ImageMagick on Ubuntu 14.04 No decode delegate

2019-09-01 20:05发布

问题:

In development enviroment works but not in production enviroment.

Production enviroment error:

$e->getMessage():
"no decode delegate for this image format 
'/tmp/sws5725c638311df5.24370631' @ error/svg.c/ReadSVGImage/2871"

Generate tmpname:

$tmpname = '/tmp/'.uniqid('sws', true);

Method:

public function load($filename)
  {
    try
    {
      $this->filename = $filename;
      $this->image = new Imagick($filename);
      return $this;
    }
    catch(ImagickException $e)
    {
      error_log($e->getMessage(), 3, "/tmp/log.log");
      OPException::raise(new OPInvalidImageException('Could not create jpeg with ImageMagick library'));
    }
  }

Delegates:

convert -list configure | grep DELEGATES
bzlib djvu fftw fontconfig freetype jbig jpeg jng jp2 lcms2 lqr lzma openexr pango png rsvg tiff x11 xml wmf zlib

Versions (dev and prod enviroments):

  • ImageMagick 6.7.7-10
  • Ubuntu 14.04
  • PHP 5.5.9-1ubuntu4.16

Any suggestions? Thanks for your attention.

回答1:

Temporary file

In reviewing the temporary file with the command vim I got the error message coming from the server in XML format and is why the library imagick treated it as svg file.

vim /tmp/sws5725c638311df5.24370631
<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>RequestTimeTooSkewed</Code>
    <Message>The difference between the request time and the current time is too large.</Message>
    <RequestTime>Sun, 01 May 2016 06:43:17 GMT</RequestTime>
    <ServerTime>2016-05-01T06:28:06Z</ServerTime>
    <MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds>
    <RequestId>382A337F3660C5A9</RequestId>
    <HostId>+2RI3xW5KBd64P13x4yaWly6VdZzn1okvMAYgKvbFYlGnLp87udxpSBCVx7iQNk7zgnkK/ckUXA=</HostId>
</Error>

Solution

Synchronize time operating system with the server time.

sudo service ntp stop
sudo ntpdate ntp.ubuntu.com
sudo service ntp start

Thanks for the comments.