PHPでサムネイル作成
某氏に依頼されたスクリプト用の習作ですね。
$source_x=1024;
$source_y=768;
$thumb_x=252;
$thumb_y=189;
$image=imagecreatefromjpeg($source_name);
$thumb=imagecreatetruecolor($thumb_x,$thumb_y);
imagecopyresampled($thumb,$image,0,0,0,0,$thumb_x,$thumb_y,$source_x,$source_y);
imagejpeg($thumb,$thumb_name,100);
実際に使うときは$source_nameと$thumb_nameにそれぞれ元画像とサムネイル画像のファイル名を入れてどうぞ。元画像をそのまま縮小する方法は…誰か教えてw
| 固定リンク
コメント