本文介绍了是否可以判断 JPEG 的质量水平?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这真的是一个由两部分组成的问题,因为我还没有完全理解这些东西是如何工作的:

This is really a two part question, since I don't fully understand how these things work just yet:

我的情况:我正在编写一个允许用户上传图像的网络应用程序.然后,我的应用将大小调整为可显示的大小(例如:640x480-ish)并保存文件以备后用.

My situation: I'm writing a web app which lets the user upload an image. My app then resizes to something displayable (eg: 640x480-ish) and saves the file for use later.

我的问题:

  1. 给定一个任意的 JPEG 文件,是否可以判断质量级别是多少,以便我在保存调整大小的图像时可以使用相同的质量?
  2. 这还重要吗??无论原始质量如何,我是否应该以合适的级别(例如:75-80)保存所有图像?

我对此不太确定,因为我认为:(让我们举一个极端的例子),如果有人以 0 质量保存了 5 兆像素的图像,它会像任何东西一样块状.将图像大小减小到 640x480,块状将被平滑并且不那么明显......直到我再次以质量 0 保存它......

I'm not so sure about this because, as I figure it: (let's take an extreme example), if someone had a 5 megapixel image saved at quality 0, it would be blocky as anything. Reducing the image size to 640x480, the blockiness would be smoothed out and less noticeable... until I saved it with quality 0 again...

另一方面,如果有一张 800x600 且 q=0 的图像,调整到 640x480 不会改变它看起来完全是废话的事实,因此使用 q=80 保存将是多余的.

On the other end of the spectrum, if there was an image which was 800x600 with q=0, resizing to 640x480 isn't going to change the fact that it looks like utter crap, so saving with q=80 would be redundant.

我什至接近了吗?

如果有任何用处,我正在 PHP 上使用 GD2 库

推荐答案

  1. JPEG 是一种有损格式.每次保存 JPEG 相同图像时,无论质量级别如何,都会降低实际图像质量.因此,即使您确实从文件中获得了质量级别,再次保存 JPEG 时也无法保持相同的质量(即使在 quality=100 时).

  1. JPEG is a lossy format. Every time you save a JPEG same image, regardless of quality level, you will reduce the actual image quality. Therefore even if you did obtain a quality level from the file, you could not maintain that same quality when you save a JPEG again (even at quality=100).

就文件大小而言,您应该以尽可能高的质量保存 JPEG.或者使用无损格式,例如 PNG.

You should save your JPEG at as high a quality as you can afford in terms of file size. Or use a loss-less format such as PNG.

低质量的 JPEG 文件不会简单地变得更加块状.取而代之的是减少了颜色深度,并删除了图像部分的细节.您不能指望低质量的图像是块状的并且在较小的尺寸下看起来还不错.

Low quality JPEG files do not simply become more blocky. Instead colour depth is reduced and the detail of sections of the image are removed. You can't rely on lower quality images being blocky and looking ok at smaller sizes.

根据 JFIF 规范 质量数(0-100) 不存储在图像标题中,尽管存储了水平和垂直像素密度.

According to the JFIF spec. the quality number (0-100) is not stored in the image header, although the horizontal and vertical pixel density is stored.

这篇关于是否可以判断 JPEG 的质量水平?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 16:30