有谁知道有一个程序/方法可以只压缩 PNG 图像的某些部分而不对其进行切片?

发布于 2024-07-17 08:10:11 字数 388 浏览 1 评论 0原文

请帮忙! 提前致谢。


更新:很抱歉回复延迟,但如果在这里提供更多背景信息有帮助的话,因为我不确定我应该问什么替代问题。

我有一个 300 像素 x 300 像素的网站主页图像。 该图像有几个不同的区域,其中两个区域顶部有图形副本。

我已在不影响文本外观以及图像关键区域的情况下尽可能压缩图像。

我尝试对图像的不太关键的区域进行切片并以较低的压缩率保存这些区域,以便降低总 kbs,但正如 gregmac 发布的那样,这些部分在重新连接时看起来不正确。

我想知道是否有一款软件,或者手动解决方案来识别图像的关键区域以“减少压缩”,并且可以更多地压缩图像的其他部分,以减小文件大小,同时保留这些元素在需要高分辨率更清晰的图形中。

Please help! Thanks in advance.


Update: Sorry for the delayed response, but if it is helpful to provide more context here, since I'm not sure what alternative question I should be asking.

I have an image for a website home page that is 300px x 300px. That image has several distinct regions, including two that have graphical copy on top of the regions.

I have compressed the image down as much as I can without compromising the appearance of that text, and those critical regions of the image.

I tried slicing the less critical regions of the image and saving those at lower compressions in order to get the total kbs down, but as gregmac posted, the sections don't look right when rejoined.

I was wondering if there was a piece of software out there, or manual solution for identifying critical regions of an image to "compress less" and could compress other parts of the image more in order to get the file size down, while keeping those elements in the graphic that need to be high resolution sharper.

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

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

发布评论

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

评论(2

贵在坚持 2024-07-24 08:10:11

你不能 - 你只能压缩整个 PNG 文件。

你不需要(我想不出压缩 PNG 文件的特定部分有用的单一情况)

将图像分成多个部分(“切片”)是唯一的方法压缩图像文件的不同部分,尽管我什至建议再次在一个“切片图像”中使用不同的压缩级别,因为不同的压缩工件连接在一起可能看起来很奇怪

关于您的更新,

识别图像的关键区域以“减少压缩”,并可以更多地压缩图像的其他部分以减小文件大小

这本质上是图像压缩的作用 - 如果有一点空白区域,它将被压缩到几个字节(例如使用 RLE),但如果有一个非常详细的区域,它会有更多其上“花费”的字节数。

问题听起来好像图像太大(就文件大小而言),您是否尝试过其他图像格式,主要是 GIF 或 JPEG(或其他 PNG 格式,PNG-8 或 PNG-24)?

我已在不影响文本外观的情况下尽可能压缩图像

也许文本可以使用 CSS 覆盖,而不是嵌入图像中? 可能不实用,但它可以让您更多地压缩背景(如果背景图像是照片,JPEG 可能效果最好,因为您不再需要担心文本)

除此之外,我没有想法。 300*300px PNG 真的太大了吗?

You cannot - you can only compress an entire PNG file.

You don't need to (I cannot think of a single case where compressing a specific portion of a PNG file would be useful)

Dividing the image in to multiple parts ("slicing") is the only way to compress different portions of a image file, although I'd even recommend again using different compression levels in one "sliced image", as differing compression artefacts joining up will probably look odd

Regarding your update,

identifying critical regions of an image to "compress less" and could compress other parts of the image more in order to get the file size down

This is inherently what image compression does - if there's a bit empty area it will be compressed to a few bytes (using RLE for example), but if there's a very detailed region it will have more bytes "spent" on it.

The problem sounds like the image is too big (in terms of file-size), have you tried other image formats, mainly GIF or JPEG (or the other PNG format, PNG-8 or PNG-24)?

I have compressed the image down as much as I can without compromising the appearance of that text

Perhaps the text could be overlaid using CSS, rather than embedded in the image? Might not be practical, but it would allow you to compress the background more (if the background image is a photo, JPEG might work best, since you no longer have to worry about the text)

Other than that, I'm out of ideas. Is the 300*300px PNG really too big?

命硬 2024-07-24 08:10:11

听起来好像您正在使用 JPEG 之类的东西压缩图像的一部分,然后将这些压缩图像与其他图像组合粘贴到 PNG 上,然后将整个 PNG 发送到浏览器,在其中将它们分开。

这样做的问题是,对 JPEG 部分压缩得越多,得到的解压伪影就越多。 然后,当您将这些低质量图像放入使用 deflate 压缩的 PNG 时,实际上最终会增加文件大小,因为它无法很好地压缩。

因此,如果您热衷于保留 PNG 作为文件格式,最好的解决方案是不要使用 JPEG 压缩粘贴到 PNG 上的部分 - 使所有内容尽可能清晰。

PNG 会单独压缩每一行,除非您在压缩中使用了“预测器”。

因此,最好让 PNG 尽可能宽,相似的图像水平相邻,而不是垂直排列。

也许上传您正在使用的图像的示例?

It sounds like you are compressing parts of your image using something like JPEG and then pasting those compressed images onto a PNG combined with other images, and the entire PNG is sent to the browser where you split them up.

The problem with this is that the more you compress your JPEG parts the more decompression artifacts you will get. Then when you put these low quality images onto the PNG, which uses deflate compression, you will actually end up increasing the file size because it won't be able to compress well.

So if you are keen on keeping PNG as your file format the best solution would be to not compress the parts using JPEG which you paste onto your PNG - keep everything as sharp as possible.

PNG compresses each row separately unless you have used a "predictor" in the compression.

So it's best to keep your PNG as wide as possible with similar images next to each other horizontally rather than under each other vertically.

Perhaps upload an example of the images you're working with?

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