WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 3 months ago

#45598 accepted enhancement

Prevent unnecessary whitespace around thumbnails when processing cropped PDFs

Reported by: michel.weimerskirch Owned by: joemcgill
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch needs-testing
Focuses: Cc:

Description (last modified by SergeyBiryukov)

When generating thumbnails from cropped PDF pages, Imagemagick uses the uncropped area - resulting in unnecessary (and ugly) whitespace - unless the option "use-cropbox" is set.

I attached a patch that solves the issue by setting a parameter in ImageMagick. Note that this doesn't in any way affect uncropped PDFs.

I also attached a demo.pdf for you to reproduce the issue as well as two thumbnails generated before and after the patch.

Attachments (4)

wp-imagemagick-pdf-thumbnail.patch (1.1 KB) - added by michel.weimerskirch 7 months ago.
Patch
demo_cropped.pdf (61.9 KB) - added by michel.weimerskirch 7 months ago.
Demo file to reproduce the issue
demo-before-patch.png (126.6 KB) - added by michel.weimerskirch 7 months ago.
Thumbnail generated BEFORE the patch (with whitespace around the cropped image not visible in the PDF itself)
demo-after-patch.png (118.8 KB) - added by michel.weimerskirch 7 months ago.
Thumbnail generated AFTER the patch

Download all attachments as: .zip

Change History (7)

@michel.weimerskirch
7 months ago

Demo file to reproduce the issue

@michel.weimerskirch
7 months ago

Thumbnail generated BEFORE the patch (with whitespace around the cropped image not visible in the PDF itself)

@michel.weimerskirch
7 months ago

Thumbnail generated AFTER the patch

#1 in reply to: ↑ description @michel.weimerskirch
7 months ago

Replying to michel.weimerskirch:

Not that this doesn't in any way affect uncropped PDFs.

Small typo. This should say "Note that this doesn't in any way affect uncropped PDFs." (unfortunately, Trac doesn't allow editing tickets)

#2 @SergeyBiryukov
7 months ago

  • Description modified (diff)

#3 @joemcgill
3 months ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to 5.3
  • Owner set to joemcgill
  • Status changed from new to accepted

Thanks @michelweimerskirch, this looks like a nice improvement. I'm adding this to the 5.3 milestone for testing.

Note: See TracTickets for help on using tickets.