Is it possible to save an image with the Imagine PHP library without compressing its size?

Asked

Viewed 95 times

0

I am using the Imagine PHP library to upload and process images and when I will upload images of the type . GIF he does this normally keeping the dimensions of the original image but he does the compression of the size of the same, with this the image . GIF loses its 'animation' becoming like a normal image. I reworked the documentation of them but I couldn’t get anything that could help me. At the time of saving the image I tried to pass some parameters listed in the documentation but did not succeed:

$image->save('cats.gif', Array('quality' => 100, 'animated' => TRUE, 'flatten' => FALSE));

inserir a descrição da imagem aqui

  • 1

    From what I saw in the documentation, it is necessary to iterate through the image, as the library will iterate through each layer (frames). on the link you posted yourself they resize with a foreach ($image->layers() as $frame) {
 $frame->resize(new Box(100, 100));
}


  • @Renatotavares tried this but did not roll... what happens is that after he saves the image is made to compress the size of the same. I’m attaching an image to the question so you can see what I’m talking about

  • 1

    I never used this library but, reading the documentation link superficially, there is an example that shows the method coalesce(). Try calling this method before calling the method save(). Example: $image->layers()->coalesce();.

  • @Danielomine I tried to use it but it didn’t work either

  • 1

    You want to compress the images keeping the highest level of quality possible and keep the dimensions unchanged, right?

  • 1

    And obviously, for animated gif images, keep all layers.

  • @Danielomine in real I want her to keep the original size and dimensions. The original dimensions I can maintain but size not. As it is being compressed in size GIF crashes

  • 2

    I suspected you wanted this, but I avoided comment. What I would comment on is, if you don’t need to compress or tweak the dimensions, then you don’t need any library. Just upload normally rescuing from global $_FILES. Then I’d use the move_uploaded_file or copy().

  • 1

    Really @Danielomine was the only alternative I had left. I used Copy and it worked. Thanks!

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.