Pages use progressive JPEG to improve user experience

Source: Internet
Author: User
Tags imagejpeg
This article mainly introduces the materials on pages that use progressive JPEG to improve user experience, for more information about JPEG files, see Baseline JPEG (standard) and Progressive JPEG (Progressive ). The two formats have the same size and image data, and their extensions are the same. The only difference is that they are displayed differently.

Baseline JPEG

This type of JPEG file is stored in the JPEG file by scanning from top to bottom. When you open this file to display its content, the data will be displayed from top to bottom lines in the storage order until all the data is read, the entire image is displayed. If the file size is large or the network download speed is slow, the image is loaded by one row. this format of JPEG has no advantages. Therefore, Progressive JPEG is generally recommended.

Progressive JPEG

Unlike Baseline, the Progressive JPEG file contains multiple scans. these scans are stored in JPEG files. When opening a file, the blurred outline of the entire image is 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 picture outline to know what the picture is being loaded. When some websites open large images, you will notice this technology.

The advantage of progressive images is that users can see the outline of the final image without downloading the image, which can improve the user experience to a certain extent. (The standard type is recommended for waterfall websites)

In addition, the size of the progressive image is not much different from that of the basic image, and sometimes it may be smaller than the basic image. The disadvantage of progressive images is to eat the user's CPU and memory, but for the current computer, the calculation of this image is not much.

Now let's talk about how to save or convert an image to Progressive JPEG.

1. PhotoShop

In photoshop, there is "Storage is the format used by the web". when it is turned on, "continuous" is the progressive JPEG.

Detailed tutorial reference http://www.bitsCN.com/photoshop/182198.html

2. Linux

Check whether it is progressive jpeg: identify-verbose filename.jpg | grep Interlace (if None is output, it is not progressive jpeg; if Plane is output, it is progressive jpeg .)

Convert basic jpeg to progressive jpeg:> convert infile.jpg-intermo-plane outfile.jpg

3. PHP

Using the imageinterlace and imagejpeg functions, we can easily solve the conversion problem.

<?php
$im = imagecreatefromjpeg('pic.jpg');
imageinterlace($im, 1);
imagejpeg($im, './php_interlaced.jpg', 100);
imagedestroy($im);
?>

4. Python

import PIL
from exceptions import IOError
img = PIL.Image.open("c:\\users\\biaodianfu\\pictures\\in.jpg")
destination = "c:\\users\\biaodianfu\\pictures\\test.jpeg"
try:
img.save(destination, "JPEG", quality=80, optimize=True, progressive=True)
except IOError:
PIL.ImageFile.MAXBLOCK = img.size[0] * img.size[1]
img.save(destination, "JPEG", quality=80, optimize=True, progressive=True)

5. pivotran

Jpegtran-copy none-progressive

6. C #

using (Image source = Image.FromFile(@"D:\temp\test2.jpg")) { 
ImageCodecInfo codec = ImageCodecInfo.GetImageEncoders().First(c => c.MimeType == "image/jpeg");
EncoderParameters parameters = new EncoderParameters(3);
parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
parameters.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.ScanMethod, (int)EncoderValue.ScanMethodInterlaced);
parameters.Param[2] = new EncoderParameter(System.Drawing.Imaging.Encoder.RenderMethod, (int)EncoderValue.RenderProgressive);
source.Save(@"D:\temp\saved.jpg", codec, parameters);
}

The above is all the content that uses progressive JPEG images to improve the page experience. it is very simple and practical. we recommend it to our friends here.

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.