获取图像的压缩比

发布于 2024-10-15 01:45:54 字数 52 浏览 3 评论 0原文

我使用 LibJPEG 来读取 JPEG 压缩图像。有没有办法获取未更改图像的当前压缩率?

I use LibJPEG to read JPEG compressed images. Is there a way to get the current compression ratio of the unchanged image?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

终弃我 2024-10-22 01:45:54

您指的是编码质量,通常是 0-100 的数字吗?

它不会被存储 - 它被用作图像编码的指南,以了解波的准确度,然后将其丢弃。任何 JFIF 标头结构中都没有对应的字段。据我所知,这个数字在编码器中的含义没有正式的定义,因此您无论如何都无法精确确定任何给定数字的影响。

Do you mean the encoding quality, usually a number 0-100?

That isn't stored - it's used as a guide for the image encode as to how accurate the waves should be, and it's then discarded. There's no field for it in any of the JFIF header structures. As far as I can see there's no formal definition of what this number means across encoders and so you can't precisely determine the effects of any given number anyway.

剪不断理还乱 2024-10-22 01:45:54

如果 Photoshop 保存 Jpeg,则必须将压缩级别存储在某处。多年来,我一直在文件上使用 Photoshop 的“另存为”作为检测所使用的压缩级别的方法。根据我的经验,它总是建议与当前文件使用的压缩级别相同的压缩级别。请注意,您实际上不必保存它。显然,这种方法不适用于大量文件,但确实有证据表明它必须存储在某个地方。

The compression level must be stored somewhere if Photoshop saves the Jpeg. For years I have used Photoshop's Save As on a file as a method of detecting what compression level was used. In my experience it always suggests a compression level equal to that used on the current file. Note that you don't actually have to save it. Obviously this method is no good for lots of files, but surely is evidence that it must be stored there somewhere.

铁憨憨 2024-10-22 01:45:54

如果压缩比,你的意思是文件大小相对,

可以使用 ImageMagick-6.7.5.6 中的识别-verbose

例如:

identify -verbose 1.jpg
(...)
  Geometry: 607x800+0+0
  Resolution: 72x72
(...)
  Filesize: 143KB
  Number pixels: 486K

好坏

identify -verbose 2.jpg
  (...)
  Geometry: 1719x2377+0+0
  Resolution: 100x100
  (...)
  Filesize: 408KB
  Number pixels: 4.086M

更好

convert 2.jpg -resample 72x72 2c.jpg 
identify -verbose 2c.jpg
  Geometry: 1238x1711+0+0
  Resolution: 72x72

  Filesize: 272KB
  Number pixels: 2.118M

http://www.imagemagick.org/script/command-line-options.php?#密度 讨论这个主题并以“调整图像大小”结束以便它在不同的分辨率下具有相同的大小,请使用 -resample 选项”

我还发现了一个修改“jpeg 品质因数”的工具。 Jpegoptim - 优化 jpeg 文件的实用程序。提供无损优化(基于优化霍夫曼表)和基于设置最大品质因数的“有损”优化。
http://www.kokkonen.net/tjko/projects.html

希望有所帮助。

if compression ratio, do you mean filesize relative

you may use identify -verbose from ImageMagick-6.7.5.6

For example:

identify -verbose 1.jpg
(...)
  Geometry: 607x800+0+0
  Resolution: 72x72
(...)
  Filesize: 143KB
  Number pixels: 486K

good

identify -verbose 2.jpg
  (...)
  Geometry: 1719x2377+0+0
  Resolution: 100x100
  (...)
  Filesize: 408KB
  Number pixels: 4.086M

bad

convert 2.jpg -resample 72x72 2c.jpg 
identify -verbose 2c.jpg
  Geometry: 1238x1711+0+0
  Resolution: 72x72

  Filesize: 272KB
  Number pixels: 2.118M

much better

http://www.imagemagick.org/script/command-line-options.php?#density talk about this subject and finish with "To resize the image so that it is the same size at a different resolution, use the -resample option"

I found also a tool to modify "jpeg quality factor". Jpegoptim - utility to optimize jpeg files. Provides lossless optimization (based on optimizing the Huffman tables) and "lossy" optimization based on setting maximum quality factor.
http://www.kokkonen.net/tjko/projects.html

Hope help in something.

南街女流氓 2024-10-22 01:45:54

压缩比=(未压缩大小)/(压缩大小)。

要自动获取该信息,请下载 Irfanview,Windows 的免费图像程序,用它打开图像,然后从转到“图像”->“图像”->“图像”。信息->您可以在那里看到很多有用的信息,其中包括“压缩”和质量、尺寸分辨率颜色等。现在转到 -> EXIF 信息 ->压缩->这里的数字就是压缩比。

例如:如果压缩率为 6,则原始文件/图像大小是压缩后的文件/图像大小的 6 倍(您现在正在查看)。

Compression ratio = (uncompressed size) / (compressed size).

To get that automatically, download Irfanview, free image program for Windows, open your image with it and then from the go to Image -> Information -> You can see a lot of useful information there, among those are "Compression" and quality, size resolution colors etc. Now go to -> EXIF info -> Compression -> The number here is the compression ratio.

example: If the compression is 6, then the original file/image size was 6 times bigger than the compressed one (you are now viewing).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文