我有如下PHP代碼:作物扭曲/縮放圖像
$w = 300; // Width of new image
$h = 300; // Height of new image
$oh = 540; // Original file height
$ow = 720; // Original file width
$x = 196;
$y = 50;
$image = imagecreatefromjpeg('fileToCrop.jpg');
$cropped_image = imagecreatetruecolor($w, $h);
imagecopyresampled($cropped_image, $image, 0, 0, $x, $y, $ow, $oh, $w, $h);
imagejpeg($cropped_image, 'fileToCrop.jpg', 100);
而且要裁剪的圖像,但我的圖像扭曲/比原來的,例如更高:
原文:
裁剪( 「N」 爲 「未」 被示出):
我看不出有什麼錯我的代碼,什麼都發生在圖像變爲更大..
原始尺寸爲720x540。使用以下函數來獲取高度/寬度。 http://php.net/manual/en/function.getimagesize.php – twodayslate
@twodayslate對不起,這是一個錯字。 –