Skip to content

Fix resolution unit in Imagick ResolutionModifier - #1548

Merged
olivervogel merged 1 commit into
Intervention:developfrom
NotAFlightRisk:fix-imagick-resolution-units
Oct 5, 2026
Merged

olivervogel merged 1 commit into
Intervention:developfrom
NotAFlightRisk:fix-imagick-resolution-units

Conversation

@NotAFlightRisk

Copy link
Copy Markdown
Contributor

setResolution() is documented as DPI, but the Imagick driver keeps whatver unit the image already had. ImageMagick reads a PNG's pHYs chunk as pixels per centimetre, so setResolution(300, 300) on a PNG from disk saves a 762 DPI file. A PNG with no pHYs at all gets no unit either, and saves without any DPI. GD writes 300 for both.

This sets the unit to pixels per inch along with the resolution. The new test reuses 300dpi.png and fails on develop as it stands.


crop() on Imagick has the same gap. The canvas it rebuilds gets the resolution but not the unit, so a cropped image saves with an "unknown" unit, even a JPEG that started out in inches.

@olivervogel

Copy link
Copy Markdown
Member

Thanks.

@olivervogel
olivervogel merged commit 9f52b24 into Intervention:develop Oct 5, 2026
8 checks passed
@olivervogel

Copy link
Copy Markdown
Member

Also fixed in 3.x branch. af6e5cf

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