9952 explained code solutions for 126 technologies

php-gdHow to compress GD image


$im = imagecreatefrompng('/var/www/examples/heroine.png');
imagejpeg($im, '/tmp/image.jpg', 88);ctrl + c

image resource of original image to compress


creates GD image object from given PNG image


saves $im gd object to the specified 'jpeg' file with a given level of compression


quality (or compression) level, use lower values for better compression, up to 100 (best quality, worst compression)