Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.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
Javascript imagecopyresized()函数不会更改为上述尺寸,而是更改为20 x 20 px_Javascript_Php_Html_Image - Fatal编程技术网

Javascript imagecopyresized()函数不会更改为上述尺寸,而是更改为20 x 20 px

Javascript imagecopyresized()函数不会更改为上述尺寸,而是更改为20 x 20 px,javascript,php,html,image,Javascript,Php,Html,Image,我使用下面的代码来更改大小,但它将图像尺寸更改为固定的20 x 20像素。请帮忙 $url="database_images/".$row['post_id']."_image.jpg"; $width=300; $image = imagecreatefromjpeg($url); $orig_width = imagesx($image); $orig_height = imagesy($image); // Calc the new height $height = (($orig_hei

我使用下面的代码来更改大小,但它将图像尺寸更改为固定的20 x 20像素。请帮忙

$url="database_images/".$row['post_id']."_image.jpg";
$width=300;
$image = imagecreatefromjpeg($url);
$orig_width = imagesx($image);
$orig_height = imagesy($image);
// Calc the new height
$height = (($orig_height * $width) / $orig_width);
// Create new image to display
$new_image = imagecreatetruecolor($width, $height);

// Create new image with changed dimensions
imagecopyresized($new_image, $image,
0, 0, 0, 0,
$width, $height,
$orig_width, $orig_height);
// Print image
imagejpeg($new_image,"temp.jpg");
echo '<img id="post_image_display" src="temp.jpg">';
$url=“database_images/”$row['post_id']。“_image.jpg”;
$width=300;
$image=imagecreatefromjpeg($url);
$orig_width=imagesx($image);
$orig_height=imagesy($image);
//计算新高度
$height=($orig_height*$width)/$orig_width);
//创建要显示的新图像
$new_image=imageCreateTureColor($width,$height);
//创建具有更改尺寸的新图像
imagecopyresized($new\u image,$image,
0, 0, 0, 0,
$width,$height,
$orig_宽度,$orig_高度);
//打印图像
imagejpeg($new_image,“temp.jpg”);
回声';

你有没有费心检查你输入到
imagecopyresized
的数字?有。新的宽度和高度分别为300和300。然而,显示的图像高度为20,宽度为20。您可能正在显示缓存版本。由于url位于
“/>
中,因此每次都会使它看起来像一个新的url。非常感谢…它工作了。。。。。