list($width,$height)=getimagesize("img/php/20040218.jpg"); |
<?php list($width,$height)=getimagesize("img/php/20040218.jpg"); echo "幅:" .$width ." 縦:" .$height; ?> |
$src=@imagecreatefromjpeg("img/php/20040218.jpg"); |
$awidth=$width/2; $aheight=$height/2; $dst=imagecreatetruecolor($awidth,$aheight); |
まとめて書くと <?php src=@imagecreatefromjpeg("img/php/20040218.jpg"); $awidth=$width/2; $aheight=$height/2; $dst=imagecreatetruecolor($awidth,$aheight); imagecopyresized($dst,$src,0,0,0,0,$awidth,$aheight,$width,$height); imagejpeg($dst,"img/php/20040218small.jpg"); ?> |
(オマケ) getimagesizeの4つめの要素はにそのまま使えますっ♪ <?php list($width,$height,$type,$imgtag)=getimagesize("img/php/20040218.jpg"); echo "<img src=\"img/php/20040218.jpg\" $imgtag>"; ?> この画像のソース <img src="img/php/20040218.jpg" width="289" height="206"> |
HOME |