Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.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 调整图像大小-如果图片不正确,则仅显示一半_Php - Fatal编程技术网

Php 调整图像大小-如果图片不正确,则仅显示一半

Php 调整图像大小-如果图片不正确,则仅显示一半,php,Php,这个脚本如何显示图像的一半而不是整个图像。。。我想弄清楚这里到底出了什么问题 需要帮忙吗 //档案 $ftimage = $_POST['feature_image']; // maximum height 150 X width 150 $width = 150; $height = 150;

这个脚本如何显示图像的一半而不是整个图像。。。我想弄清楚这里到底出了什么问题

需要帮忙吗

//档案

                        $ftimage = $_POST['feature_image'];

                        // maximum height 150 X width 150
                        $width = 150;
                        $height = 150;


                        // Dimensions Set
                        list($width_orig, $height_orig) = getimagesize($ftimage);

                        $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($ftimage);
                        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

                        // Output
                        $image = imagejpeg($image_p, null, 100);
                        var_dump($image);
试着替换它

$ftimage = $_POST['feature_image'];
有了它:

$ftimage = $_POST['feature_image']['tmp_name'];
或者,如果在POST请求中存储了远程图像的URL,请尝试以下操作:

$image = imagecreatefromstring(file_get_contents($ftimage));

我想没有文件上传,你用不同的图片尝试了吗?每个人都有相同的结果?输出
$width\u orig
$height\u orig
,看看这是否正确。