function makeThumbWatermark($objWidth = 128, $objHeight = 128) { $this->fileCheck(); $image_info = $this->getInfo($this->src_image_name); if (!$image_info) { return false; } $src_image_type = $image_info["type"]; $objWidth = $objWidth == 0 ? $image_info["width"] : $objWidth; $objHeight = $objHeight == 0 ? $image_info["height"] : $objHeight; $objWidth = $objWidth > $image_info["width"] ? $image_info["width"] : $objWidth; $objHeight = $objHeight > $image_info["height"] ? $image_info["height"] : $objHeight; $thumb = $this->createThumb($objWidth, $objHeight); $thumbwm = $this->createWaterMark($thumb); $this->savefile($src_image_type, $thumbwm); ClearMagickWand($thumbwm); return true; }
function resizeMobile2($src_path, $dest_path, $d_width, $d_height) { $mk = NewMagickWand(); if (!MagickPingImage($mk, $src_path)) { echo "magick wand - no image \n"; $format = sprintf("convert %s -resize %dx%d -colors 256 -quality 90 -depth 8 %s", $src_path, $destWidth, $destHeight, $dest_path); $buffer = ""; exec($format, $buffer); return false; } // Now we need to clear out the data that MagickPingImage() put there ClearMagickWand($mk); if (MagickReadImage($mk, $src_path)) { list($srcWidth, $srcHeight, $destWidth, $destHeight) = getRate($src_path, $d_width, $d_height); //소스 이미지를 읽어서 $mk = MagickTransformImage($mk, NULL, $destWidth . "x" . $destHeight); MagickSetImageCompressionQuality($mk, 90); MagickSetImageDepth($mk, 8); //MagickSetImageIndex($mk, 256); MagickProfileImage($mk, "*", ""); MagickQuantizeImage($mk, 256, MW_RGBColorspace, 0, true, false); //$chk = MagickResizeImage($mk, $destWidth, $destHeight); //echo "$src_path , $dest_path, $destWidth, $destHeight \n"; // 이미지를 리사이징해라. 가로 $w 세로 $h //MagickResizeImage() 이라는 함수도 있는데 위의 것이 더 범용적입니다. if ($mk == null) { //echo "this is convert"; $format = sprintf("convert %s -resize %dx%d -colors 256 -quality 90 -depth 8 %s", $src_path, $destWidth, $destHeight, $dest_path); $buffer = ""; exec($format, $buffer); //echo "object is null \n"; return true; } MagickWriteImage($mk, $dest_path); // 새로운 이미지를 만들어라~ ClearMagickWand($mk); } else { echo "magick wand - read fail \n"; return false; } return true; }