-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Minor improvements to ImageMagick thumbnail filters #8850
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b07fdd7
to
cf0a3f2
Compare
alanorth
added a commit
to alanorth/DSpace
that referenced
this pull request
May 19, 2023
Minor improvements to logging and generation of PDF thumbnails by using a MIFF intermediate instead of a JPEG. Backported from DSpace 7.6. See: DSpace#8850
5cb1f85
to
5c63296
Compare
Instead of logging the name of the source bitstream, we should be logging the name of the actual thumbnail bitstream that is being considered for replacement. For example, instead of this: IM Thumbnail manual.pdf matches pattern and is replaceable. ... the message should read: IM Thumbnail manual.pdf.jpg matches pattern and is replaceable. This message is already confusing enough, but this will help.
Minor standardization to logging (unneccessary capitalization and excessive spaces).
There is no point passing a page parameter here, with a default of 0 no less, because we will *always* use the first page of the PDF to generate the thumbnail. No other filters use this function and the page parameter is not configurable so we should just hard code it.
Add some comments to document the functionality of the ImageMagick thumbnail filters. This will help others understand it later when we need to re-factor them.
When filtering PDF bitstreams, the ImageMagickThumbnailFilter first creates an intermediate JPEG and then a "thumbnail" JPEG. These two operations are both lossy. The ImageMagick usage guide warns against doing that: > JPEG losses (sic) information, degrading images when saved. > Use some other format for intermediate images during processing. > Only use JPEG format, for the final image, not for further processing. As our current filter architecture requires writing a temporary file we must choose one of the following lossless formats to use for the intermediate: PNG, TIFF, or MIFF. MIFF is ImageMagick's own internal format and is much faster to write than PNG. By eliminating the first lossy conversion we gain 1.1% points on the ssimulacra2 (v2.1) scoring scale of visual quality. See: https://imagemagick.org/Usage/formats/#jpg
5c63296
to
5357923
Compare
tdonohue
approved these changes
May 31, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks @alanorth ! Tested these minor changes today with ImageMagick for image and pdf thumbnails. No issues found... thumbnails still are created successfully.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
1 APPROVAL
pull request only requires a single approval to merge.
tools: media-filters
Related to filter-media, full text extraction or thumbnail creation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References
Description
Minor documentation and logging fixes to the ImageMagick thumbnail filters—these are not documented very well and have some logical errors. Also includes a minor optimization for PDF thumbnail generation, which changes the intermediate temp file format to MIFF instead of JPEG so we don't lose quality.
In the long term we will have to re-factor these filters, but for now I want to address some minor issues.
Instructions for Reviewers
Test running the filter-media script on an item with PDF bitstreams. Use verbose and force to make sure the process works as expected:
$ dspace filter-media -i 10568/130406 -v -f
List of changes in this PR:
getImageFile()
by removing thepage
parameter (we always use page 0 and this is not configurable so there is no need to use this parameter)See the commit messages for more information.
Checklist
pom.xml
), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.