UploadProc 는 업로드 되는 부분을 만들어 놓은 class 입니다.
업로드 부분은 자신에게 맞는것으로 수정 하시면 됩니다.
if($mode=="submit"){
// echo $_FILES['userfile']['name'];
// exit;
if($_FILES['userfile']["name"] != "") {
$UploadProc = new UploadProc("/home/flowermall/admin_new/temp/imageMagick/original","1073741824");
$image_name = $UploadProc->Upload($_FILES['userfile']);
$full_filename=explode(".","$image_name");
$ext=$full_filename[sizeof($full_filename)-1];
$file_name=str_replace(".".$ext,"",$image_name);
$image_name_110=$file_name."_110.$ext";
$image_name_150=$file_name."_150.$ext";
$image_name_200=$file_name."_200.$ext";
$image_name_250=$file_name."_250.$ext";
$image_name_550=$file_name."_550.$ext";
$image_name_650=$file_name."_650.$ext";
$image_name_550_mark=$file_name."_550_mark.$ext";
exec("convert -thumbnail 110 -sharpen 100 ./original/$image_name ./110/$image_name_110");
exec("convert -thumbnail 150 ./original/$image_name ./150/$image_name_150");
exec("convert -thumbnail 200 ./original/$image_name ./200/$image_name_200");
exec("convert -thumbnail 250 ./original/$image_name ./250/$image_name_250");
exec("convert -thumbnail 550 ./original/$image_name ./550/$image_name_550");
exec("convert -thumbnail 650 ./original/$image_name ./650/$image_name_650");
exec("composite -gravity SouthWest mark_550.gif ./550/$image_name_550 ./550/$image_name_550_mark");
exec("composite -gravity SouthWest mark_550.gif ./650/$image_name_650 ./650/$image_name_650_mark");
echo "
<IMG SRC='./110/$image_name_110'><br>
<IMG SRC='./150/$image_name_150'><br>
<IMG SRC='./200/$image_name_200'><br>
<IMG SRC='./250/$image_name_250'><br>
<IMG SRC='./550/$image_name_550_mark'><br>
<IMG SRC='./650/$image_name_650'><br>
";
}
}
?>
<html>
<head>
<title>이미지 업로드 resize 테스트</title>
<script language=javascript>
function addPhoto(url){
document.preview.src=url;
document.preview.style.display='block';
}
</script>
</head>
<body>
<form method=post action='<?=$_SERVER[PHP_SELF]?>' enctype='multipart/form-data'>
<input type=hidden name=mode value='submit'>
<INPUT TYPE=FILE name=userfile onChange="addPhoto(this.value)"><br>
<img name=preview src='' width=300 style="display:none"><br>
<INPUT TYPE=SUBMIT><br>
</form>
</body>
</html>
소스상에서
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
function MakeThum($FileName)
{
$ThumFileName = $FileName . ".gif";
$FileName = "../screenshot/" . $FileName;
$ThumFileName = "../screenshot/" . $ThumFileName;
exec ("convert -geometry 400x $FileName $ThumFileName");
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
정도면 가능합니다.
조금 설명을 드린다면 exec는 외부 프로그램을 실행시키는 명령어 입니다.
convert는 좀전에 설치한 imagemagick중의 하나인데 메뉴얼에보면
이놈의 옵션중에 하나인 geometry는
geometry <width>x<height>{+-}<x>{+-}<y>{%}{@} {!}{<}{>}
preferred size and location of the Image window.
preferred size and location of the Image window.
By default, the window size is the image size and the location is chosen by you when it is mapped.
By default, the width and height are maximum values. That is, the image is expanded or contracted to fit the width and height value while maintaining the aspect ratio of the image. Append an exclamation point to the geometry to force the image size to exactly the size you specify. For example, if you specify 640x480! the image width is set to 640 pixels and height to 480.
If only the width is specified, the width assumes the value and the height is chosen to maintain the aspect ratio of the image. Similarly, if only the height is specified (e.g., -geometry x256), the width is chosen to maintain the aspect ratio.
To specify a percentage width or height instead, append %. The image size is multiplied by the width and height percentages to obtain the final image dimensions. To increase the size of an image, use a value greater than 100 (e.g. 125%). To decrease an image's size, use a percentage less than 100.
Use @ to specify the maximum area in pixels of an image.
Use > to change the dimensions of the image only if its width or height exceeds the geometry specification. < resizes the image only if both of its dimensions are less than the geometry specification. For example, if you specify '640x480>' and the image size is 256x256, the image size does not change. However, if the image is 512x512 or 1024x1024, it is resized to 480x480. Enclose the geometry specification in quotation marks to prevent the < or > from being interpreted by your shell as a file redirection.
When used with animate and display, offsets are handled in the same manner as in X(1) and the -gravity option is not used. If the x is negative, the offset is measured leftward from the right edge of the screen to the right edge of the image being displayed. Similarly, negative y is measured between the bottom edges. The offsets are not affected by "%"; they are always measured in pixels.
When used as a composite option, -geometry gives the dimensions of the image and its location with respect to the composite image. If the -gravity option is present with NorthEast, East, or SouthEast gravity, the x represents the distance from the right edge of the image to the right edge of the composite image. Similarly, if the -gravity option is present with SouthWest, South, or SouthEast gravity, y is measured between the bottom edges. Accordingly, a positive offset will never point in the direction outside of the image. The offsets are not affected by "%"; they are always measured in pixels. To specify the dimensions of the composite image, use the -resize option.
When used as a convert, import or mogrify option, -geometry is synonymous with -resize and specifies the size of the output image. The offsets, if present, are ignored.
When used as a montage option, -geometry specifies the image size and border size for each tile; default is 256x256+0+0. Negative offsets (border dimensions) are meaningless. The -gravity option affects the placement of the image within the tile; the default gravity for this purpose is Center. If the "%" sign appears in the geometry specification, the tile size is the specified percentage of the original dimensions of the first tile. To specify the dimensions of the montage, use the -resize option.
라고 되어있는데...
convert -geometry 400x
정확한 해석은...제가 아까도 말씀드렸지만 영어가 딸려서...^^...공부해야되...ㅡ,.ㅡ
뭐 대충
convert -geometry 400x
요렇게 쓰면 썸네일을 만들때 가로가 400에 고정되고 세로는 그 비율에 맞게 되고
convert -geometry x400
요렇게 쓰면 썸네일을 만들때 세로가 400에 고정되고 가로는 그 비율에 맞게 되는
암튼 써보시고 더 좋은 팁있으면 올려주세요..
댓글