WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 4 months ago

#54116 new enhancement

Check ImageMagick version 6/7

Reported by: JavierCasares Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Site Health Keywords:
Focuses: performance Cc:

Description

From #52654

Context

WordPress uses ImageMagick to create, edit, compose, or convert digital images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, WebP, HEIC, SVG, PDF, DPX, EXR and TIFF. ImageMagick can resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

ImageMagick recommendation

But, we recommend using ImageMagick, although the last WordPress versions supports WebP and ImageMagick 6 does not support it.

Moreover, a lot of OS have the version 6 by default because version 7 needs to be compiled manually (at least, at this moment).

Site Health

Should the Site Heath check the version?

Yes. because for some functionalities, there are some things different.

How we can check it?

https://www.php.net/manual/en/imagick.getversion.php

The array returns something like:

Array
(
    [versionNumber] => 1632
    [versionString] => ImageMagick 6.6.0-4 2010-11-16 Q16 http://www.imagemagick.org
)

But, we should get the version with this example:

<?php
$v = Imagick::getVersion();
preg_match('/ImageMagick ([0-9]+\.[0-9]+\.[0-9]+)/', $v['versionString'], $v);
if(version_compare($v[1],'6.2.8')<=0){
   print "Your ImageMagick Version {$v[1]} is '6.2.8' or older, please upgrade!";
}

Version 6 vs. version 7

And, here is the comparison between version 6 and version 7:

https://www.imagemagick.org/script/porting.php

Version 7 Change Summary

Changes from ImageMagick version 6 to version 7 are summarized here:
High Dynamic Range Imaging

  • ImageMagick version 7 enables HDRI by default. Expect more accurate image processing results with higher memory requirements and possible slower processing times. You can disable this feature for resource constrained system such as a cell phone with a slight loss of accuracy for certain algorithms (e.g. resizing).

Pixels

  • Pixels are no longer addressed with PixelPacket structure members (e.g. red, green, blue, opacity) but as an array of channels (e.g. pixel[PixelRedChannel]).
  • Use convenience macros to access pixel channels (e.g. GetPixelRed(), SetPixelRed()).
  • The black channel for the CMYK colorspace is no longer stored in the index channel, previously accessed with GetAuthenticIndexQueue() and GetCacheViewAuthenticIndexQueue(). Instead it is now a pixel channel and accessed with the convenience pixel macros GetPixelBlack() and SetPixelBlack().
  • The index channel for colormapped images is no longer stored in the index channel, previously accessed with GetAuthenticIndexQueue() and GetCacheViewAuthenticIndexQueue(). Instead it is now a pixel channel and accessed with the convenience pixel macros GetPixelIndex() and SetPixelIndex().
  • Use GetPixelChannels() to advance to the next set of pixel channels.
  • Use the metacontent channel to associate metacontent with each pixel.
  • All color packet structures, PixelPacket, LongPacket, and DoublePacket, are consolidated to a single color structure, PixelInfo.

Alpha

  • We support alpha rather than opacity (0 transparent; QuantumRange opaque).
  • Use GetPixelAlpha() or SetPixelAlpha() to get or set the alpha pixel channel value.

Grayscale

  • Grayscale images consume one pixel channel in ImageMagick version 7. To process RGB, set the colorspace to RGB (e.g. -colorspace sRGB).

Masks

  • ImageMagick version 6 only supports read mask in limited circumstances. Version 7 supports both a read and write mask. The read mask is honored by most image-processing algorithms.

MagickCore API

  • Almost all image processing algorithms are now channel aware.
  • MagickCore, version 7, adds an ExceptionInfo argument to those methods that lacked it in version 6, e.g. NegateImage(image,MagickTrue,exception);
  • All method channel analogs have been removed (e.g. BlurImageChannel()), they are no longer necessary, use pixel traits instead.
  • Public and private API calls are now declared with the GCC visibility attribute. The MagickCore and MagickWand dynamic libraries now only export public struct and function declarations.
  • The InterpolatePixelMethod enum is now PixelInterpolateMethod.
  • To account for variable pixel channels, images may now return a different signature.

Deprecated Methods

  • All ImageMagick version 6 MagickCore and MagickWand deprecated methods are removed and no longer available in ImageMagick version 7.
  • All MagickCore channel method analogs are removed (e.g. NegateImageChannels()). For version 7, use pixel traits instead.
  • The FilterImage() method has been removed. Use ConvolveImage() instead.

Change History (4)

#1 in reply to: ↑ description @desrosj
4 months ago

Replying to JavierCasares:

But, we recommend using ImageMagick, although the last WordPress versions supports WebP and ImageMagick 6 does not support it.

I'm not sure that this is accurate. I've seen several different setups that have ImageMagick v6 and WebP support included. This includes the local Docker environment in trunk used for contributing. The PHP 7.4 container, for example, has ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 and WebP support.

As far as I am aware, as long as the libwebp package is present when compiling ImageMagick, both version 6 & 7 will be compiled with WebP support.

In general, I support encouraging users to always run the latest versions of software on their servers. But, ImageMagick is often something they have no control over, especially in shared environments. This could lead to frustration because there is no clear path for updating other than reaching out to their host.

The changelog above is also pretty advanced. I worry about exposing any of the items listed above as reasons to update ImageMagick.

#2 @JavierCasares
4 months ago

Yes, I didn't mean that IMGK 6 does not support WebP, I meant that does not have full support because of the Alpha thingy (it happens with some other new formats).

What I mean informing about the differences about IMGK 6 / 7 is for some reasons:

  • Only informative (IMGK 6 has support for another 4-5 years, but it will end)
  • IMGK 7 has better performance than IMGK 7 (also, it's been around 2017)

I'll check with the Hosting team about in the next meeting.

This ticket was mentioned in Slack in #hosting-community by javier. View the logs.


4 months ago

This ticket was mentioned in Slack in #hosting-community by jadonn. View the logs.


4 months ago

Note: See TracTickets for help on using tickets.