Survey123 Tricks of the Trade: Photos

81895
70
08-06-2020 06:31 PM
IsmaelChivite
Esri Notable Contributor
15 70 81.9K

Updated December 2, 2022 (setFileName property to rename photo file names)

 

Survey123 includes great capabilities to help you specify how photos should be captured from your smart form. The 3.10 release, introduces even more: multiline appearance and the method setting in the body::esri:style column. This blog highlights these new features and a few other techniques so you can get the best out of photos in your smart forms. Most of what is described in this article involves the use of Survey123 Connect and requires familiarity with XLSForms. Check out the Survey123 XLSForm tutorials in YouTube or our documentation if you need to get started.

 

As with many other Tricks of the Trade articles, we will start easy, and progressively explore more sophisticated techniques one step at a time.

 

The Basics: One question, one photo.

 

If you want your users to submit a photo through your smart form, you will include a question of type image. Here is an XLForm example:

 

typenamelabel
geopointlocationIncident location
imagephotoPhoto of the incident

 

Like any other question type, you can use the required column to define if the end user must submit data for your question or not. In the next XLSForm example, an expression is used in the required column to determine if a photo must be submitted. If the severity of the incident is high, then a photo must be submitted. Otherwise, the photo question will be presented to the user as optional.

 

typenamelabelrequired
geopointlocationIncident location 
select_one severityseveritySeverity 
imagephotoPhoto of the incidentselected(${severity},"high")

 

Controlling the source of the photo: Camera versus browse

 

By default, the Survey123 web and field apps will let end users either take a new photo using the camera or browse for an existing photo in the device. Sometimes, you want to have control over the source of the photo. If you are designing a survey for inspectors to document code violations, for example, you may want them always to take a new photo with the camera, and not allow browsing of existing photos in the device.

 

The method parameter in the body::esri:style XLSForm column lets you specify if both methods are allowed, or just one. If the method parameter is set to camera, users will need to capture a photo using the camera. If method is set to browse, users will need to browse for an existing photo. If you want to give users a choice, leave the the body::esri:style column empty or set the method parameter to camera,browse

 

Here is a visual representation of what the user experience looks like using the different method parameter options:

And here is what an XLSForm looks like if you want to force users to submit a new photo from the camera:

 

typenamelabelbody::esri:style
geopointlocationLocation 
imageimagePhotomethod=camera

 

One question, multiple photos

 

If you want users to submit more than one photo with your survey, you can either add multiple image questions or alternatively use the multiline appearance on an image question. There are good cases for both approaches. For now, lets start with the multiline appearance:

 

typenamelabelappearance
geopointlocationIncident location 
imagephotoIncident photosmultiline

 

Support for the multiline appearance for image questions was added in version 3.10. When using the multiline appearance you will initially not see much of a difference in your form. However, after you take the first photo, you will see that new options appear for you to take additional photos and navigate through all the photos you have taken.

 

Counting photos submitted, and limiting how many photos can be submitted

 

The XLSForm count-selected() function can be used to get the number of photos a user has added to an image question. Two common uses for this function are calculations and constraints.

 

The following example shows how you can store as a feature attribute the total number of photos submitted through an image question. Once you have this attribute, you can use it to filter, label or simply set the symbology of features in a web map. For example, you may want to create a filter to hide features with no associated photos.

 

typenamelabelappearancecalculation
geopointlocationIncident location  
imagephotoIncident photosmultiline 
integerphoto_countPhotos submitted count-selected(${photo})

 

Using count-selected(), you can also also control how many photos can be submitted with a question. For example, you can setup a constraint to limit photos submitted with your image question to less than 5:

 

typenamelabelappearanceconstraint
geopointlocationIncident location  
imagephotoIncident photosmultilinecount-selected(${photo})<5

 

You can use count-selected() against an image question with and without the multiline appearance.

 

Image questions and repeats

 

Support for the multiline appearance in image questions was added with version 3.10. Before that, if you wanted users to upload more than one photo you had to either add multiple image questions to your survey or include the image question within a repeat. Adding multiple image questions in a survey is still a valid pattern, as we will describe later. Creating a repeat block simply to include a single image question is never a good idea, because the repeat will create a new related table and your attachments will link to that table. It will be extremely difficult for you to later explore the attachments in ArcGIS that way. Instead of using a repeat for that, use the multiline appearance as described above.

 

typenamelabelhint
geopointlocationLocation 
begin repeatphotosPhotosDo not create a repeat just to add a single image question in it. Use the multiline appearance instead on the image question (as shown above)
imagephotoPhoto 
end repeat   

 

For clarity, this is not to say that you should not include image questions within a repeat. For example, If you want to have a repeat and then add an image question along with a text question for a description or something else, that is all good. It is adding a repeat containing just an image question that should be avoided.

 

Here is an example where having an image question within a repeat is justified. In this case, the repeat makes sense because we want to associate multiple attributes (Direction, Latitude, Longitude as well as a user entered description) with every photo.

 

typenamelabelcalculationbind::esri:fieldType
geopointlocationLocation  
begin repeatphotosPhotos  
imagephotoPhoto  
textdesDescription  
calculatedirDirpulldata("@exif", ${photo}, "GpsImgDirection")esriFieldTypeDouble
calculatelatLatpulldata("@exif", ${photo}, "GpsLatitude")esriFieldTypeDouble
calculatelonLonpulldata("@exif", ${photo}, "GpsLongitude")esriFieldTypeDouble
end repeat    

 

Note that photos in the repeat table have attributes to extract their direction, latitude, longitude and even a user-entered description of the photo. Storing all these attributes for every one of the photos would not be possible using the multiline appearance in the image question. This is what justifies the use of the repeat.

 

If you are not familiar with the pulldata("@exif") function check the https://community.esri.com/groups/survey123/blog/2017/12/12/working-with-exif-image-metadata-in-surv...  blog post.

 

One survey, multiple photos

 

It is possible to include multiple image questions within a single form. Note that adding multiple image questions to a form is very different from enabling multiple photos in a single question.

 

The Virginia Department of Agriculture and Consumer Services (VDACS) was notified in early 2020 that many residents in the State had received unsolicited packages containing seeds from an unknown source. To better understand the extent of the problem, a survey was put together for Virginia residents to submit reports of unsolicited seed packages. In this survey, one question was added to capture a photo of the front of the envelope, and a separate question for the back of the envelope.

 

 

Rather than asking users to take one or more photos of the envelope in a single question with multiline appearance, this survey uses two separate image questions. This gives more explicit direction to the user, which generally is going to yield better data.

 

typenamelabel
imagephotoFrontFront of package
imagephotoBackBack of package

 

An additional advantage of using multiple image questions is that each of the photos will be automatically tagged by Survey123 with the name of the corresponding image question. This later on will be an advantage when you want to put your photos into a Survey123 report. Since the front and back photos are tagged differently, you will be able to specify where exactly each of the photos should go.

 

Using multiple image questions within a form is a good practice when you want to explicitly tell users what each photo should contain. In the Virginia seeds use case above, you are telling users to take a photo of the front of the envelope first, and then a photo of the back. This is a good use case. If you want to simply want to open up the possibility of submitting multiple photos of something, then the multiline appearance is the way to go.  For example, say you want people to submit multiple photos of an issue in an asset. You do not know in advance what exactly the end user will report, but you want that user to be able to submit a few photos; that is a perfect example for multiline.

 

Since the multiline appearance was not available in the past, some of you created surveys with multiple image questions as follows:

 

typenamelabelhint
geopointlocationLocation 
imagephoto1Photo 
imagephoto2PhotoDon't do this. Use mutliline appearance in photo1 instead
imagephoto3PhotoDon't do this. Use mutliline appearance in photo1 instead

 

Now that the multiline appearance has been added, it is time to adjust the XLSForm design accordingly. Remember you can also use the count-selected() function to limit the number of photos that you want people to submit. Removing the extra image questions in your form will not cause data loss, however, keep in mind that the multiline appearance is only supported in Survey123 3.10 or newer, so you will want end users to be up to date with their app version or otherwise the appearance will be ignored.

 

Controlling the size of photos

 

Using Survey123 Connect, you can control the size of photos sent to ArcGIS. There are a number of devices out there and each of them may send photos of different sizes. You can bring consistency by properly configuring your survey from Survey123 Connect.

 

In Survey123 Connect, go to the Options tab of your survey and scroll down until you see the Images section. Use that setting to control how big you want images to be when sent to ArcGIS. The default value is 1280 pixels on the largest edge, which generally works well for most workflows, the quality is good and the size of the photo is manageable.  However, you can reduce images down to 320 pixels or leave them in their original size.

 

IsmaelChivite_0-1654534904705.png

 

The Survey123 Connect setting above applies to all image questions in your form, unless you overwrite this value with the max-pixels parameter. As you can likely already tell, the max-pixels parameter controls the image size on the longest edge at the question level.

typenamelabelparameters
geopointlocationIncident location 
imagephotoIncident photosmax-pixels=600

 

Photo filenames

 

Survey123 automatically assigns a unique filename to photos. The filename includes as a prefix the name of the image question and it is followed by a unique number. If you want to persist the name of your photos as a GIS attribute, use a calculation as shown below.

 

typenamelabelappearance
calculation
imagephotoPhoto of the incident  
textphoto_filenamePhoto filenamehidden${photo}

 

If you want to set the name of the photo file yourself, you can. You will use the fileName property in the bind::esri: parameters column for that. 

 

typenamelabelbody::esri:parameters
imagephotoPhoto filename=concat("Photo_",format_date(now(),"%y%m%d%H%M%S"))

 

Check this help topic or this blog, for more details on how to set the fileName property.

Photos in reports

 

Survey123 includes a powerful report service which you can use to create high quality reports in MS Word and PDF format. Check https://community.esri.com/groups/survey123/blog/2019/07/23/understanding-survey123-feature-reports for an introduction to this service.

 

Survey123 reports require you to create a template specifying the content and look and feel of your report. These templates are authored as Microsoft Word documents where you insert placeholders to fetch data from your survey records. The full syntax for report templates is described at Feature report templates—Survey123 for ArcGIS | Documentation 

 

In regards to photos, you can control the size of the photos in your report and even where to put each of the photos from your survey. This is where using mutliple image questions can really pay off.

 

For example, the following syntax in a report template will insert into your report the photo corresponding to the incident_photo question in your form. The photo will be added to the document with a width of 300 pixels and the height will grow proportionally to preserve the original aspect ratio.

${incident_photo | size:300:0}

If you used the multiline appearance in your survey, you will want to use the following syntax to arrange all photos vertically within your report:

${#incident_photos}
${$file | size:300:0}
${/}

This syntax will arrange the photos horizontally (note that I adjusted the width to 200px to have images fit within the width of the page).

${#incident_photos}${$file | size:300:0}${/}

Unfortunately, as of the time I write this, it is not possible to arrange photos in a table (each photo in its own cell). Mike Onzay‌ figured that adding a space right before the closing tag would add a nice separation between photos. That is pretty clever! Thanks Mike for the tip! Here is the same expression with the space added:

${#incident_photos}${$file | size:300:0} ${/}

 

Photo Watermarks

 

Photo watermarks is a neat feature in Survey123. Since this article is about photos, I thought I would bring it up, although there is a separate blog covering this topic https://community.esri.com/groups/survey123/blog/2019/08/08/survey123-tricks-of-the-trade-photo-wate... 

70 Comments
MJBiazar
Esri Contributor

@bgomes thanks for the update! I'm glad that we were able to reproduce the same behavior in field app. 

We are currently discussing this behavior internally to confirm what is the expected behavior in both field app and web app with both constraint formats and log a defect if needed. 

Please let me know if you run into any issues moving forward or if you have any other questions. 

Best,

MJ

DougBrowning
MVP Esteemed Contributor

Is there any support for PhotoSphere images?  Or VR?

thanks

Katie_Clark
MVP Alum

Hello! I know this article is over a year old now, but wanted to say thanks for writing this - very helpful!

"Unfortunately, as of the time I write this, it is not possible to arrange photos [from a repeat] in a table (each photo in its own cell)."

Is this still the case? Being able to put specific photos from the repeat into specified cells in a report template would be a game changer! Are repeat values indexed? Perhaps you could possibly implement something like this by using syntax along the lines of: 

${#incident_photos}${$file[1] | size:300:0} ${/}

Where the [1] indicates the second photo from the repeat (assuming the indexes start at zero).

Is something like this being considered for future product plans?

@IsmaelChivite @MJBiazar 

FRSadmin
Occasional Contributor

@IsmaelChivite 

Hello, I had two maybe minor questions?

Our survey team uses multiple photos and wants to be able to have the file name exported into the csv document. Looking at another thread this was solved for individual photos by placing a text field under after the photo and using ${image} in the calculation column.

I want to know, for multiple photo questions is there a way to return the multiple file names?

 

Lastly, One issue we have is that our cell plan data limits prevents us from always sending those high quality photos through Survey123, but if we alter the photo max pixel size and send a picture, the original photo is saved to those standards.

Is there a way to use the camera to take a high quality photo, have that saved onto the phone as is, and then send a lower quality photo so we don`t use all of our data?

Sorry for the long post! Really getting knee deep into survey123 as of late.

IanGallo
Regular Contributor

I agree. This would be incredibly useful for us as a lot of our data collection needs are housed inside repeats. Images are not always collected so it would be much more space efficient on the pdf to list a table of text values for a repeat then, later in the document, show a table of images associated with some of those rows of text in the table. This would also allow us to display larger images which would make the report more useful for our customers.

Any timeline for this kind of enhancement?

@Katie_Clark @IsmaelChivite @MJBiazar 

codergrl
Occasional Contributor

@IsmaelChivite 

Thank you for adding this functionality and writing this article. Extremely useful! I just implemented the multiline photos for one of our clients and they love it. But now they are asking about being able to add multiple photos at once. So, when they browse to select their images, they want to be able to select multiple images to add, not just one at a time. Is there a way to do that? Are there any plans to enable this?

Alternatively, would enabling this type of functionality be possible through addins? We just started looking at addins so we're not quite sure yet what's possible and what the limitations are. Thank you!

by Anonymous User
Not applicable

It is my understanding that the exif data in the photo will not be included when you downsize the image for transfer.

DougBrowning
MVP Esteemed Contributor

Has anyone come up with a good idea to handle photo comments when using the new multiline option?  I always did 2 fields Photo1 and Photo1Comments and then a bunch of those or I use a repeat.  That way when I export later I can add the comments right into EXIF.  I know we can calculate the file name now but what I would really like is a way to embed comments into the EXIF right in the 123 form.

Also how far have you pushed the form?  We have one program that adds up to 19 a form and it does go.  This new program wants to add as many as 68!  I have a feeling it will time out.

thanks

JonathanPollack
Frequent Contributor

Great stuff.  Is there any support for multi-photos to be visible in the "Inbox" submittals like you can with Repeats photos?  

MarjorieDillinghamGOAA
Occasional Contributor

Hello,

When submitting a survey we would like to send the images to a database that is different than the one the survey is going to.  The data from the survey will be pulled by Maximo Spatial from our ArcGIS Enterprise feature classes to create work orders.  We would like the images to go to a shared database so they do not have to be copied and stored twice.  Is this possible?

Andrew-Bowne
Frequent Contributor

If Maximo has an API you could probably automate this using Make or Microsoft Power Automate.

LMedeirosUI
Frequent Contributor

This blog post needs to be updated to reflect the fact that photos can now be named using the fileName command in the bind::esri:parameters column. It moved out of the beta phase in late June of 2022 so users can implement the change without being part of the beta group.

More information on this feature is located in the "Image file names" section of this documentation: https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformmedia.htm

And in the "Use XLSForm to set the file name of photos and signatures" section of this blog: https://community.esri.com/t5/arcgis-survey123-blog/what-s-new-in-arcgis-survey123-june-2022/ba-p/11...

 

 

JohnWatson_EBA
Regular Contributor

@IsmaelChiviteI haven't found this question or answer yet, so I thought I'd ask: in Connect, can you use the calculation column to calculate (or populate) an image from the related table to the parent FC? We are using an existing FC for point locations and the survey results are being collected in the related table. I want the image taken in the survey to then be copied up to feature class. Is that possible?

AlderMaps
Frequent Contributor

YEEEESSSSSS!!!!

I was slamming my head against the wall trying to use repeats for an image question on a table with attachments enabled (old way, I guess). I just needed to find THIS information about adding a single image question, with attachments enabled (not a custom table with a relationship class I created) and using the multiline appearance. SLICK!

(And I've looked at enough Esri blogs and posts and forums over the last day that I already knew, when I did find the answer, it would probably be in content from Ishmael).

THANK YOU!!!!!!!!!

MatthewBertrand
Occasional Contributor

I want to have a user submit a single, high-quality photo, but then in a hidden field make a lower quality duplicate of the photo for web display. I want the original high-quality photo for print marketing purposes, and the low-quality as an autofeed into an Experience Builder application. Is there a way to do this?

So far, I've learned the calculation field can pull an image in from another image question. However, I have not been able to resize that image.

  • I've tried setting parameters to "max-pixels=400" but it doesn't resize. From documentation, this only appears to resize an image when input through a question prompt, not when calculated
  • In the calculation field I've also tried using the calculation suggested above for reports, e.g. "${photo_original | size:300:0}", but I get an error "there is no survey element with this name" so I assume this syntax doesn't work here.
  • I could prompt the user to enter the photo twice with different max-pixels parameters, but that's not great customer service. I'd rather automate the image resize if possible

Anything I'm missing? I assume this just isn't possible.

Thank you!

Arnaud_Brival
Occasional Contributor

Dear @IsmaelChivite , 

First and foremost,  as always, your trick of the trade posts are fantastic!  Thanks for these!

a quick message to raise a potential issue we may have encountered: 

All our photo based coral monitoring surveys were working fantastically. 

when we realised that pictures sent were being compressed, I fiddled in Survey123 Connect options to set the max photo size to unrestricted... in hope to improve the quality of our photo submission. 

Unfortunately, after a few submission error, I then learnt that there was a set max size of 10Mb when using the field App. Using a recent Gopro,  most of our photos are in the 12-15Mb range so it's a quite pity, but also an understandable (technical?) limit.  

Our problem,  is that since then, I have republished the surveys after reseting the max Photo sizes in the Connect options.  but ever since and despite mutliple republishing attempts,  the photos are no longer being compressed when uploaded in the survey123 app..... So now all we get is a constant "fail to send error" because pictures seem to be uploaded uncompressed and therefore with a file size beyong the the 10Mb limit.  

Could this be a small bug?   any advice on how to maybe to fix this? 


Thanks a lot for your time and consideration,  and thanks again for all the hardwork and great tips! 




JohnWatson_EBA
Regular Contributor

@Arnaud_BrivalIsmael is not on the Survey123 team anymore, so tag @JamesTedrick to see if he can help you.

PaulCone2
Frequent Contributor

Is there a way to have an image repeat inside a geopoint repeat?  I'm working on a form (for damage assessment) and we want multiple locations each of which can have multiple photos.  For example, a facility could have multiple reports of damage (each with a location) and then each damage report could have multiple photos.  I have set up a repeat and then inside that a geopoint question and an image question with multiline appearance, but I only get the geopoint repeat.  No image repeat.  Is there a way to do this?

JamesTedrick
Esri Esteemed Contributor

@PaulCone2 - The multiline appearance does not create a full repeat; rather, after adding the first image you will see buttons to allow you to add additional images: 

img_multiline.jpg

 

typenamelabelappearance
begin repeatr1Repeat 
geopointlocGeopoint 
imageimg1Imagemultiline
end repeat   
PaulCone2
Frequent Contributor

@JamesTedrick hmm... that's what I have set already in the .xlsx but that's not what I'm seeing in my survey...

PaulCone2_0-1761841029870.png

IMG_0011.PNG

 

PaulCone2_1-1761841048106.png