我有脚本来调整上传图像的大小而不会降低质量但是当它大约超过3000像素宽/高时它不会调整大小。我尝试在httaccess中设置值,但没有任何变化。
以下是脚本:
$filename = "image.jpg";
// Set a maximum height and width
$width = 490;
$height = 800;
header('Content-Type: image/jpeg');
list($width_orig, $height_orig) = getimagesize($filename);
$ratio_orig = $width_orig / $height_orig;
if ($width / $height > $ratio_orig) {
$width = $height * $ratio_orig;
} else {
$height = $width / $ratio_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p, "image_resized.jpg", 100);
和.htacces我试过:
php_value memory_limit 24M
php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_input_time 300
php_value max_execution_time 300
答案 0 :(得分:2)
在重新取样图像时使用@
即
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = @imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
测试解决方案。