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

fix: ensure that VimsImageProcessor#write_to_jpeg writes jpg #40

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

knarewski
Copy link
Contributor

Problem

Vips determines file format using the extension taken from the target filename. That makes VipsImageProcessor#write_to_jpeg's behaviour misleading for names with a different extension (eg image.png) and broken for names with no extension (eg tmp123413123). Example error message:

`write_to_file': VipsForeignSave: "tmp/no-extension" is not a known file format (Vips::Error)

Solution

Write to file with .jpg extension, then rename to target filename

Notes

  • code uses the same location as original, so should be performant
  • I've also did a little style fix for specs, changed to use context instead of describe where it felt appropriate

"describe" feels more accurate when discussing the interface, while "context" fits well when we are talking
about particular scenario/setup"
… of the output file extension

Since vips chooses format based on the extension, the easiest way to guarantee the expected format is to append .jpg to the filename, then rename
@knarewski knarewski requested a review from a team December 4, 2024 15:37
Copy link
Contributor

@MrLukeSmith MrLukeSmith left a comment

Choose a reason for hiding this comment

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

LGTM

@knarewski knarewski merged commit fe97a53 into master Dec 5, 2024
15 checks passed
@knarewski knarewski deleted the fix-ensure-that-write-to-jpeg-writes-jpg branch December 5, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants