0
如果我有一個圖像2048×2048,我希望將圖像從頂部1488x1488像素450向下和280個像素從左imagecopyresampled裁剪
是這個正確的代碼x.png是2048×2048圖像:
<?php
$imagesrc_location = 'x.png';
// Get new sizes
list($srcwidth, $srcheight) = getimagesize($imagesrc_location);
$imagedst = imagecreatetruecolor(1488, 1488);
$imagesrc = imagecreatefrompng($imagesrc_location);
if (imagecopyresampled($imagedst,$imagesrc,0,0,280,450,1488,1488,2048,2048)) {
// Output image
header('Content-type: image/png');
imagepng($imagedst);
} else {
echo "Could not resize file";
}
這是一張圖片,顯示我想要的,灰色部分是裁剪圖片。
它不是爲我工作。我給它這個:http://i.min.us/ibvzyAeW9415uv.png它提出了這個:http://i.min.us/ibyi5KbfTglN2P.png – ParoX 2012-02-13 00:11:24
嘗試我發佈的新代碼,並讓我知道 – Matt 2012-02-13 04:41:58
奇怪的是'imagecopyresampled($ imagedst,$ imagesrc,0,0,280,450,1488,1488,1488,1488)'和'imagecopyresampled($ imagedst,$ imagesrc,0,0,280,450,2048,2048,2048,2048)'都可以。我永遠不會完全理解這個功能。 – ParoX 2012-02-14 16:53:37