0

I need a resizing image script in PHP, actually i need something like this: https://gist.github.com/nomisoft/11403298 That script works already perfect but the resized gif image isn't animated. I need to resize gif,jpg,jpeg and png images with highest quality, and that gif images are animated later & png images are transparent.

Sorry for bad English. Thank you.

1 Answers1

0

For animated GIF images, you may use https://github.com/glukash/glu-image

For JPG, JPEG, PNG, etc. http://image.intervention.io/api/make http://image.intervention.io/api/resize

$this->image_manager = new Intervention\Image\ImageManager(['driver' => 'imagick']);
$this->max_width = 800;

public function resizeImage($resource) {
$image = $this->image_manager->make($resource);

if ($image->width() <= $this->max_width) {
    return $resource;
}

return $image->resize($this->max_width, null, function ($constraint) {
        $constraint->aspectRatio();
        $constraint->upsize();
     })->save();
}
Alex
  • 513
  • 6
  • 14