サムネイルを表示
function CreateThumbnail($path,$newFileName,$width=100,$height=100)
{
@$s_img = getimagesize($path);
@$type = $s_img[2] ;
switch($type)
{
ケース 1 : @$im = imagecreatefromgif($path);break;
ケース 2 : @$im = imagecreatefromjpeg($path); Break;
ケース 3 : @$im = imagecreatefrompng($path);break;
デフォルト: $im = false;
Break;
= Images x($im);
@$s_height = imagey( $im);
$sizexy = getScaleImage($path,$width,$height);
$width = $sizexy[0];
$height = $sizexy[1];
if($im)
{
$im2 = imagecreatetruecolor($width,$height);
imagecopyresize ($im2,$im,0,0,0,0,$width,$height,$s_width,$s_height);
imagejpeg($im2,$ newFileName);
}
return false;
}
function getScaleImage($image,$perfectWidth,$perfectHeight)
{
if (realpath($image) != false)
{
$sizeArray = getimagesize($image) ;
$sizeX = $sizeArray[ 0 ] ;
$sizeY = $sizeArray[ 1 ] ;
if ($perfectWidth!=0 && $perfectHeight==0)
{
if ($sizeX>$perfectWidth)
{
$scale = $sizeX/$sizeY ;
$sizeX = $perfectWidth;
$sizeY = Floor($sizeX/$scale);
}
}
if ($perfectHeight != 0 && $perfectWidth == 0)
{
if ($sizeY > $perfectHeight)
{
$scale = $sizeY / $sizeX ;
$sizeY = $perfectHeight;
$sizeX = Floor($sizeY / $scale);
}
}
if ($perfectHeight != 0 && $perfectWidth != 0)
{
$sizeX = $perfectWidth;
$sizeY = $perfectHeight;
}
$tmp[] = $sizeX;
$tmp [] = $sizeY;
}
else
{
$tmp[] = 0;
}
return $tmp;
}
$t m = getScaleImage("http://www.pushad.com/Info/100_3353 .jpg",0,0);
echo "";
foreach ($tm as $v)
{
echo $v."
";
}
//CreateThumbnail("http ://www.pushad.com/Info/100_3353.jpg","aa.gif",100,0);
?>