
Here is the example: // Create new Imagick class The only difference is that cropImage function is used instead of resizeImage function. $imagick->writeImages($image_path, true) Cropping GIF Animationsįor cropping an GIF animation, the same principle is used as for resizing them. This would overwrite the original image $imagick = $imagick->deconstructImages() $imagick->resizeImage(580, 0, Imagick::FILTER_BOX, 1) If one of the params is set to zero, image will keep the aspect ratio

First parameter is resized image width and second is resized image height $imagick = new Imagick($image_path) // $image_path is the path to the image location In PHP, it is done like this: // Create new Imagick class However, since each animation consists of multiple images (frames), we need to loop through all of them, resize them one by one and merge them into one image again. To resize a GIF animation, we will use resizeImage function. Restart Apache: service apache2 reload Resizing GIF Animations
#Gif resize install
Install PHP extension: sudo apt-get install php5-imagick Install ImageMagick: sudo apt-get install imagemagick First, install the required dependencies: sudo apt-get install php5 php5-common gcc Restart Apache web server: service httpd restart Install PHP extension: pecl install imagick Install ImageMagick: yum install -y ImageMagick ImageMagick-devel


On CentOS operating systems, use the yum package manager.įirst, install the required dependencies: yum install -y gcc php-devel php-pear However, you can install it by running a couple of Linux commands. On most servers, ImageMagick is not installed by default. In PHP, this can be achieved by using the ImageMagick extension. However, it is possible to resize and crop image while keeping the animation intact. When resizing and cropping images, many popular PHP packages break the GIF animation and save it as a static image.
