Image compression Solutions in PHP

Source: Internet
Author: User
Image compression in PHP
Now I want to compress the picture, for example, 640x480 image is now stored 600k I want to achieve compression into 640x 480 480k size of the picture This can be achieved? If this compresses the picture will not be damaged? How exactly do you want to do it? Urgent request?????
------to solve the idea----------------------
Reduce the pixels of the picture can be, there may be a problem is the image display effect and the original effect of color difference, there are defects.
------to solve the idea----------------------
You can use the GD library to generate thumbnails
------to solve the idea----------------------


Create a compressed package
$ZP = Gzopen ("1.gz", "WB");
Get data to be compressed
$string = file_get_contents ("com.html");
Maximize compressed data
$compress _string = gzcompress ($string, 9);
Writing compressed data to a compressed package
Gzwrite ($ZP, $compress _string, strlen ($compress _string));
Gzclose ($ZP);
?>



Picture compression is the same
------to solve the idea----------------------
References: http://blog.csdn.net/fdipzone/article/details/9316385
------to solve the idea----------------------
No!
640x 480 600k compression into 640x 480 480k, then remove the 120k will inevitably take away 1/5 of the picture data, resulting in picture quality decline
Unless your original image is Bitmap mode (Bmp,tiff), but
GIF is lossless compression, but only 256 colors (that is, color information is lost)
JPEG is lossy compression, apparently lossy two words already good to explain the problem
PNG is lossless compression, but if it is 256 color, it is obviously lost color information, and true color is equal to no compression

------to solve the idea----------------------
Try to reduce quality.
  • 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.