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

On-demand image scaling #2

Open
specious opened this issue Dec 20, 2021 · 1 comment
Open

On-demand image scaling #2

specious opened this issue Dec 20, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@specious
Copy link
Member

User contributed images are issued a random id1 and uploaded directly to the S3 media bucket. They are publicly accessible via a URL of the form:

/media/<id>

If the request is made of the form:

/media/<id>/<size>

Either a scaled version will be found by that key and immediately served, or a redirect will be issued to a scaling function that will determine whether the scaling request is valid, and if it is will download the image from the media bucket, scale it, and place the scaled image into the bucket under the scaled version retrieval key. If successful, it will then return a redirect to the scaled image.

Logic regarding which object resize requests will be carried out can be implemented inside the scaling function.

My thoughts are currently that <size> should refer to the object's vertical dimension.

Footnotes

  1. Identifying a file by the hash of its contents would arguably be better. However, currently the id is assigned before the image has been uploaded, at which point the contents wouldn't be known even by the client. To make this robust, a provisional id would need to be issued for the new upload, and then the server would need to verify the contents and assign a content-based id to the uploaded image. Refer to the get-upload-link function to see initial step in the image upload process.

@specious
Copy link
Member Author

Here's a currently experimental attempt to implement on-the-fly image resizing in C++: #4

@specious specious changed the title Automatic image scaling upon request On-demand image scaling Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant