Форматът PNG е загубен, тъй като има параметър на компресията?

Съдържание:

Форматът PNG е загубен, тъй като има параметър на компресията?
Форматът PNG е загубен, тъй като има параметър на компресията?

Видео: Форматът PNG е загубен, тъй като има параметър на компресията?

Видео: Форматът PNG е загубен, тъй като има параметър на компресията?
Видео: Как включить отображение скрытых файлов в Mac OSX - 3 способа | показ скрытых файлов и папок на Mac - YouTube 2024, Април
Anonim
PNG форматът трябва да е без загуба на формат, но когато запазвате изображение като PNG файл, ще бъдете помолени да изберете ниво на компресия. Това означава ли, че PNG форматът всъщност не е без загуба в края на краищата? Днешната публикация "SuperUser Q &A" помага да се изясни объркването за любопитен читател.
PNG форматът трябва да е без загуба на формат, но когато запазвате изображение като PNG файл, ще бъдете помолени да изберете ниво на компресия. Това означава ли, че PNG форматът всъщност не е без загуба в края на краищата? Днешната публикация "SuperUser Q &A" помага да се изясни объркването за любопитен читател.

Днешната сесия за въпроси и отговори ни идва с любезното съдействие на SuperUser - подразделение на Stack Exchange - обединяване на уеб сайтове с въпроси и отговори.

Въпроса

Плейърът за четене на SuperUser иска да знае дали качеството на PNG изображение е повлияно от избраното ниво на компресия:

As I understand it, PNG files use lossless compression. However, when I am using an image editor such as Gimp and try to save an image as a PNG file, it asks for a compression level ranging between 0 and 9.

If it has a compression parameter that affects the visual precision of the compressed image, how is PNG lossless then? Can someone please explain this to me? Do I get lossless behavior only when I set the compression level to 9?

Има ли разлика в качеството на изображението в зависимост от нивото на компресия, което избирате?

Отговорът

Сътрудниците на SuperUser LordNeckbeard и jjlin имат отговор за нас. Първо, лорд Нeкбеард:

PNG is Compressed, but Lossless

The compression level is a trade-off between file size and encoding/decoding speed. To overly generalize, even non-image formats such as FLAC have similar concepts.

Different Compression Levels, Same Decoded Output

Although the file sizes are different due the the different compression levels, the actual decoded output will be identical. You can compare the MD5 hashes of the decoded outputs with ffmpeg using the MD5 muxer. This is best shown with some examples.

Create PNG Files

Image
Image
  • By default, ffmpeg will use -compression_level 100 for PNG output.
  • A quick, sloppy test showed that 100 (the highest compression level) took roughly three times longer to encode and five times longer to decode than 0 (the lowest compression level) in this example.

Compare File Size

Image
Image

Decode the PNG Files and Show MD5 Hashes

Since both hashes are the same, you can be assured that the decoded outputs (the uncompressed raw files) are exactly the same.
Since both hashes are the same, you can be assured that the decoded outputs (the uncompressed raw files) are exactly the same.

Последвано от отговора на jjlin:

PNG is lossless. GIMP is most likely not using the best choice of wording in this case.

Think of it as quality of compression or level of compression. With lower compression, you get a bigger file, but it takes less time to produce, whereas with higher compression, you get a smaller file that takes longer to produce.

Typically you get diminishing returns, i.e. not as much decrease in size compared to the increase in time it takes when going up to the highest compression levels, but it is up to you.

Имате ли нещо, което да добавите към обяснението? Звучи в коментарите. Искате ли да прочетете повече отговори от други потребители на Stack Exchange? Вижте цялата тема на дискусията тук.

Препоръчано: