Skip to content

FIX: key optimized images on format #32575

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

Merged
merged 3 commits into from
May 6, 2025
Merged

FIX: key optimized images on format #32575

merged 3 commits into from
May 6, 2025

Conversation

SamSaffron
Copy link
Member

@SamSaffron SamSaffron commented May 5, 2025

Previous to this change when we used to specify format it could get an image
in the incorrect format.

Also... allows image magick to decode svg


There remains a bug where the crop / resize information is not stored in optimized images
this means that sometimes when asking for a cropped image you may get a resized one.

Previous to this change when we used to specify format it could get an image
in the incorrect format.

Also... allows image magick to decode svg

---

There remains a bug where the crop / resize information is not stored in optimized images
this means that sometimes when asking for a cropped image you may get a resized one.
@SamSaffron SamSaffron changed the title optimize diff formats FIX: key optimized images on format May 5, 2025
@@ -49,7 +49,8 @@ def self.create_for(upload, width, height, opts = {})
end

# prefer to look up the thumbnail without grabbing any locks
thumbnail = find_by(upload_id: upload.id, width: width, height: height)
extension = ".#{opts[:format] || upload.extension}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to store the leading . for every single optimized images? 🤔

Copy link
Member

@ZogStriP ZogStriP May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "format" to correct name for the option? Why not "extension"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree this needs cleaning up, but I worry about the huge rabbit hole here. The . and calling this format is very confusing.

@@ -49,7 +49,8 @@ def self.create_for(upload, width, height, opts = {})
end

# prefer to look up the thumbnail without grabbing any locks
thumbnail = find_by(upload_id: upload.id, width: width, height: height)
extension = ".#{opts[:format] || upload.extension}"
thumbnail = find_by(upload_id: upload.id, width: width, height: height, extension: extension)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: you can omit the variables when the keys have the same name

Suggested change
thumbnail = find_by(upload_id: upload.id, width: width, height: height, extension: extension)
thumbnail = find_by(upload_id: upload.id, width:, height:, extension:)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh til

@@ -93,7 +93,7 @@ def self.create_for(upload, width, height, opts = {})
opts = opts.merge(quality: target_quality) if target_quality
opts = opts.merge(upload_id: upload.id)

if upload.extension == "svg"
if extension == ".svg" && upload.extension == "svg"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just extension == ".svg" is enough here? We can't convert any raster images into an SVG anyways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good point I guess we should reject earlier...

@SamSaffron
Copy link
Member Author

thanks @ZogStriP

@SamSaffron SamSaffron merged commit c8d6dd2 into main May 6, 2025
16 checks passed
@SamSaffron SamSaffron deleted the optimize_diff_formats branch May 6, 2025 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants