Page 1 of 1

speed/timeout problem

Posted: 2020-01-27T02:35:31-07:00
by musicmaster
I have an (webshop) application that generates a lot of formats for a lot of images.

In pseudocode it looks something like:

for hundred images
{ take the image
generate 10 formats from it (50x50, 100x100, etc)

This used to work ok. However, recently I increasingly get complaints about timeouts.

I am wondering whether other people have similar experiences. And does anyone have an idea what could cause this? I have been thinking about PHP 7 and antimalware software. But it could also be something else.

Re: speed/timeout problem

Posted: 2020-01-27T10:37:41-07:00
by fmw42
What is your ImageMagick version and platform? What is your Imagick code for the loop?

Re: speed/timeout problem

Posted: 2020-01-27T16:20:02-07:00
by musicmaster
ImageMagick version 6.9.7-4 Q16 x86_64 on Linux

The first part of the code groups target formats with the same ratio together (in the test all formats had the same ratio). The second part does the actual work.

Code: Select all

 foreach($updatedformats AS $targetratio => $ratiogroup)
  { $targetratio = $targetratio/100;
    $mold = clone $src;
    if($targetratio == $sourceratio)
	{ $img = $src;
	  $newwidth = $width;
	  $newheight = $height;
	{ if($targetratio > $sourceratio)
	  { $newwidth = $height*$targetratio;
	    $newheight = $height;
		echo "";
		$offsetx = ($newwidth - $width)/2;
		$offsety = 0;
      else if($targetratio < $sourceratio)
	  { $newheight = $width/$targetratio;
	    $newwidth = $width;
		$offsetx = 0;
		$offsety = ($newheight - $height)/2;
	  $mold->extentImage($newwidth, $newheight, -$offsetx, -$offsety);

	foreach($ratiogroup AS $format)
    { $targetname = $format[0];
      if((!isset($_POST["removexist"])) && file_exists($imgbase."-".$targetname.'.jpg')) continue;
	  $targetwidth = $format[1];
	  $targetheight = $format[2];
	  $img = clone $mold;
	  $img->setInterlaceScheme(Imagick::INTERLACE_PLANE); /* alternatives: INTERLACE_NONE and INTERLACE_LINE */
	  $img->resizeImage($targetwidth,$targetheight,$filter, 1);
		  pecho("Error creating ".$imgbase."-".$targetname.'.jpg'); /* image, filename, quality */

Re: speed/timeout problem

Posted: 2020-01-27T20:16:40-07:00
by fmw42
It might be an issue with PHP Imagick. Also there could be issues with a shared server environment. Has the server been upgraded for ImageMagick? I have seen issues with Linux systems doing patches rather than proper updates of ImageMagick. Version is ancient by version, though I suspect the date of the version shows patches. Linux systems often only patch for security bugs and not for other issues. So that old a system with lots of odd patches may cause issues or there could be an issue with that version of ImageMagick, if it is that old. Has it always been this version? Do all your users use the same version of ImageMagick and Imagick?

Re: speed/timeout problem

Posted: 2020-01-28T09:15:05-07:00
by musicmaster
It usually depends on hosting providers. So I don't have much influence. On the tested site ImageMagick has the timestamp 20170114. Another is on a rather new server but I don't have the data for that.

What I find puzzling is that the software has been around for some time and that only recently this kind of reports are arriving.

Re: speed/timeout problem

Posted: 2020-01-28T10:01:41-07:00
by snibgo
Servers will often have timeouts set to prevent runaway processes consuming resources. They may have become active due to increased workload.

ImageMagick has a timeout mechanism. Check your policy.xml for a name="time" entry that isn't commented out.