PHP convert JPEG images to progressive JPEG _php tutorial

Source: Internet
Author: User
There are two ways to save the JPEG file format. They are baseline JPEG and progressive JPEG.

Both formats have the same size and image data, and their extensions are the same, and the only difference is the way they are displayed.

Baseline JPEG

This type of JPEG file is stored as a top-to-bottom scan, keeping each row sequentially in a JPEG file. When you open this file to display its contents, the data is displayed in the order in which it was stored, from top to bottom, until all the data has been read, and the entire picture is displayed. If the file is large or the network download speed is slow, then you will see the image is loaded by a row of the effect, this format of JPEG has no merit, therefore, it is generally recommended to use progressive JPEG

Progressive JPEG

Unlike baseline scans, Progressive JPEG files contain multiple scans, which are stored in a JPEG file. In the process of opening a file, the blurred outline of the entire picture is displayed first, and as the number of scans increases, the picture becomes clearer. The main advantage of this format is that when the network is slow, you can see the outline of the picture knowing what the picture is about to be loaded. When you open larger pictures on some websites, you'll notice the technology.


If your internet speed and snail, you should be able to see the effect of, in fact, you in Qzone, Weibo and other large sites you will often see such effects.

PHP code can also be converted to progressive JPG.

Copy the Code code as follows:
<?php

$im = Imagecreatefromjpeg (' file.jpg ');
Set interlaced bit markers and the image is in JPEG format, the image is created as a progressive JPEG. PHP Manual
Imageinterlace ($im, 1);
Imagejpeg ($im, './outfile.jpg ', 80);
Imagedestroy ($im);

?>

How do I see whether the picture is progressive or baseline format?

I now know that using the ImageMagick software with the identity command to view the image resources
Copy the Code code as follows:
Identify-verbose outfile.jpg

If you see that there is a property for interlace:jpeg then it is the progressive picture.

http://www.bkjia.com/PHPjc/824749.html www.bkjia.com true http://www.bkjia.com/PHPjc/824749.html techarticle There are two ways to save the JPEG file format. They are baseline JPEG and progressive JPEG. Both formats have the same size and image data, their extensions are the same, the only difference ...

  • Related Article

    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.