【发布时间】:2012-09-15 10:58:04
【问题描述】:
我有一个 php 脚本,用户可以在其中上传图片。 如果文件大小大于“X”kbytes,我想让脚本降低图像质量(jpeg)。
类似这样的:
if( $_FILES['uploaded_img']['size'] > $file_size_limit ){
// code that lowers the quality of the uploaded image but keeps the image width and height
}
最好的方法是什么?
ps:我不想改变图片的宽度和高度。
【问题讨论】:
-
了解图像功能:php.net/manual/en/ref.image.php 您可以使用
imagejpeg将图像保存为另一种质量,但您不会知道原始质量。 -
是的,我想我无法判断图像质量。这就是为什么我只会在文件大小超过一定限制时运行这段代码。
标签: php