Jump to content

ImageSizerEngine ImageMagick CLI


horst
 Share

Recommended Posts

Do you have any (even short) info about the use-cases for those engines? Even a "Just an alternative. Mostly comparable to … in speed/performance/quality" would be helpful for anyone looking at those.

The first thing is, if you do not have the PHP-IMagick Extension available on a server, but are able to use the PHP exec() function for CLI operations. Than this and the NETPBM module are useful.

A quick and short comparision of the current state of all currently available modules is:

The core implemented PHP-Extension Imagick module lacks of support / detection of PNG 8bit transparency files and correct GIF support. Therefor it only processes JPEG and PNG24 images. GIF and PNG8 images are handed over to the GD engine.

If the ImageMagick-CLI can handle PNG8 bit images with transparency is not inspected before image processing. It may or may not, but with a recent, and fully functional ImageMagick installation it should be able to process all sort of image formats and subformats.

The NETPBM-CLI is currently work in progress. With Version 0.1.0, It supports JPEG only. But the other formats will be added as soon as I get time for it. There are no known downsides, I just need time to test and implement this.

The difference in quality is minimal between those three modules. They are all better than the GD lib. To choose one before the other ATM only depends on what is supported on a webserver, or may be on personal preferences.

When the modules are finished, so that they support all kind of formats and subformats, I will publsh a comparision table of the most useful aspects. Until then, it will be helpful if people can test one or more of them and report back how it goes. :)

  • Like 4
Link to comment
Share on other sites

If anyone interested, I installed Imagick on Win8.1 x64, IIS 8.5, PHP 7.0 x86. I took ImageMagick-6.9.3-6-Q16-x86-dll.exe from http://www.imagemagick.org/script/binary-releases.php#windows (I think the latest version would be ok too). Installed as usual, then I created env variable MAGICK_HOME, pointing to the C:\Program Files (x86)\ImageMagick-6.9.3-Q16\modules\coders. Checked that application is running. Then I downloaded PHP 7.0 Non Thread Safe (NTS) x86 of Imagick from http://pecl.php.net/package/imagick/3.4.0/windows, copied php_imagick.dll to the PHP's extension dir, in my case C:\Program Files (x86)\PHP\v7.0\ext, and added extension=php_imagick.dll to php.ini. Finally I had to restart the computer!

  • Like 3
Link to comment
Share on other sites

A first comparision in filesize & processing time among the first 4 engines with different qualities. Sharpening is set to soft here. Without sharpening, the Netpbm is much faster, but also more blurry than IMagick without sharpening. In regard of filesize and visual quality, Netpbm is better than IMagick. For the overall usage,   IMagick   as  PHP  extension is best  optimized for speed with a very good  visual quality. It is also faster than the IMagick-CLI engine in most cases.

screen_252.png

screen_253.png

screen_254.png

  • Like 4
Link to comment
Share on other sites

Hello. This looks good! 1 Problem I had was the fact that using the resize feature (via width(), height(), size()) on large images (started already at 1500xY -.-) would crash PW because of PHP memory issues. I read that PNG8 was still routed to the old GD. Will this be fixed so everything uses Imagick?

I really don't want a server to crash because of those bad memory issues. I prevented it by using following config:

$config->imageSizerOptions = [
    'upscaling' => false,
    'cropping' => false,
    'autoRotation' => true,
    'sharpening' => 'soft',
    'quality' => 85,
    'hidpiQuality' => 55,
    'defaultGamma' => -1,
];

Now after this great announcement of this great module, I commented out this thing and hope that all these memory issue go away.

Link to comment
Share on other sites

The GD now has complete memory checking before loading images into memory. It has had memory checking since some time already, but I have overseen two points in the code for this, what is now fixed with PW 3.0.10 too.

In regard of the IMagick bug with PNG8 with transparency, we only can and will change this if we are able to detect if IMagick can handle this correct. Otherwise it will be handed over to GD.

  • Like 4
Link to comment
Share on other sites

Yes, it prevent memory errors. The sizer is invoked in here in Pageimage. If it returns false, for what ever reason, but also for a memorcheck, the error is handled here in Pageimage starting from line 434. It writes a text line into the variation file: "This is intentionally invalid image data.\n"; And it logs that error. But it will not interrupt your page render / page load. It will proceed further content, just the image what would exceed your available memory isn't created, is missing. But this only belongs to the GD-lib, not to IMagick. IMagick can process image manipulation by lines or by chunks, what let it successful work with less memory too.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Our client's hoster (1&1) does not support ImageMagick natively, so I installed your CLI module and pointed to the directory where the executables were uploaded.

I checked with a short PHP script if the executable really are executable and everything worked fine so far.

The module's priority was set to 0.

However, the upload still crashes due to allowed memore issues and the error routes to ImageSizerEngineGD.php :-(

Any suggestions?

Link to comment
Share on other sites

I assume you are not able to upload and execute binarys on a shared host. I think it isn't allowed / is suppressed by the hoster. At least, that the GD-lib is invoked points to this. You also can force an image engine via API calls:

$image = $image->width(500, array("forceEngine" => "ImageMagickCLI"));

I think you need to ask the hoster where the IMagickCLI resides and take this path.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...