Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当图像大于3000px时,调整图像大小而不丢失质量_Php - Fatal编程技术网

Php 当图像大于3000px时,调整图像大小而不丢失质量

Php 当图像大于3000px时,调整图像大小而不丢失质量,php,Php,我有一个脚本可以调整上传图像的大小而不会降低质量,但是当它的宽度/高度超过3000像素时,它就不会调整大小。我尝试在httaccess中设置值,但没有任何更改。 以下是脚本: $filename = "image.jpg"; // Set a maximum height and width $width = 490; $height = 800; header('Content-Type: image/jpeg'); list($width_orig

我有一个脚本可以调整上传图像的大小而不会降低质量,但是当它的宽度/高度超过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 

在对图像进行重新采样时,请使用@

i、 e


测试解决方案。

白色屏幕,没有图像,没有其他内容,图像上载,但原始大小可以尝试
var\u转储(imagecopyresampled($image\u p,$image,0,0,0,$width,$height,$width\u orig,$height\u orig));退出检查返回值?
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = @imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);