使用PHP GD库保存jpg图像时如何禁用二次采样? [英] How to disable sub-sampling when saving jpg image using PHP GD library?

查看:43
本文介绍了使用PHP GD库保存jpg图像时如何禁用二次采样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,每当我在PHP中保存一个jpg文件时,该文件都会通过子采样进行保存.如何删除?我正在使用GD库.

I noticed that each time I save a jpg file in PHP, it is saved with sub-sampling. How to remove that? I'm using GD library.

推荐答案

如果将质量设置为90或更高,我相信 libgd 的较新版本会禁用色度二次采样.

I believe newer versions of libgd disable chroma-subsampling if you set the quality to 90 or higher.

如果失败,您可以考虑使用 PHP Imagick 并通过以下方式禁用色度子采样:

Failing that, you could consider using PHP Imagick and disabling chroma sub-sampling with:

$img->setSamplingFactors(array('1x1', '1x1', '1x1'));

这篇关于使用PHP GD库保存jpg图像时如何禁用二次采样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆