POSTS
利用imagemagick來作縮圖
<?php
$w=”240″; //自行設定的縮圖寬度
$h=”320″; //自行設定的縮圖高度
if($_FILES[‘file’][‘type’]==”image/pjpeg” || $_FILES[‘file’][‘type’]==”image/gif” || $_FILES[‘file’][‘type’]==”image/png”) {
if($_FILES[‘file’][‘type’]==”image/pjpeg”) {
$filename=substr(rand(0,999999999999),1,7).”.gif”; //隨機取檔名..我的習慣啦 ^^||
}
if($_FILES[‘file’][‘type’]==”image/gif”) {
$filename=substr(rand(0,999999999999),1,7).”.gif”;
}
if($_FILES[‘file’][‘type’]==”image/png”) {
$filename=substr(rand(0,999999999999),1,7).”.png”;
}
$size=$w.”x”.$h;
copy($_FILES[‘file’][‘tmp_name’],”/home/caisse/case/kf/data/file/b”.$filename); //將暫存檔copy至自己定義的目錄..因為小弟大小圖都想要 ^^
$big_image=”/home/caisse/case/kf/data/file/b”.$filename;
$small_image=”/home/caisse/case/kf/data/file/s”.$filename;
$exec_str=”/usr/bin/convert ‘-geometry’ “.$size.” “.$big_image.” “.$small_image; //注意”跟’唷
exec($exec_str);
} else {
echo “請上傳圖片”;
}
?>
<?php if($_FILES) { ?>
原始圖 ”>
裁切後的圖 ”>
<?php } ?>