Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve images based on aspect ratio query #458

Closed
youriwims opened this issue Feb 19, 2019 · 8 comments
Closed

Serve images based on aspect ratio query #458

youriwims opened this issue Feb 19, 2019 · 8 comments

Comments

@youriwims
Copy link

The API needs to be capable of serving optimized, uploaded images to specific aspect ratios/dimensions based on a query parameter.

Use-case: Currently on the foundation site, I am trying to render Fellow images from Pulse at a 1:1 aspect ratio, but the current system doesn't allow me to do that solely with the URL that is being served.

cc: @patjouk

@Pomax
Copy link
Contributor

Pomax commented Feb 19, 2019

corresponding issue over on the foundation repo: MozillaFoundation/foundation.mozilla.org#2687

@Pomax
Copy link
Contributor

Pomax commented Feb 19, 2019

Depending on the "physical" size we need, we might be able to do some python resizing magic, and send the profile headshots over as base64 strings as part of the API response, or we might be able to set up a dedicated API route for headshot images that we can call based on an id, like api/profiles/<id>/thumbnail

@Pomax
Copy link
Contributor

Pomax commented Feb 19, 2019

Headshots would be 192x192 x1, 384x384 x2, so that would pack on probably about 10kb in compressed JPG per profile - that makes it impractical to add it as BASE64 string in the API response itself, but makes it quite suited for serving up as dedicated API response on a /profiles/<id>/thumbnail route.

@alanmoo API responses already tie profile ids to headshot URLs, would there any privacy concerns over also having a dedicated "just the headshot" route?

@Pomax
Copy link
Contributor

Pomax commented Feb 19, 2019

I'm also not entirely sure whether this is a thing we can easily do, if the API server itself just deals with the metadata. I'm sure we don't want the API server to also become an image proxy, so we'll have to think about how best to get images resized in a way that doesn't bog down the API server itself.

@patjouk
Copy link
Contributor

patjouk commented Feb 21, 2019

We were discussing this issue with @cadecairos and it reminded me of that: https://github.com/codingjoe/django-stdimage. It sounds pretty cool and we could use this https://github.com/glemmaPaul/django-stdimage-serializer/blob/master/stdimage_serializer/fields.py as a prototype to build our own serializer.
Maybe that could unblock you?

@Pomax
Copy link
Contributor

Pomax commented Feb 22, 2019

Oh wow, that definitely looks pretty cool, let's see how far that gets us!

@youriwims
Copy link
Author

@Pomax am I able to just install and use the StdImageField or should I be waiting for the serializer to be built?

@Pomax
Copy link
Contributor

Pomax commented Apr 4, 2022

Closing this issue due to having gone stale - if this is still something we want to do, let's file a new issue with all the information necessary for triaging.

@Pomax Pomax closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants