PHP 10 different levels of compression optimized image (PNG)

Source: Internet
Author: User
Tags php write

Today found a PHP write compressed picture program, can be divided into 10 levels (0-9) to compress, 0 grade when the compression ratio is not very large, the picture will not be distorted; As the compression level increases, the picture will become more and more unclear, usually compressed after the image size can be reduced to the original 50%, compression ratio is quite large.

The following is a PHP compressed picture program

<?php
Header ("Content-type:image/png");/* Tell IE your program is a picture */
$image = @imagecreatefrompng ("Banner.png");
Imagepng ($image, null,0); /* Compression level 0-9, 9 min after compression, 1 Max */
Imagedestroy ($image);
?>

The original volume is 125k, and now I want to see what the results will be at different levels of compression. The following is a Test record.

Imagepng ($img, null,0); --Size = 225K
Imagepng ($img, null,1); --Size = 85.9K
Imagepng ($img, null,2); --Size = 83.7K
Imagepng ($img, null,3); --Size = 80.9K
Imagepng ($img, null,4); --Size = 74.6K
Imagepng ($img, null,5); --Size = 73.8K
Imagepng ($img, null,6); --Size = 73K
Imagepng ($img, null,7); --Size = 72.4K
Imagepng ($img, null,8); --Size = 71K
Imagepng ($img, null,9); --Size = 70.6K

PHP 10 different levels of compression optimized image (PNG)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.