[wp-trac] [WordPress Trac] #39262: Fall back to ImageMagick command line when the pecl imagic is not available on the server
WordPress Trac
noreply at wordpress.org
Wed Dec 14 09:07:55 UTC 2016
#39262: Fall back to ImageMagick command line when the pecl imagic is not available
on the server
--------------------------------+------------------------------
Reporter: Hristo Sg | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: External Libraries | Version: 4.7
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------------+------------------------------
Comment (by danielkanchev):
@dd32 thanks for the quick reply and the feedback.
Regarding the {{{update_size()}}} function, the width and height are not
variables in this case - this is how you call the identify binary in order
to get the dimensions:
{{{
/usr/bin/identify -format '%[width] %[height]' wp-content/uploads/2008/08
/noimage-600x600.png
600 600
}}}
That is why these two should not be escaped in the code.
Regarding the {{{shell_exec()}}} exception I do agree that the exception
handling code should be removed because {{{shell_exec()}}} does not return
an exception. However, in this case there is no need to actually catch an
exception at all.
I do believe that the focus of this enhancement request should be changed
and we need to discuss if the way ImageMagick is used in the WP core could
be improved.
Right now in the WP core ImageMagick is used just because it supports more
file types then GD. That is why in WP 4.7 we can now generate thumbnails
of PDF files. What actually happens is that when a PDF file is uploaded
the ImageMagick part of the code kicks in and it generates an object which
is loaded into memory and it stores a jpeg picture. After that GD is used
for manipulating this picture. In other words right now ImageMagick is
used only as a bridge so that PDF files could be displayed better in the
media library. Judging by the used code probably the class for ImageMagick
was copied over from the GD class and simply the functions that are used
were changed.
This is all good because ImageMagick gives us more flexibility in terms of
what could be done with images and other files (SVG, jpeg, png, pdf files,
etc.). However, right now the ImageMagick is used only to rotate, crop,
flip and resize images - all of these things are 100% supported by GD.
According to the performance tests that @Hristo Sg provided PHP is 2-3
times slower and uses 25% more memory when ImageMagick is loaded and used.
@dd32 as you mentioned in [ticket:6821] some hosts have all the needed
convert binaries but do not load the ImageMagick PHP PECL by default. On
such hosts it will be nice to offer support for PDF thumbnail generation
by using the binaries installed on the servers. Of course, the real
problem here is that it need's to be decided if the WP core should be
calling external commands. My personal opinion is that in this specific
case this is not a problem because the potential benefits are actually
more than the potential problems (which could be addressed with carefully
checking the used code):
- Better performance and memory usage of WP core
- Getting the new feature provided by WP 4.7 available to more people
- Better support for different environments. The user doesn't care of the
host has ImageMagick or not. The user just wants to see the thumbnail
generated and when ImageMagick is not available this will not happen.
Of course, this is just my opinion and other people from the community
should share their thoughts too and it would be great if we get more
people look into this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39262#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list