dprnr5559 2012-10-09 23:39
浏览 59

如何在PHP中获得图像质量

I've been doing some speed optimization on my site using Page Speed and it gives recommendations like so:

Optimizing the following images could reduce their size by 35.3KiB (21% reduction).

Losslessly compressing http://example.com/.../some_image.jpg could save 25.3KiB (55% reduction).

How are the calculations done to get the file size reduction numbers? How can I determine if an image is optimized in PHP?

As I understand it, they seem to base this on the image quality (so saving at 60% in Photoshop or so is considered optimized?).

What I would like to do is once an image is uploaded, check if the image is fully optimized, if not, then optimize it using a PHP image library such as GD or ImageMagick. If I'm right about the number being based on quality, then I will just reduce the quality as needed.

How can I determine if an image is fully optimized in the standards that Page Speed uses?

  • 写回答

2条回答 默认 最新

  • douzao1119 2012-10-09 23:54
    关注

    Chances are they are simply using a standard compression or working on some very simple rules to calculate image compression/quality. It isn't exactly what you were after but what I often use on uploaded images etc etc dynamic content is a class called SimpleImage:

    http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

    this will give you the options to resize & adjust compression, and I think even change image type (by which I mean .jpg to .png or .gif anything you like). I worked in seo and page optimization was a huge part of my Job I generally tried to make the images the size the needed to be no smaller or bigger. compress JS & CSS and that's really all most people need to worry about.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大