• <tfoot id='AyWsn'></tfoot>
    • <bdo id='AyWsn'></bdo><ul id='AyWsn'></ul>

      1. <legend id='AyWsn'><style id='AyWsn'><dir id='AyWsn'><q id='AyWsn'></q></dir></style></legend>

      2. <i id='AyWsn'><tr id='AyWsn'><dt id='AyWsn'><q id='AyWsn'><span id='AyWsn'><b id='AyWsn'><form id='AyWsn'><ins id='AyWsn'></ins><ul id='AyWsn'></ul><sub id='AyWsn'></sub></form><legend id='AyWsn'></legend><bdo id='AyWsn'><pre id='AyWsn'><center id='AyWsn'></center></pre></bdo></b><th id='AyWsn'></th></span></q></dt></tr></i><div id='AyWsn'><tfoot id='AyWsn'></tfoot><dl id='AyWsn'><fieldset id='AyWsn'></fieldset></dl></div>

        <small id='AyWsn'></small><noframes id='AyWsn'>

        PHP:如何压缩图像而不损失可见质量(自动)?

        时间:2023-08-17
      3. <i id='sQaL9'><tr id='sQaL9'><dt id='sQaL9'><q id='sQaL9'><span id='sQaL9'><b id='sQaL9'><form id='sQaL9'><ins id='sQaL9'></ins><ul id='sQaL9'></ul><sub id='sQaL9'></sub></form><legend id='sQaL9'></legend><bdo id='sQaL9'><pre id='sQaL9'><center id='sQaL9'></center></pre></bdo></b><th id='sQaL9'></th></span></q></dt></tr></i><div id='sQaL9'><tfoot id='sQaL9'></tfoot><dl id='sQaL9'><fieldset id='sQaL9'></fieldset></dl></div>
            <bdo id='sQaL9'></bdo><ul id='sQaL9'></ul>
              <tbody id='sQaL9'></tbody>
          • <legend id='sQaL9'><style id='sQaL9'><dir id='sQaL9'><q id='sQaL9'></q></dir></style></legend>

                <small id='sQaL9'></small><noframes id='sQaL9'>

                  <tfoot id='sQaL9'></tfoot>

                  本文介绍了PHP:如何压缩图像而不损失可见质量(自动)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道如何自动确定最佳压缩率(小文件+无质量损失).

                  I'm wondering how to figure out the best compress rate (small filesize + no quality loss) automatically.

                  目前我正在使用 imagejpeg() 和 $quality = 85 对于每个 <代码>.jpg.

                  At the moment I'm using imagejpeg() with $quality = 85 for each .jpg.

                  PageSpeed(Chrome 插件)建议降低一些图像的质量以节省一些 kb.减少的百分比不同.

                  PageSpeed (Chrome Plugin) suggests, to lower the quality of a few images to save some kb. The percentage of reduction is different.

                  我想编写一个 cronjob 来抓取特定目录并优化每个图像.

                  I'd like to write a cronjob that crawls a specific directory and optimizes every image.

                  PageSpeed 或 TinyPNG 如何确定最佳优化质量,这是否可以使用 PHP 或其他服务器端语言?

                  How does PageSpeed or TinyPNG figure out the best optimized quality and is this possible with PHP or another serverside-language?

                  推荐答案

                  TinyPNG 使用 pngquant.

                  TinyPNG uses pngquant.

                  Pngquant 可以选择设置所需的质量,类似于 JPEG.您可以运行以下内容:

                  Pngquant has option to set desired quality, similar to JPEG. You can run something like:

                  <?php system('pngquant --quality=85 image.png'); ?>
                  

                  Pngquant 网站上的示例代码展示了如何使用 PHP 中的 pngquant.

                  对于 JPEG,您可以应用 lossless jpegcrush.

                  For JPEG you can apply lossless jpegcrush.

                  JpegMini(商业)和 jpeg-archive(免费)有损,可以自动为 JPEG 找到最低质量的质量.

                  JpegMini (commercial) and jpeg-archive (free) are lossy and can can automatically find a minimal good quality for a JPEG.

                  在 PHP 中,您可以通过观察重新压缩后文件大小的变化来粗略估计 JPEG 被压缩了多少.以相同或更高质量重新压缩的 JPEG 文件大小不会有太大变化(但会损失视觉质量).

                  In PHP you can roughly estimate how much JPEG was compressed by observing how much file size changes after re-compression. File size of JPEG recompressed at same or higher quality will not change much (but will lose visual quality).

                  如果您重新压缩 JPEG 并看到文件大小减半,则保留重新压缩的版本.如果您看到文件大小仅减少 10-20%,请保留原始文件.

                  If you recompress JPEG and see file size halved, then keep the recompressed version. If you see only 10-20% drop in file size, then keep the original.

                  如果您要压缩自己,请使用 MozJPEG(这是一个 网络版).

                  If you're compressing yourself, use MozJPEG (here's an online version).

                  这篇关于PHP:如何压缩图像而不损失可见质量(自动)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:退出时自动重启 PHP 脚本 下一篇:如何使用 PHP 启动/停止 cronjob?

                  相关文章

                  1. <i id='OQwzj'><tr id='OQwzj'><dt id='OQwzj'><q id='OQwzj'><span id='OQwzj'><b id='OQwzj'><form id='OQwzj'><ins id='OQwzj'></ins><ul id='OQwzj'></ul><sub id='OQwzj'></sub></form><legend id='OQwzj'></legend><bdo id='OQwzj'><pre id='OQwzj'><center id='OQwzj'></center></pre></bdo></b><th id='OQwzj'></th></span></q></dt></tr></i><div id='OQwzj'><tfoot id='OQwzj'></tfoot><dl id='OQwzj'><fieldset id='OQwzj'></fieldset></dl></div>
                    <tfoot id='OQwzj'></tfoot>

                    <small id='OQwzj'></small><noframes id='OQwzj'>

                      <legend id='OQwzj'><style id='OQwzj'><dir id='OQwzj'><q id='OQwzj'></q></dir></style></legend>

                        <bdo id='OQwzj'></bdo><ul id='OQwzj'></ul>