我建立了一个imgResize类:
class imgResize
{
public static function resizeAndOutput($img) {
$orginal_img = $img;
$width = 591;
$height = 332;
$new_width = 161;
$new_height = 91;
$edit_img = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($orginal_img);
imagecopyresampled($edit_img, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
header('Content-Type: image/jpeg');
imagejpeg($edit_img);
}
}
在 html 中,我尝试动态img
显示:
<img class="img_small" src="<?php imgResize::resizeAndOutput($img)">
只是得到这样的二进制数据:
�����JFIF���������>CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality ���C� $.'
我该如何解决我的问题?