Home Web Front-end CSS Tutorial My opinion on the selection of image formats in html pages_Experience exchange

My opinion on the selection of image formats in html pages_Experience exchange

May 16, 2016 pm 12:05 PM
page

A student asked me today: The GIF format is used in the page and the distortion is too great. What should I do? This problem is relatively simple, just use JPG. There are three image formats we commonly use on pages, GIF, JPG, and PNG. So how do we choose to use these three formats? Let’s talk about some of my opinions on the use of these three formats based on my experience.

Let’s first take a look at the more formal explanations of several formats (note: the following content is from Baidu Knows):

GIF means Graphics Interchange format, GIF image The extension is gif. All graphic browsers now support the GIF format, and some graphic browsers only recognize the GIF format. GIF is an indexed color format. When the number of colors is small, the file generated is extremely small. Its main advantages are:

The GIF format supports background transparency. If the background color of a GIF image is set to transparent, it will be combined with the browser background to generate a non-rectangular image.
The GIF format supports animation. Before the emergence of Flash animation, GIF animation could be said to be the only form of animation on web pages. The GIF format can combine single-frame images and then play each frame in turn to become an animation. Although not all graphics browsers support GIF animation, the latest graphics browsers already support GIF animation.
The GIF format supports graphic progression. Progressive means that the picture gradually appears on the screen. Progressive pictures will appear on the screen faster than non-progressive pictures, allowing visitors to know the outline of the picture faster.
The GIF format supports lossless compression. Lossless compression is an effective method of compressing images without losing image details. Since the GIF format uses lossless compression, it is more suitable for lines, icons and drawings.
The shortcomings of the GIF format are also quite obvious. Indexed color is a relic of history. Old games under DOS almost without exception use indexed color. This format should have been eliminated long ago. However, due to bandwidth limitations, GIF became popular from the DOS era to the Internet era. The biggest disadvantage of the indexed color format GIF is that it only has 256 colors, which is obviously not enough for photo-quality images.

JPEG stands for Joint Photograhic Experts Group (Joint Photographic Experts Group). This format is often written as JPG, and the extension of JPG images is jpg.

The main advantage of JPG is that it can support millions of colors, so it can be used to express photos. In addition, because JPG images use a more efficient lossy compression algorithm, the file length is smaller and the download time is shorter. Lossy compression gives up some detail in an image to reduce file size. Its compression ratio is quite high. Using a special JPG compression tool, the compression ratio can reach 180:1, and the image quality will not be too damaged from a browsing perspective, which greatly facilitates network transmission and disk exchange files. JPG is better for photos than GIF because the loss of some detail in the photo is not as obvious as with line art. In addition, JPG has a greater compression ratio for photos, and the final quality is better.

But in the long run, with the continuous improvement of bandwidth and the development of storage media, JPG should also be an eliminated image format, because lossy compression will cause unrecoverable damage to the image. loss. Therefore, compressed JPG images are generally not suitable for printing, and it is best not to use JPG when backing up important images. Also, JPG is not as flexible as GIF images. It does not support graphic gradients, background transparency, or animation.

PNG is an image file storage format that was developed in the mid-1990s. Its purpose is to replace the GIF and TIFF file formats while adding some features that the GIF file format does not have. The Portable Network Graphic Format (PNG) name comes from the unofficial "PNG's Not GIF". It is a bitmap file storage format, pronounced "ping". When PNG is used to store grayscale images, the depth of the grayscale image can be up to 16 bits. When storing color images, the depth of the color image can be up to 48 bits, and it can also store up to 16 bits of alpha channel data. PNG uses a lossless data compression algorithm derived from LZ77.

The PNG file format retains the following features of the GIF file format:

Color images can support 256 colors using a color lookup table, or palette.
Streaming read/write performance (streamability): The image file format allows continuous reading and writing of image data.
This feature is very suitable for generating and displaying images during communication.
Progressive display: This feature allows the image file to be displayed on the terminal while transmitting the image file on the communication link. After the entire outline is displayed, the details of the image are gradually displayed, that is, using the Display the image at a low resolution and then gradually increase its resolution.
Transparency (transparency): This feature allows certain parts of the image not to be displayed, and is used to create some distinctive images.
Auxiliary information (ancillary information): This feature can be used to store some text annotation information in the image file.
Independent of the computer software and hardware environment.
Use lossless compression.
The PNG file format will add the following features that the GIF file format does not have:

A true color image with 48 bits per pixel.
Each pixel is a 16-bit grayscale image.
Alpha channels can be added to grayscale images and true color images.
Add gamma information of the image.
Detect corrupted files using cyclic redundancy code (CRC).
Successive approximation display method that speeds up image display.
Standard read/write toolkit.
Multiple images can be stored in one file.
File structure

These three formats have their own advantages and disadvantages, among which PNG has many advantages. Although its popularity is still very general, its special advantages have made us very interested in it. At least I like this format now. Of course, for those who create the page, the total size of the page is competitiveness. So we still have to pay attention to the mixed use of these three formats. So when to use GIF, when to use PNG, and when to use JPG? Let’s analyze them one by one below.

In actual work, I found that general solid-color graphics, such as some small icons and tiled backgrounds, have relatively few colors. Although the GIF format only has 256 colors, it is necessary to deal with this type of pictures. It's very appropriate. Of course, we do not rule out the richness of the colors of some special small icons, but I believe that as small icons, a slight loss of color will not affect the overall visual effect. Therefore, the applicable scope of GIF is: small icons, tiled backgrounds and other colors Relatively few small images.

How to choose such a large picture? First, let’s learn about JPG. Our friends who use Photoshop all know that when exporting the picture at the end, there will be a place for us to choose the picture quality of this JPG picture. 100 % means no compression. When we exported the same picture and compared it with different quality pictures, we found that the low-quality one was obviously much dirtier than the high-quality one, so the photo looked very bad. Of course, we also found that this The situation is even more prominent in the pictures with larger color blocks. So like the sky, the portrait. Unsightly dark spots will appear especially on the face of portraits. Of course, if you don’t have strict requirements on photo quality, you can use JPG and lower the quality. But it does not apply to backgrounds and small icons.

My opinion on the selection of image formats in html pages_Experience exchange

My opinion on the selection of image formats in html pages_Experience exchange

My opinion on the selection of image formats in html pages_Experience exchange

I personally think PNG is a choice between GIF and high-quality JPG. If it is a simple small icon, PNG will be a little larger than GIF, but the quality is almost the same. If it is an ordinary picture, then PNG is still a little smaller than high-quality JPG, but PNG still has some color loss. However, it is basically not visible if the picture is not enlarged. Basically, we don’t create pages just for people to magnify and criticize. So PNG is an option in the middle. Of course, PNG also has a great advantage, that is, transparency, although IE6 did not support this feature before. GIF also has transparency, but GIF only supports absolute transparency and does not support translucency, so there is often a circle of white dots on the edge of the GIF image. PNG does not have these problems. With the development of the times, when IE6 becomes history, I think we will be able to see the true power of PNG.

Of course, there is a special situation that may be very special, that is, where the background image and the foreground image meet. This kind of place requires a consistent color structure to produce good visual effects. So at this time, be careful not to mix different formats as much as possible.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to copy a page in Word How to copy a page in Word Feb 20, 2024 am 10:09 AM

Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

How to quickly refresh a web page? How to quickly refresh a web page? Feb 18, 2024 pm 01:14 PM

Page refresh is very common in our daily network use. When we visit a web page, we sometimes encounter some problems, such as the web page not loading or displaying abnormally, etc. At this time, we usually choose to refresh the page to solve the problem, so how to refresh the page quickly? Let’s discuss the shortcut keys for page refresh. The page refresh shortcut key is a method to quickly refresh the current web page through keyboard operations. In different operating systems and browsers, the shortcut keys for page refresh may be different. Below we use the common W

How to customize and edit standby mode on iPhone: What's new in iOS 17 How to customize and edit standby mode on iPhone: What's new in iOS 17 Sep 21, 2023 pm 04:01 PM

Standby is a new feature in the iOS 17 update that provides a new and enhanced way to access information when your phone is idle quickly. With StandBy, you can conveniently check the time, view upcoming events, browse your calendar, get weather updates for your location, and more. Once activated, the iPhone will intuitively enter standby mode when set to landscape while charging. This feature is perfect for wireless charging points like your bedside table, or when you're away from your iPhone charging during daily tasks. It allows you to swipe through various widgets displayed in standby to access different sets of information from various applications. However, you may want to modify these widgets or even delete some based on your preferences and the information you need frequently. So let's dive into

How to deal with the problem that Laravel page cannot display CSS correctly How to deal with the problem that Laravel page cannot display CSS correctly Mar 10, 2024 am 11:33 AM

"Methods to handle Laravel pages that cannot display CSS correctly, need specific code examples" When using the Laravel framework to develop web applications, sometimes you will encounter the problem that the page cannot display CSS styles correctly, which may cause the page to render abnormal styles. Affect user experience. This article will introduce some methods to deal with the failure of Laravel pages to display CSS correctly, and provide specific code examples to help developers solve this common problem. 1. Check the file path. First check the path of the CSS file.

How to Rearrange, Disable, and Delete iPhone Home Screen Pages How to Rearrange, Disable, and Delete iPhone Home Screen Pages Nov 29, 2023 am 08:22 AM

In iOS, Apple allows you to disable individual home screen pages on your iPhone. It's also possible to rearrange the order of home screen pages and delete pages directly instead of just disabling them. Here's how it works. How to Rearrange Home Screen Pages Touch and hold Space on the Home screen to enter jitter mode. Tap the row of dots that represent Home screen pages. In the Home screen grid that appears, touch and drag a page to rearrange it relative to other pages. Others move in response to your dragging. When you're happy with your new arrangement, tap "Done" in the upper right corner of the screen, then tap "Done" again to exit dither mode. How to Disable or Remove Home Screen Pages Touch and hold Space on the Home screen to enter dither mode. Tap to represent home screen

How to implement page jump in 3 seconds: PHP Programming Guide How to implement page jump in 3 seconds: PHP Programming Guide Mar 25, 2024 am 10:42 AM

Title: Implementation method of page jump in 3 seconds: PHP Programming Guide In web development, page jump is a common operation. Generally, we use meta tags in HTML or JavaScript methods to jump to pages. However, in some specific cases, we need to perform page jumps on the server side. This article will introduce how to use PHP programming to implement a function that automatically jumps to a specified page within 3 seconds, and will also give specific code examples. The basic principle of page jump using PHP. PHP is a kind of

Use ThinkPHP6 to implement a beautiful 404 page Use ThinkPHP6 to implement a beautiful 404 page Jun 20, 2023 am 11:06 AM

As the Internet develops, many websites or applications have gradually become more complex. When users use it, they often encounter error pages, the most common of which is the 404 page. The 404 page means that the page being accessed does not exist and is a common error page. For websites or applications, a beautiful 404 page can greatly improve the user experience. In this article, we will introduce how to use ThinkPHP6 to quickly implement a beautiful 404 page. Create a route First, we need to create an err in the route folder

Introduction to how to delete a page of content in Word Introduction to how to delete a page of content in Word Mar 26, 2024 am 10:06 AM

Title: Introduction to how to delete a page of content in Word When editing a document using Microsoft Word, you may sometimes encounter a situation where you need to delete the content of a certain page. You may want to delete a blank page or unnecessary content on a certain page in the document. In response to this situation, we can take some methods to quickly and effectively delete a page of content. Next, some methods to delete a page of content in Microsoft Word will be introduced. Method 1: Delete a page of content First, open the Word document that needs to be edited. Certainly

See all articles