corincerami / mars-photo-api

A Rails API for photo data from NASA's Mars Rovers
https://api.nasa.gov/#MarsPhotos
GNU General Public License v3.0
358 stars 48 forks source link

Perseverance: Grab full resolution PNG images #130

Open samgrover opened 3 years ago

samgrover commented 3 years ago

The Perseverance team is releasing images in full resolution in PNG format. These URLs are included in the feed.

The recently added support for Perseverance grabs the URL for large image (in JPG format). Please also grab the URL for full_res image (in PNG format) for all photos where it is available.

If I was familiar with Ruby, I would totally submit a pull request.

Thank you for your consideration.

corincerami commented 3 years ago

It seems like to get the full_res URL, all that's needed is to remove the last section of it which adds the size constraint and change the file extension to png. For example,

https://mars.nasa.gov/mars2020-raw-images/pub/ods/surface/sol/00004/ids/edr/browse/ncam/NLM_0004_0667310972_991ECM_N0010052AUT_04096_00_2LLJ01_1200.jpg

becomes

https://mars.nasa.gov/mars2020-raw-images/pub/ods/surface/sol/00004/ids/edr/browse/ncam/NLM_0004_0667310972_991ECM_N0010052AUT_04096_00_2LLJ01.png

Rather than storing and presenting multiple URLs in the API, perhaps you can manage this in your application.

samgrover commented 3 years ago

That could work if that assumption on URL structure can hold for the lifetime of the rover. I'm not well versed with these data sets. In your experience, is the structure likely to change?

corincerami commented 3 years ago

Based on my experience with the other rover datasets, that seems very unlikely. They tend to be very structured.

mtilda commented 3 years ago

@chrisccerami is this a feature you are interested in adding? Or is there a reason you would not want to add it.

It seems like we could add this feature to the photos controller by checking for a size parameter (possible values: "small", "medium", "large" (default), "full_res").

We wouldn't need to store extra data. We would only need to create a function to mutate the URL to correspond with the selected size.

I am happy to spend some time working on this.

corincerami commented 3 years ago

@mxkay if you want to give it a shot, I'd be open to it. If folks think that would be a useful feature I'm certainly not opposed to it.

samgrover commented 3 years ago

I'm primarily interested in the lossless PNG file. I could work with the workaround suggested above, but a dedicated entry in the response would be wonderful.

mtilda commented 3 years ago

Sweet :) I will begin working on adding a photo size parameter to the API. @chrisccerami should I make a new issue for that?

corincerami commented 3 years ago

That's not necessary, you can just reference this issue in your PR. Thank you.

ken-2021 commented 3 years ago

In python Import requests Get url Open file to get content should be "true"