我已经设置了一个包机,游艇和其他车辆预订的管理面板,我只想上传一个单一的图像为车辆和nedd来调整图像的多个大小,而不使用phpthumb库,因为它需要太多的时间加载列表页面,首先它使图像的缓存,因此它糟糕。我需要一个简单的方法来调整单个图像的大小,以便管理员没有上传该车辆的多个图像。
发布于 2012-05-03 21:38:25
好的,this是一个非常好的库,用来做你需要的事情。
发布于 2012-05-03 21:41:27
我使用我创建的这个函数:
<?php
function getImageXY( $image, $type='original' ) {
if( $type == 'original' ) {
$imgDimsMax = 200;
} else if( $type == 'thumb' ) {
$imgDimsMax = 60;
} else if( $type == 'defualt' ) {
$imgDimsMax = 140;
}
$aspectRatio = 1; // deafult aspect ratio...keep the image as is.
// set the default dimensions.
$imgWidth = $imgDimsMax;
$imgHeight = $imgDimsMax;
list( $width, $height, $type, $attr ) = getimagesize( $image );
//$imgHeight = floor ( $height * ( $imgWidth / $width ) );
if( $width == $height ) {
// if the image is less than ( $imgDimsMax x $imgDimsMax ), use it as is..
if( $width < $imgDimsMax ) {
$imgWidth = $width;
$imgHeight = $height;
}
} else {
if( $width > $height ) {
// set $imgWidth to $imgDimsMax and resize $imgHeight proportionately
$aspectRatio = $imgWidth / $width;
$imgHeight = floor ( $height * $aspectRatio );
} else if( $width < $height ) {
// set $imgHeight to $imgDimsMax and resize $imgWidth proportionately
$aspectRatio = $imgHeight / $height;
$imgWidth = floor ( $width * $aspectRatio );
}
}
return array( $imgWidth, $imgHeight );
}
?>向它传递原始图像和尺寸类型(不同的类型指定不同的大小),它将返回新的宽度和高度。希望ie能帮上忙。
https://stackoverflow.com/questions/10432542
复制相似问题