Home > Backend Development > PHP Tutorial > How to convert JPEG images to Progressive JPEG in PHP_PHP Tutorial

How to convert JPEG images to Progressive JPEG in PHP_PHP Tutorial

WBOY
Release: 2016-07-13 10:26:15
Original
861 people have browsed it

There are two ways to save the JPEG file format. They are Baseline JPEG and Progressive JPEG.

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

Baseline JPEG

This type of JPEG file storage method scans from top to bottom and saves each line sequentially in the JPEG file. When this file is opened to display its contents, the data will be displayed line by line from top to bottom in the order in which it was stored. Until all the data has been read, the display of the entire picture is completed. If the file is large or the network download speed is slow, you will see the effect of the image being loaded line by line. This format of JPEG has no advantages. Therefore, it is generally recommended to use Progressive JPEG

Progressive JPEG

Unlike a Baseline scan, a Progressive JPEG file contains multiple scans, and these scans are stored sequentially in the JPEG file. During the process of opening the file, the blurred outline of the entire image will be displayed first. As the number of scans increases, the image becomes clearer and clearer. The main advantage of this format is that when the network is slow, you can see the outline of the image and know what the image being loaded is. You'll notice this technique when opening larger images on some websites.


If your Internet speed is the same as a snail, you should be able to see the effect. In fact, you will often see such effects on large websites such as qzone and Weibo.

PHP code can also convert it into Progressive jpg.

Copy code The code is as follows:


$im = imagecreatefromjpeg('file.jpg');
// Set interlacing If the interlacing bit flag is set and the image uses JPEG format, the image is created as a progressive JPEG. php manual
imageinterlace($im, 1);
imagejpeg($im, './outfile.jpg', 80);
imagedestroy($im);

?>

How can I tell whether a picture is in Progressive or Baseline format?

What I currently know is to use the identity command of ImageMagick software to view image resources

Copy code The code is as follows:

identify -verbose outfile.jpg

If you see an attribute for Interlace: JPEG is a Progressive image.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824749.htmlTechArticleThere 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 also the same. The only difference...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template