How to calculate names of images collected as attachments

665
6
03-31-2021 09:56 PM
Mike_Koutnik
New Contributor III

Hi, We have a field data collection workflow focused on static points.  At each point one or more photos will be taken each field season.  The photos need to be easily extracted from ArcGIS for other purposes.  To do this effectively, the photos must have an identifiable name.  Photo1, Photo2, etc., don't work for us.  I need to be able to calculate the photo name, such as:

SITE1_2021_03_31_Num_01

This allows the photos to be useful in other work environments.

Is there a way to do this?  With Arcade possibly? I would rather not shift to Survey123 if I can avoid it.

Thanks, Mike Koutnik

6 Replies
AndrewBowne
Occasional Contributor III

Looks like this has been submitted as an Idea:

https://community.esri.com/t5/arcgis-field-maps-ideas/allow-attachments-to-be-named-and-made-require...

Vote it up and add some detail of your specific workflow.

0 Kudos
TravisSizemore
Occasional Contributor

Hi Mike,

I don't know of any native functions to do what you're asking. I also upvoted @AndrewBowne's suggested post. I don't know if this is a possibility for you, but you could write a short python script to rename the photos. You would just pull down the hosted feature layer into memory, download the attachments for each record (each record you haven't already processed), then rename the files using the attributes of that record, and re-upload them to that same record. There may be a faster way even in python, but I didn't see one after a quick search. 

0 Kudos
Mike_Koutnik
New Contributor III

Hi Travis,

We've thought about that option.  And that is what we may need to try as a workaround.  But the existing photos are full-res on relatively new devices.  So they are around 5MB each.  This week I downloaded the feature class (with attachments) to an fGDB from a group layer in Online.  Then I republished the feature class into its own layer in Online.  For 897 point features with a total of about 2,000 photos.  It took about 6.5 hours to republish the service from Pro.  I'd prefer not to do through that again with the Python script.  But if there was a way to reduce the resolution of the photo as I was renaming it and reinserting it, then it might be worth it.  ;)

Thanks, Mike K

TravisSizemore
Occasional Contributor
Mike,
I can see how that would be a limitation, and hopefully you find an easier way. If you do go this route, you'll need save those photos to a temporary folder on your hard drive to get them out of memory (or else your script will fail due to lack of sufficient memory). You could then compress them with one of many tools. Here's an article that discusses some of the options: https://sempioneer.com/python-for-seo/how-to-compress-images-in-python/
Good luck!
Travis
0 Kudos
Mike_Koutnik
New Contributor III
Very helpful. Thanks!
0 Kudos
Mike_Koutnik
New Contributor III

Hi, I noticed that ArcGIS Pro exposes the actually attachments table.  And the photo names appear to be an editable columns.  So a simple geoprocessing task MAY be one way to accomplish what I need.  But I haven't tried that approach yet.

0 Kudos