GIF compression quality in PHP?

How to compress GIF image file in PHP5?

I know it is possible to do this with JPG, like this imagejpeg ($ resource, $ filename, $ quality) according to http://us.php.net/manual/en/function.imagejpeg.php

+3
source share
3 answers

JPG - lossy compression. This means that you can use the quality parameter to adjust the size to quality ratio.

GIF is lossless compression, you cannot improve compression by adjusting quality.

To create a GIF image, use imagegif (...)
http://us.php.net/manual/en/function.imagegif.php

+6
source

, , , - . PHP:

$img = imagecreatefromstring(file_get_contents($_FILES["my_field"]["tmp_name"]));
imagetruecolortopalette($img, false, 16);  //  compress to 16 colors in gif palette (change 16 to anything between 1-256)
imagegif($img, $destination_filename);  //  $destination_filename is the location on your server where you want to save the compressed gif file

: JPG/GIF- PNG PHP?

, gifs , . Gifs, , . , , gif-loss - jpegs, . , , , , . - , "", () .

http://searchcio-midmarket.techtarget.com/definition/lossless-and-lossy-compression : " (GIF) - , , ". , , " - ". , , , , 100% . - , gif , gifs " ". , jpeg 100% , , .

: gif (, ); jpegs 50% -70% (, ); gif jpegs 63% -85% (, ).

LZW ( Tiff ) , , , , , . , , . , "" , .

+5

GIF-, imagecreatefromgif: http://www.php.net/manual/en/function.imagecreatefromgif.php

imagejpeg JPEG. .

0

Source: https://habr.com/ru/post/1764680/


All Articles