-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Use Imagick
class
#6754
base: v5/develop
Are you sure you want to change the base?
Use Imagick
class
#6754
Conversation
I don't have any idea about IM. I've run unit tests. Getting following error for all provider for
|
9047372
to
1e35132
Compare
1e35132
to
f9ee3e0
Compare
It's no help with the todos (sorry about that) but I was just thinking if we maybe could change the driver name to "imagick" for this and keep the old "im" driver? Then it wouldn't be a breaking change, but more important: the preferred name would be a lot better. |
ac33204
to
cc73571
Compare
I have some doubts about calling A short test for demonstration (not a solution): function doTest(string $file, string $ext) {
$image = new Imagick($file);
// get the ICC profile before stripping
$profiles = $image->getImageProfiles('icc', true);
// strip all metadata
$image->stripImage();
// re-apply the ICC profile
if ($icc = $profiles['icc'] ?? null) {
$image->profileImage('icc', $icc);
}
// save the image
file_put_contents('./output-wrong.' . $ext, $image);
// destroy the image
$image->destroy();
// re-open the output image and apply the ICC profile without calling stripImage
$image = new Imagick('./output-wrong.' . $ext);
if ($icc = $profiles['icc'] ?? null) {
$image->profileImage('icc', $icc);
}
// save the image
file_put_contents('./output-correct.' . $ext, $image);
// destroy the image
$image->destroy();
}
doTest('./png-adobe-rgb-gps.png', 'png');
doTest('./onigiri-adobe-rgb-gps.jpg', 'jpg'); Execute this in a folder with the The ICC profiles being present in:
I know the top comment in the PHP guide about Imho this looks like a bug in either Imagick or ImageMagick, because other file formats seem to work ootb. |
@rasteiner Thanks for sharing your insights, much appreciated. So to make our use case work (keep color profile but strip all other metadata) we would have to write the thumb basically twice - at least for PNG. |
I don't know if that can be a valid workaround, encoding the image twice surely isn't very optimal for a CMS... FYI this seems to be an issue in ImageMagick, not the imagick extension. The same behaviour issue also shows with the command line:
I've also posted this here: Anyway, if it's really a bug in imagemagick, I don't know if it can be fixed in a useful timespan since it's 2 steps upstream (Kirby -> Imagick -> Magick C API) which is then compiled who knows when by unknown hosting providers :/ So unless we find a better workaround (maybe the discussion in ImageMagick leads to something), maybe encoding it twice might actually be the only solution, in that case we should only do it when writing a png file with a profile: as converting a PNG with profile to JPG/WEBP seems to work fine. Saving to avif also seems to skip the profile, but I'm not sure if that's the same problem |
@rasteiner yea I guess we cannot expect a fix there but have to work around it ourselves. @afbora has pushed a working version that avoids writing to the filesystem but making use of getImageBloc/readImageBlob. |
Description
Help needed
: Cannot figure out why ICC profile isn't preservedImagick
objectSummary of changes
Imagick
class forimagick
darkroom driverim
(ImageMagick
class)Changelog
Enhancements
imagick
thumbs driver, using theImagick
class instead of command lineimagick
thumbs driver does not respectbin
optionDeprecated
im
driver option, useimagick
insteadReady?
For review team