Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animated gif issues PHP 5.3, Ubuntu 12.04, Imagick 3.1 #20

Closed
casperwilkes opened this issue Feb 14, 2014 · 18 comments
Closed

Animated gif issues PHP 5.3, Ubuntu 12.04, Imagick 3.1 #20

casperwilkes opened this issue Feb 14, 2014 · 18 comments

Comments

@casperwilkes
Copy link

@casperwilkes casperwilkes commented Feb 14, 2014

Hello, I've been having problem with animated gifs on Ubuntu. I have Imagemagick and Imagick installed on both Windows 7 and Ubuntu 12.04. In Windows, everything works as expected, but in Ubuntu, it seems that only the first image of a coalesced gif is being saved. A problem with writeImages() maybe?

*Ubuntu:
-Distributor ID: Ubuntu
-Description: Ubuntu 12.04.4 LTS
-Release: 12.04
-Codename: precise

*PHP:
-PHP Version: 5.3.10-1ubuntu3.9
-PHP API: 20090626
-PHP Extension Build: API20090626,NTS

*Imagick:
-imagick module version: 3.1.0RC1

*ImageMagick:
-Version: ImageMagick 6.8.7-0 2013-10-11 Q16 http://www.imagemagick.org
-Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
-Features: DPC OpenMP
-Delegates: zlib

Here is the function that was giving me problems. Again, it works in Windows, but not Linux.

<?php
function resize($file_src) {
    try {
        set_time_limit(180);
        $image = new Imagick($file_src);
        $destination = dirname(__FILE__) . DS . 'images' . DS . basename($file_src);
        $images = $image->coalesceImages();
        $size_w = 250;
        $size_h = 250;

        foreach ($images as $frame) {
            $frame->thumbnailImage($size_w, $size_h);
        }

        $images->writeImages($destination, true);
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
?>

This is the command line version of the same function:

<?php
function resize_cmd($file_src) {
    set_time_limit(180);
    $destination = dirname(__FILE__) . DS . 'images' . DS . basename($file_src);
    $w = 250;
    $h = 250;

    exec("convert {$file_src} -coalesce -resize {$h}x{$w} {$destination}", $output);
    if (!empty($output)) {
        echo $output;
    }
}
?>

The second function "resize_cmd()" works without a problem.

@F21

This comment has been minimized.

Copy link

@F21 F21 commented Feb 18, 2014

Your code works fine for me with the latest master of imagick on Ubuntu 13.10 64-bit.

My ImageMagick is 6.8.8-7 Q8 x86_64 2014-02-18 which was compiled from source.

Trying using a newer version of imagick and ImageMagick.

@casperwilkes

This comment has been minimized.

Copy link
Author

@casperwilkes casperwilkes commented Feb 20, 2014

Thank you. I'm re-installing my ImageMagick, and I'm going to re-install Imagick tonight. I'll let you know what I find.

@casperwilkes

This comment has been minimized.

Copy link
Author

@casperwilkes casperwilkes commented Mar 1, 2014

I updated the Imagick to imagick 3.2.0RC1. I'm still receiving the same errors. I'm using the newest version of ImageMagick.

@F21

This comment has been minimized.

Copy link

@F21 F21 commented Mar 1, 2014

Here's my imagick in phpinfo():

imagick module version  @PACKAGE_VERSION@
imagick classes     Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version     ImageMagick 6.8.8-7 Q8 x86_64 2014-02-18 http://www.imagemagick.org
ImageMagick copyright   Copyright (C) 1999-2014 ImageMagick Studio LLC
ImageMagick release date    2014-02-18
ImageMagick number of supported formats:    201
ImageMagick supported formats   3FR, A, AAI, AI, ART, ARW, AVI, AVS, B, BGR, BGRA, BMP, BMP2, BMP3, BRF, C, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DNG, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, ERF, FAX, FITS, FRACTAL, FTS, G, G3, GIF, GIF87, GRADIENT, GRAY, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, INFO, INLINE, IPL, ISOBRL, JNG, JNX, JPEG, JPG, JSON, K, K25, KDC, LABEL, M, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, O, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PWP, R, RADIAL-GRADIENT, RAF, RAS, RGB, RGBA, RGBO, RGF, RLA, RLE, RW2, SCR, SCT, SFW, SGI, SHTML, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TILE, TIM, TTC, TTF, TXT, UBRL, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, Y, YCbCr, YCbCrA, YUV 

The only things I can think of left to try are the following:

  • Compile imagemagick in Q8.
  • Try to set up a newer version of PHP.
@casperwilkes casperwilkes reopened this Mar 1, 2014
@casperwilkes

This comment has been minimized.

Copy link
Author

@casperwilkes casperwilkes commented Mar 1, 2014

My imagick and ImageMagick are almost identical to yours. I'm afraid that you're right, I'm going to have to update my php from 5.3 to 5.4. I was trying to avoid the hassle at the moment, but it's something I have to get around to doing eventually anyway. Thank you for your help.

@F21

This comment has been minimized.

Copy link

@F21 F21 commented Mar 1, 2014

My PHP is 5.5.9. If you have no issues with using PPAs, I recommend this one: https://launchpad.net/~ondrej/+archive/php5

@tmli3b3rm4n

This comment has been minimized.

Copy link

@tmli3b3rm4n tmli3b3rm4n commented Feb 10, 2015

I still can't get writeImages() to work properly on : ImageMagick 6.7.8-9 2014-05-12 Q16. It was working in production and now it's shot to hell. Still working to find issue.

@Danack

This comment has been minimized.

Copy link
Collaborator

@Danack Danack commented Feb 10, 2015

@tmli3b3rm4n Can you list what version of giflib you're using? or the appropriate library if not giflib.

Also, please can you try converting the image to an animated gif with the ImageMagick convert command.

I recently added an animated gif test to the Imagick test suites and it works fine on my machine, but fails on Travis - so I suspect it is a library issue, but haven't been able to investigate it yet.

@Danack Danack reopened this Feb 10, 2015
@tmli3b3rm4n

This comment has been minimized.

Copy link

@tmli3b3rm4n tmli3b3rm4n commented Feb 10, 2015

This is exactly what's happening here. It works locally but fails on qa servers. Let me get you the information you're asked for.

@tmli3b3rm4n

This comment has been minimized.

Copy link

@tmli3b3rm4n tmli3b3rm4n commented Feb 10, 2015

Name : giflib
Arch : x86_64
Version : 4.1.6
Release : 3.1.6.amzn1

@Danack

This comment has been minimized.

Copy link
Collaborator

@Danack Danack commented Feb 10, 2015

Do you have a vagrant script box that you can share to recreate the issue? If not I guess I'll try with the puphet one which apparently is "Ubuntu Precise 12.04 LTS x64"

For reference, I'm on Centos 6.4 and the versions of giflib I'm apparently using are:
giflib.x86_64 4.1.6-3.1.el6 @base
giflib-devel.x86_64 4.1.6-3.1.el6 @base

And everything works for me :^)

@Danack

This comment has been minimized.

Copy link
Collaborator

@Danack Danack commented Feb 11, 2015

Just to add, apparently Travis is pulling in ImageMagick from here http://packages.ubuntu.com/precise/imagemagick - so I ought to test with that also.

@tmli3b3rm4n

This comment has been minimized.

Copy link

@tmli3b3rm4n tmli3b3rm4n commented Feb 11, 2015

I ended just stripping all the writeImages() out using Gaufrette and writing straight to s3 with getImagesBlob(). I don't know what happened to writeImages() but writing was failing on gif's when saving locally to a live server. Would always work with localhost. My vagrant had an older version.

@Danack

This comment has been minimized.

Copy link
Collaborator

@Danack Danack commented Feb 12, 2015

Actually @tmli3b3rm4n I can't reproduce this on Ubuntu, and it's not an issue on Travis - I thought it was but it was just that the image generation function was failing.

Can you check to see if ImageMagick was compiled with OpenMP enabled? Running identify -version would probably be the easiest way to do that. If so that may be the issue so please try either recompiling ImageMagick or set:

Imagick::setResourceLimit(\Imagick::RESOURCETYPE_THREAD, 1);

To disable OpenMP and let me know if that fixes the issue?

@Danack

This comment has been minimized.

Copy link
Collaborator

@Danack Danack commented Feb 13, 2015

This is really very similar to https://bugs.php.net/bug.php?id=61879

Please can you confirm that you're using at least version 3.1.0RC2 ?

@tmli3b3rm4n

This comment has been minimized.

Copy link

@tmli3b3rm4n tmli3b3rm4n commented Feb 13, 2015

I'll check and get back to you.

@Danack

This comment has been minimized.

Copy link
Collaborator

@Danack Danack commented Feb 18, 2015

I'm going to close this again. There was a known issue that has been fixed. If you find any evidence it's a separate issue, please feel free to add more info.

@Danack Danack closed this Feb 18, 2015
@tmli3b3rm4n

This comment has been minimized.

Copy link

@tmli3b3rm4n tmli3b3rm4n commented Feb 23, 2015

Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.