1
这里是网站的IM谈论 http://makeupbyarpi.com/portfolio.phpPHP GD:当我通过PHP裁剪图像的一些图像出来smushed
,你会发现一些图像都smushed宽度方向。
我使用的代码是这样的:
$width="500";
$height="636";
$img_src = $_FILES['galleryimg']['tmp_name'];
$thumb = "../gallery/".rand(0,100000).".jpg";
//Create image stream
$image = imagecreatefromjpeg($img_src);
//Gather and store the width and height
list($image_width, $image_height) = getimagesize($img_src);
//Resample/resize the image
$tmp_img = imagecreatetruecolor($width, $height);
imagecopyresampled($tmp_img, $image, 0, 0, 0, 0, $width, $height, $image_width, $image_height);
//Attempt to save the new thumbnail
if(is_writeable(dirname($thumb))){
imagejpeg($tmp_img, $thumb, 100);
}
//Free memory
imagedestroy($tmp_img);
imagedestroy($image);
是那些获得上传的图片是巨大的,有时3000px由2000像素和我有PHP的作物下来,以500×536和一些基于景观图像得到smushed。有没有一个公式我可以用它仔细裁剪,使图像出来好?
感谢
所以如果宽度大于这种情况下的高度,我将宽度设置为500,并保持高度? – iaddesign 2009-09-30 17:45:44
给我5分钟我会写一个例子。 – 2009-09-30 17:47:19
哇,这很不错。非常感谢!你不需要为此付出代价,只要你对我产生了很大的帮助。我希望我能把你的观点:) – iaddesign 2009-10-01 01:11:54