チャーター、ヨット、その他の車両の予約用の管理パネルを設定しました。リストの読み込みに時間がかかりすぎるため、phpthumbライブラリを使用せずに、車両の画像を1つだけアップロードし、画像のサイズを複数のサイズに変更したいと考えています。ページ、最初に画像のキャッシュを作成するので、それはひどいです。管理者がその車両の複数の画像をアップロードしないように、単一の画像のサイズを変更する簡単な方法が必要です。
2 に答える
0
わかりました。これは、必要なことを行うための非常に優れたライブラリです。
于 2012-05-03T13:38:25.427 に答える
0
私が作ったこの関数を使用します:
<?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 );
}
?>
元の画像と寸法タイプ(タイプが異なればサイズも異なります)を渡すと、新しい幅と高さが返されます。希望すなわち助けてください。
于 2012-05-03T13:41:26.557 に答える