Rename image files storaged in aws instead of "original.jpeg" etc

Platform(s), such as mobile, website, API, other:
Website
URLs (aka web addresses) of any pages, if relevant:
https://inaturalist-open-data.s3.amazonaws.com/photos/238838746/original.jpeg
Description of need:
Describe the iNaturalist community need that your requested feature addresses. Include screenshots, URLs, and other details to help us all understand the issue.
iNaturalist stores images with the same file name like “original.jpeg, large.jpeg, etc”. However when downloading images it is not convenient to rename files manually (otherwise there will be many duplicate “original.jpeg”, brower may rename them as “original(1).jpeg or simply delete previous one”).
Feature request details:
In detail, describe the feature you are requesting. This includes its functionality, where the feature is implemented, and what it might look like. Screenshots or mock-ups are helpful. The idea is to have a concrete and actionable request which the community can discuss and vote on. It might change through discussion, but it’s much easier to iterate and talk about something specific.
Is it possible to change the name of image files storaged in aws instead of “original.jpeg” etc? If with image ID it will be better. For example rename the file as “ID-original.jpeg” (https://inaturalist-open-data.s3.amazonaws.com/photos/238838746/238838746-original.jpeg instead of https://…/238838746/original.jpeg) so that file name of downloaded images can be easily correspond to images on website.

This is what I replied to an iNat staff Tony. I didn’t realized it was private coversation so I paste it here publicly to help others understand the case:
Hi Tony,
I download images manually, maybe a few images in an observation.
For example, there are 5 images in an observation:
EXAMPLE OBSERVATION
If I want to download them all for educational purpose, I have to right click → save image as → rename the image manually from “original.jpeg”. Because all the image URLs stored in iNat are end with “original.jpeg” etc, for example “https://inaturalist-open-data.s3.amazonaws.com/photos/238838746/original.jpeg”, I have to copy the ID number in the URL (238838746 in this case) and paste it to the file name input box, so that image will be saved as “238838746.jpeg”.
The main purpose of saving images’ file name as ID number is making sure I can find where the image I downloaded from previously. A “238838746.jpeg” in my disk is easier than an “original.jpeg”.
Best regards,
Sun

2 Likes

i don’t really understand the need for this kind of change. if you’re manually downloading the files, i assume you would be downloading only a few, and in that case, your existing process seems not to be a huge burden. if you’re going to be downloading more than that, i would think you would want to use a process that will automate a lot of this, and if you’re going to be automating, you can automate the process of naming the downloaded files to whatever format you like.

how many images do you plan to download?

Even if you download just a handful of files (e.g. 10) it’s still a PITA to have to rename each one every time.

I am actually surprised that these files aren’t already named based on the obs/pic ID e.g. 123456_1_original.jpeg

3 Likes

you wouldn’t want to store them on the server based on observation ID because one observation can have many photos, and a single photo can be used by multiple observations.

if you want to store them based on observation ID for your own personal use, that’s fine, but i think the varying preferences here just kind of prove why it doesn’t really make things better to change the way the files are stored on the server.

1 Like

I edited my post to take multiple photos into account - I think you must have missed that change :)

Also you don’t need to store them on the server with a particular filename. You just need to generate them for download with that filename.

so now you want to add download button to the photo page that will download the file using your naming convention? i guess you can request that feature, but that’s different than what the original proposal here is.

2 Likes

Sigh. No.

1 Like

I don’t have a strong feeling about this request (I agree that for bulk downloads, writing a script that renames how you want makes the most sense).

BUT, if the file names are changed, I would suggest doing away with the “original” name stub since it has lead to confusion in the past and isn’t correct for many photos. Since iNat downsizes larger pics for storage, many/most that download as “original” aren’t actually original. Some users have thought that they are though because of that “original” stub. Maybe something like “max” or other signifier that the size is the largest option iNat offers, etc.

The image url already contains all the necessary infornation, since the path element includes the photo ID. The issue here is that the browser is generating the save-as filename, not the web page. The browser could generate a filename based on the last two elements of the url path, but it doesn’t. Changing this behvaiour would require a browser extension. The only other alternative, as has already been suggested, would be to add some kind of download feature to the web page itself. This could actually be done fairly easily with a userscript extension. All that’s needed is to insert a link on the page with a data-url containing the image data and a download attribute with the desired filename.

2 Likes

If you’re already typing a lot (like with the URL shown) maybe using a CLI tool like wget might be an option?

as someone who regularly saves photos from iNaturalist, this would be a nice quality of life improvement. filename should be something like “observation#_photo#.jpg”

2 Likes

This would represent a big change but it’s something we support. There are several other improvements we’d like to make surrounding photos, and it would probably happen along with those other changes. So yes, not going to be addressed in the near future, but it’s on the drawing board.

4 Likes

Yes. That’s what I am really looking for. Maybe someday I would want to find where I downloaded from of an image in my disk. Naming the image file name as some unique number will help a lot.

This is totally necessary, because as stated, it is a real pain, copying the poster’s username, and the ID, adding the latin, also the location, so that if it needs citing it’s all there in the filename and the originals can be refound and the link constructed.
When saving photos this needs to be automated.
Presumeably one restriction may be that the images are hosted on a different site, but I’d have thought just adding a “Download Image” link that runs a couple-of-line php to fetch the image and return it as a download would solve that. i.e. if your webpage image is (to use a real example) Delairea odorata posted by pbeja65 as observation 104977897 for 15 Jan 2022 with the image
https://inaturalist-open-data.s3.amazonaws.com/photos/176027311/large.jpeg
you’d have with the image
<a href=‘…downloader.php?url=(as above)&name=Delairea odorata - pbeja65 - iNat104977897 - Portugal - 2022-01-15 - Img176027311’>Download Image</a>
and when clicked the downloader.php would simply read the content requested and return it verbatim with the filename requested, which would be barely 2 lines of code. Whilst this may add an extra bit of work for some server the php is on when utilised the actual number of people downloading rather than simply viewing should be small. You could also add timestamp and a hashed validity timestamp+url parameter+secretservercode for checking so it couldn’t get utilised by external processes.
In the longer term there would of course be other ways that could be put in place…
David

i was thinking about this since the thread popped up again, and i don’t think this will work.

from what i gather, the download attribute in anchor tags works only same-origin. since the images come from a different host, i think you’ll need a more complicated mechanism to download images to a different filename. (i tried it by using my browser’s dev tools to edit the HTML of an observation page, and download works for things coming from www.inaturalist.org, but not for things coming from other hosts.)

that said, there still are other ways to automate download to a different filename…

i made a small modification to https://jumear.github.io/stirfry/iNatAPIv1_observations which may help folks in some cases. it can now display a column that provides cURL commands to download photos, setting the destination filenames to include one or more prefixes. for example, https://jumear.github.io/stirfry/iNatAPIv1_observations?id=139619286&options=photocurl&photo_curl_filename_prefix=obs_id,obs_seq,photo_id will take you to a page that looks like this:

you can copy the text from the last column:

curl https://inaturalist-open-data.s3.amazonaws.com/photos/238838746/original.jpeg -o 139619286_01_238838746_original.jpeg https://inaturalist-open-data.s3.amazonaws.com/photos/238838763/original.jpeg -o 139619286_02_238838763_original.jpeg https://inaturalist-open-data.s3.amazonaws.com/photos/238838781/original.jpeg -o 139619286_03_238838781_original.jpeg https://inaturalist-open-data.s3.amazonaws.com/photos/238838796/original.jpeg -o 139619286_04_238838796_original.jpeg https://inaturalist-open-data.s3.amazonaws.com/photos/238838841/original.jpeg -o 139619286_05_238838841_original.jpeg

… and if you paste and run that from your OS command line in the directory where you want to save the photos, cURL will download the photos associated with observation, prefixing the filenames with observation id, observation sequence, and photo id.

there are many other ways to automate, but i thought this would be a relatively simple but flexible approach that most folks could understand and use without too much effort.

1 Like