本文整理匯總了PHP中MagickWriteImage函數的典型用法代碼示例。如果您正苦於以下問題:PHP MagickWriteImage函數的具體用法?PHP MagickWriteImage怎麽用?PHP MagickWriteImage使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MagickWriteImage函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resize
function resize($source_name, $width = "", $height = "", $save_name = "")
{
$resource = NewMagickWand();
MagickReadImage($resource, $source_name);
$src_image_x = MagickGetImageWidth($resource);
$src_image_y = MagickGetImageHeight($resource);
$src_image_scale = $src_image_x / $src_image_y;
if ($width && $height) {
$new_image_x = $width;
$new_image_y = $height;
} else {
if ($width) {
$new_image_x = $width;
$new_image_y = $new_image_x * ($src_image_y / $src_image_x);
} else {
$new_image_y = $height;
$new_image_x = $new_image_y * ($src_image_x / $src_image_y);
}
}
MagickResizeImage($resource, $new_image_x, $new_image_y, MW_BoxFilter, 1);
if ($save_name) {
MagickWriteImage($resource, $save_name);
} else {
header('Content-Type: image/jpeg');
MagickEchoImageBlob($resource);
}
DestroymagickWand($resource);
}
示例2: _save
protected function _save($writePath)
{
try {
MagickSetImageColorspace($this->_resource, MW_RGBColorspace);
MagickSetCompression($this->_resource, MW_JPEGCompression);
MagickSetCompressionQuality($this->_resource, 85);
MagickSetImageFormat($this->_resource, 'jpeg');
MagickWriteImage($this->_resource, $writePath);
} catch (Exception $e) {
throw new Bbx_Media_Image_Processor_Exception('Couldn\'t write image to ' . $writePath);
}
}
示例3: watermark
public function watermark($file, $mark_image, $set)
{
$sourceWand = NewMagickWand();
$compositeWand = NewMagickWand();
MagickReadImage($compositeWand, $mark_image);
MagickReadImage($sourceWand, $file);
MagickSetImageIndex($compositeWand, 0);
MagickSetImageType($compositeWand, MW_TrueColorMatteType);
MagickEvaluateImage($compositeWand, MW_SubtractEvaluateOperator, ($set['wm_opacity'] ? $set['wm_opacity'] : 50) / 100, MW_OpacityChannel);
MagickCompositeImage($sourceWand, $compositeWand, MW_ScreenCompositeOp, $set['dest_x'], $set['dest_y']);
MagickWriteImage($sourceWand, $file);
}
示例4: makeThumbnailtoFile
function makeThumbnailtoFile($destFile)
{
$returnVal = false;
if (!$this->isWorking()) {
return false;
}
$image = NewMagickWand();
MagickReadImage($image, $this->sourceFile);
MagickSetImageCompressionQuality($image, $this->thumbQuality);
MagickThumbnailImage($image, $this->thumbWidth, $this->thumbHeight);
$returnVal = MagickWriteImage($image, $destFile);
unset($image);
return $returnVal;
}
示例5: resize_file_MagicWand
function resize_file_MagicWand(&$file, $create)
{
$image = NewMagickWand();
MagickReadImage($image, $this->upload->path . '/' . $this->orgFileName);
MagickResizeImage($image, $this->newWidth, $this->newHeight, MW_MitchellFilter, 1);
MagickSetImageCompressionQuality($image, $this->quality);
//Set the extension of the new file
$ext = $this->GetNewfileExtension();
if (file_exists($this->upload->path . '/' . $file->name . "." . $ext) and $file->name . "." . $ext != $file->fileName and $this->upload->nameConflict == "uniq") {
$file->setFileName($this->upload->createUniqName($file->name . "." . $ext));
}
if ($create == "image") {
$fileName = $file->name . "." . $ext;
@unlink($this->upload->path . '/' . $this->orgFileName);
MagickWriteImage($image, $this->upload->path . '/' . $fileName);
$file->setFileName($fileName);
} else {
if ($this->pathThumb == "") {
$this->pathThumb = $this->upload->path;
}
if ($this->naming == "suffix") {
$fileName = $file->name . $this->suffix . "." . $ext;
} else {
$fileName = $this->suffix . $file->name . "." . $ext;
}
MagickWriteImage($image, $this->pathThumb . '/' . $fileName);
$file->setThumbFileName($fileName, $this->pathThumb, $this->naming, $this->suffix);
}
DestroyMagickWand($image);
}
示例6: resize
/**
* resize an image to a specific width/height using imagemagick
* you cant set the quality of the resized image
* @param int maximum image Width (px)
* @param int maximum image Height (px)
* @param string full path of image to resize
* @param string full file path to save resized image to
* @return string output from image magick command
*/
function resize($maxWidth, $maxHeight, $origFile, $destFile)
{
$ext = $this->GetImgType($origFile);
if (!$ext) {
//false so not an image type so cant resize
// $$$ hugh - testing making thumbs for PDF's, so need a little tweak here
$originfo = pathinfo($origFile);
if (strtolower($originfo['extension']) != 'pdf') {
return;
}
}
ini_set('display_errors', true);
//see if the imagick image lib is installed
if (class_exists('Imagick')) {
// $$$ hugh - having a go at handling PDF thumbnails, which should work as long as the server
// has ghostscript (GS) installed. Don't have a generic test for GS being available, so
// it'll just fail if no GS.
$originfo = pathinfo($origFile);
if (strtolower($originfo['extension']) == 'pdf') {
$pdf_thumb_type = 'png';
// could use jpg or whatever
// OK, it's a PDF, so first we need to add the page number we want to the source filename
$pdf_file = $origFile . '[0]';
// Now check to see if the destination filename needs changing - existing code will probably
// just have used the sourcefile extension for the thumb file.
$destinfo = pathinfo($destFile);
if (strtolower($destinfo['extension']) == 'pdf') {
// rebuild $destFile with valid image extension
// NOTE - changed $destFile arg to pass by reference OOOPS can't do that!
// $$$ rob 04/08/2011 wont work in php 5.1
//$destFile = $destinfo['dirname'] . DS . $destinfo['filename'] . '.' . $pdf_thumb_type;
$thumb_file = JFile::stripExt($destFile) . '.' . $pdf_thumb_type;
}
// Now just load it, set format, resize, save and garbage collect.
// Hopefully IM will call the right delagate (ghostscript) to load the PDF.
$im = new Imagick($pdf_file);
$im->setImageFormat($pdf_thumb_type);
$im->thumbnailImage($maxWidth, $maxHeight, true);
$im->writeImage($destFile);
$im->destroy();
} else {
$im = new Imagick();
/* Read the image file */
$im->readImage($origFile);
/* Thumbnail the image ( width 100, preserve dimensions ) */
$im->thumbnailImage($maxWidth, $maxHeight, true);
/* Write the thumbail to disk */
$im->writeImage($destFile);
/* Free resources associated to the Imagick object */
$im->destroy();
}
$this->_thumbPath = $destFile;
} else {
$resource = NewMagickWand();
if (!MagickReadImage($resource, $origFile)) {
echo "ERROR!";
print_r(MagickGetException($resource));
}
$resource = MagickTransformImage($resource, '0x0', $maxWidth . 'x' . $maxWidth);
$this->_thumbPath = $destFile;
MagickWriteImage($resource, $destFile);
}
}
示例7: resizeMobile2
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;
}
示例8: liberty_magickwand_panorama_image
/**
* liberty_magickwand_panorama_image - strictly speaking, this belongs in one of the image processing plugin files, but we'll leave it here for the moment
*
* @param array $pFileHash File hash - souce_file is required
* @param array $pOptions
* @access public
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
*/
function liberty_magickwand_panorama_image(&$pFileHash, $pOptions = array())
{
$magickWand = NewMagickWand();
$pFileHash['error'] = NULL;
if (!empty($pFileHash['source_file']) && is_file($pFileHash['source_file'])) {
if (!($pFileHash['error'] = liberty_magickwand_check_error(MagickReadImage($magickWand, $pFileHash['source_file']), $magickWand))) {
// calculate border width
$iwidth = round(MagickGetImageWidth($magickWand));
$iheight = round(MagickGetImageHeight($magickWand));
$aspect = $iwidth / $iheight;
$metaHash = array('width' => $iwidth, 'height' => $iheight, 'aspect' => $aspect);
// store original file information that we can adjust the viewer
LibertyMime::storeMetaData($pFileHash['attachment_id'], 'PANO', $metaHash);
// we need to pad the image if the aspect ratio is not 2:1 (give it a wee bit of leeway that we don't add annoying borders if not really needed)
if ($aspect > 2.1 || $aspect < 1.9) {
$bwidth = $bheight = 0;
if ($aspect > 2) {
$bheight = round(($iwidth / 2 - $iheight) / 2);
} else {
$bwidth = round(($iheight / 2 - $iwidth) / 2);
}
// if the ratio has nothing to do with a panorama image - i.e. gives us a negative number here, we won't generate a panorama image
if ($bheight > 0) {
$pixelWand = NewPixelWand();
PixelSetColor($pixelWand, !empty($pOptions['background']) ? $pOptions['background'] : 'black');
if (!($pFileHash['error'] = liberty_magickwand_check_error(MagickBorderImage($magickWand, $pixelWand, $bwidth, $bheight), $magickWand))) {
if (!($pFileHash['error'] = liberty_magickwand_check_error(MagickWriteImage($magickWand, $pFileHash['source_file']), $magickWand))) {
// yay!
}
}
DestroyPixelWand($pixelWand);
}
}
}
}
DestroyMagickWand($magickWand);
return empty($pFileHash['error']);
}
示例9: liberty_magickwand_convert_colorspace_image
/**
* liberty_magickwand_convert_colorspace
*
* @param array $pFileHash
* @param string $pColorSpace - target color space, only 'grayscale' is currently supported
* @access public
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
*/
function liberty_magickwand_convert_colorspace_image(&$pFileHash, $pColorSpace)
{
$ret = FALSE;
if (!empty($pFileHash['source_file']) && is_file($pFileHash['source_file'])) {
$magickWand = NewMagickWand();
if ($error = liberty_magickwand_check_error(MagickReadImage($magickWand, $pFileHash['source_file']), $magickWand)) {
bit_error_log("MagickReadImage Failed:{$error} ( {$pFileHash['source_file']} )");
} else {
MagickRemoveImageProfile($magickWand, "ICC");
switch (strtolower($pColorSpace)) {
case 'grayscale':
if (MagickGetImageColorspace($magickWand) == MW_GRAYColorspace) {
$ret = TRUE;
} else {
MagickSetImageColorspace($magickWand, MW_GRAYColorspace);
if (empty($pFileHash['dest_file'])) {
$pFileHash['dest_file'] = STORAGE_PKG_PATH . $pFileHash['dest_branch'] . $pFileHash['name'];
}
if ($error = liberty_magickwand_check_error(MagickWriteImage($magickWand, $pFileHash['dest_file']), $magickWand)) {
bit_error_log("MagickWriteImage Failed:{$error} ( {$pFileHash['source_file']} )");
} else {
$ret = TRUE;
}
}
break;
}
}
DestroyMagickWand($magickWand);
}
return $ret;
}
示例10: PosterizeNew
function PosterizeNew()
{
$MagickWand = NewMagickWand();
MagickReadImage($MagickWand, "/home/alex/src/imws-server/app/www/turtlz.jpg");
#$e = MagickGetExceptionString($MagickWand);
#die($e);
MagickSetImageFormat($MagickWand, 'png');
MagickWriteImage($MagickWand, "/tmp/zz");
}
示例11: image_watermark
function image_watermark(&$imgmdl, $file, $set)
{
switch ($set['wm_type']) {
case 'text':
$mark_image = $set['wm_text_image'];
break;
case 'image':
$mark_image = $set['wm_image'];
break;
default:
return;
}
$mark_image = $imgmdl->fetch($mark_image);
list($watermark_width, $watermark_height, $type) = getimagesize($mark_image);
list($src_width, $src_height) = getimagesize($file);
list($dest_x, $dest_y) = self::get_watermark_dest($src_width, $src_height, $watermark_width, $watermark_height, $set['wm_loc']);
if (function_exists('NewMagickWand')) {
$sourceWand = NewMagickWand();
$compositeWand = NewMagickWand();
MagickReadImage($compositeWand, $mark_image);
MagickReadImage($sourceWand, $file);
MagickSetImageIndex($compositeWand, 0);
MagickSetImageType($compositeWand, MW_TrueColorMatteType);
MagickEvaluateImage($compositeWand, MW_SubtractEvaluateOperator, ($set['wm_opacity'] ? $set['wm_opacity'] : 50) / 100, MW_OpacityChannel);
MagickCompositeImage($sourceWand, $compositeWand, MW_ScreenCompositeOp, $dest_x, $dest_y);
MagickWriteImage($sourceWand, $file);
} elseif (method_exists(image_clip, 'imagecreatefrom')) {
$sourceimage = self::imagecreatefrom($file);
$watermark = self::imagecreatefrom($mark_image);
imagecolortransparent($watermark, imagecolorat($watermark, 0, 0));
imagealphablending($watermark, 1);
if ($type == IMAGETYPE_PNG) {
imagecopy($sourceimage, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
} else {
imagecopymerge($sourceimage, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $set['wm_opacity'] ? $set['wm_opacity'] : 100);
}
imagejpeg($sourceimage, $file);
imagedestroy($sourceimage);
imagedestroy($watermark);
}
}
示例12: image_watermark
/**
* 設置圖片水印
* @param object image 實體對象
* @param string 文件路徑
* @param array 設置的集合
* @return null
*/
function image_watermark(&$imgmdl, $file, $set)
{
switch ($set['wm_type']) {
case 'text':
$mark_image = $set['wm_text_image'];
break;
case 'image':
$mark_image = $set['wm_image'];
break;
default:
return;
}
if ($set['wm_text_preview']) {
$mark_image = $set['wm_text_image'];
} else {
$mark_image = $imgmdl->fetch($mark_image);
}
list($watermark_width, $watermark_height, $type) = getimagesize($mark_image);
list($src_width, $src_height) = getimagesize($file);
list($dest_x, $dest_y) = self::get_watermark_dest($src_width, $src_height, $watermark_width, $watermark_height, $set['wm_loc']);
if (ECAE_MODE) {
include_lib('image.php');
$obj = new ecae_image();
$obj->set_file($file);
$obj->watermark(file_get_contents($mark_image), $dest_x, $dest_y, 0, 0, $set['wm_opacity'] ? $set['wm_opacity'] : 50);
$content = $obj->exec();
if ($content) {
file_put_contents($file, $content);
}
} elseif (function_exists('NewMagickWand')) {
$sourceWand = NewMagickWand();
$compositeWand = NewMagickWand();
MagickReadImage($compositeWand, $mark_image);
MagickReadImage($sourceWand, $file);
MagickSetImageIndex($compositeWand, 0);
MagickSetImageType($compositeWand, MW_TrueColorMatteType);
MagickEvaluateImage($compositeWand, MW_SubtractEvaluateOperator, ($set['wm_opacity'] ? $set['wm_opacity'] : 50) / 100, MW_OpacityChannel);
MagickCompositeImage($sourceWand, $compositeWand, MW_ScreenCompositeOp, $dest_x, $dest_y);
MagickWriteImage($sourceWand, $file);
} elseif (method_exists(image_clip, 'imagecreatefrom')) {
$sourceimage = self::imagecreatefrom($file);
$watermark = self::imagecreatefrom($mark_image);
imagecolortransparent($watermark, imagecolorat($watermark, 0, 0));
imagealphablending($watermark, 1);
$set['wm_opacity'] = intval($set['wm_opacity']);
imagecopymerge($sourceimage, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $set['wm_opacity']);
imagejpeg($sourceimage, $file);
imagedestroy($sourceimage);
imagedestroy($watermark);
}
@unlink($mark_image);
}
示例13: image_process_magickwand
/**
* Image Process Using MagickWand
*
* This function will resize, crop or rotate
*
* @access public
* @auth John Meng
* @param string
* @return bool
*/
function image_process_magickwand($action = 'resize')
{
if (!file_exists($this->full_src_path)) {
$this->set_error("Image source file not found!");
return false;
}
if (file_exists($this->full_dst_path)) {
@unlink("{$this->full_dst_path}");
}
$magick_wand = NewMagickWand();
MagickRemoveImageProfiles($magick_wand);
MagickSetCompressionQuality($magick_wand, $this->quality);
MagickReadImage($magick_wand, $this->full_src_path);
switch ($action) {
case 'crop':
MagickCropImage($magick_wand, $this->width, $this->height, $this->x_axis, $this->y_axis);
break;
case 'rotate':
switch ($this->rotation_angle) {
case 90:
$angle = 90;
break;
case 180:
$angle = 180;
break;
case 270:
$angle = 270;
break;
case 'vrt':
$angle = 180;
break;
case 'hor':
$angle = 270;
break;
}
MagickRotateImage($magick_wand, null, $angle);
break;
case 'resize':
default:
MagickResizeImage($magick_wand, $this->width, $this->height, MW_LanczosFilter, 1.0);
break;
}
MagickWriteImage($magick_wand, $this->full_dst_path);
DestroymagickWand($magick_wand);
// Set the file to 777
@chmod($this->full_dst_path, $this->dir_write_mode);
return TRUE;
}
示例14: liberty_generate_thumbnails
/**
* liberty_generate_thumbnails
*
* @param array $pFileHash
* @access public
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
*/
function liberty_generate_thumbnails($pFileHash)
{
global $gBitSystem, $gThumbSizes;
$resizeFunc = liberty_get_function('resize');
$ret = FALSE;
// allow custom selection of thumbnail sizes
if (empty($pFileHash['thumbnail_sizes'])) {
if (!empty($gThumbSizes) && is_array($gThumbSizes)) {
$pFileHash['thumbnail_sizes'] = array_keys($gThumbSizes);
} else {
$pFileHash['thumbnail_sizes'] = array('large', 'medium', 'small', 'avatar', 'icon');
}
}
if (!preg_match('#image/(gif|jpe?g|png)#i', $pFileHash['type']) && $gBitSystem->isFeatureActive('liberty_jpeg_originals') || in_array('original', $pFileHash['thumbnail_sizes'])) {
// jpeg version of original
if (preg_match('/pdf/i', $pFileHash['type'])) {
// has a customer pdf rasterization function been defined?
if (function_exists('liberty_rasterize_pdf') && ($rasteredFile = liberty_rasterize_pdf($pFileHash['source_file']))) {
$pFileHash['source_file'] = $rasteredFile;
} else {
$magickWand = NewMagickWand();
if (!($pFileHash['error'] = liberty_magickwand_check_error(MagickReadImage($magickWand, $pFileHash['source_file']), $magickWand))) {
MagickSetFormat($magickWand, 'JPG');
if (MagickGetImageColorspace($magickWand) == MW_CMYKColorspace) {
MagickProfileImage($magickWand, "ICC", UTIL_PKG_PATH . 'icc/srgb.icm');
MagickSetImageColorspace($magickWand, MW_sRGBColorspace);
}
$imgWidth = MagickGetImageWidth($magickWand);
$imgHeight = MagickGetImageHeight($magickWand);
MagickSetImageUnits($magickWand, MW_PixelsPerInchResolution);
MagickSetResolution($magickWand, 300, 300);
$rasteredFile = dirname($pFileHash['source_file']) . '/original.jpg';
if (!($pFileHash['error'] = liberty_magickwand_check_error(MagickWriteImage($magickWand, $rasteredFile), $magickWand))) {
$pFileHash['source_file'] = $rasteredFile;
}
}
}
} else {
$pFileHash['dest_base_name'] = 'original';
$pFileHash['name'] = 'original.jpg';
$pFileHash['max_width'] = MAX_THUMBNAIL_DIMENSION;
$pFileHash['max_height'] = MAX_THUMBNAIL_DIMENSION;
if ($convertedFile = $resizeFunc($pFileHash)) {
$pFileHash['source_file'] = $convertedFile;
$ret = TRUE;
}
}
$pFileHash['type'] = $gBitSystem->verifyMimeType($pFileHash['source_file']);
}
// override $mimeExt if we have a custom setting for it
if ($gBitSystem->isFeatureActive('liberty_thumbnail_format')) {
$mimeExt = $gBitSystem->getConfig('liberty_thumbnail_format');
} else {
list($type, $mimeExt) = preg_split('#/#', strtolower($pFileHash['type']));
}
if (preg_match("!(png|gif)!", $mimeExt)) {
$destExt = '.' . $mimeExt;
} else {
$destExt = '.jpg';
}
$initialDestPath = $pFileHash['dest_branch'];
foreach ($pFileHash['thumbnail_sizes'] as $thumbSize) {
if (isset($gThumbSizes[$thumbSize])) {
$pFileHash['dest_base_name'] = $thumbSize;
$pFileHash['name'] = $thumbSize . $destExt;
if (!empty($gThumbSizes[$thumbSize]['width'])) {
$pFileHash['max_width'] = $gThumbSizes[$thumbSize]['width'];
} else {
// Have to unset since we reuse $pFileHash
unset($pFileHash['max_width']);
}
// reset dest_branch for created thumbs
if (!empty($pFileHash['thumb_path'])) {
$pFileHash['dest_file'] = $pFileHash['thumb_path'] . $pFileHash['name'];
} else {
// create a subdirectory for the thumbs
$pFileHash['dest_branch'] = $initialDestPath . 'thumbs/';
clearstatcache();
if (!is_dir(STORAGE_PKG_PATH . $pFileHash['dest_branch'])) {
mkdir(STORAGE_PKG_PATH . $pFileHash['dest_branch'], 0775, TRUE);
clearstatcache();
}
}
if (!empty($gThumbSizes[$thumbSize]['height'])) {
$pFileHash['max_height'] = $gThumbSizes[$thumbSize]['height'];
} else {
// Have to unset since we reuse $pFileHash
unset($pFileHash['max_height']);
}
if ($pFileHash['icon_thumb_path'] = $resizeFunc($pFileHash)) {
$ret = TRUE;
// use the previous thumb as the source for the next, decreasingly smaller thumb as this GREATLY increases speed
$pFileHash['source_file'] = $pFileHash['icon_thumb_path'];
//.........這裏部分代碼省略.........
示例15: savefile
function savefile($src_image_type, $src_image)
{
if ($this->save_file) {
MagickWriteImage($src_image, $this->save_file);
} else {
switch ($src_image_type) {
case 1:
header("Content-type: image/gif");
MagickEchoImageBlob($src_image);
break;
case 2:
header("Content-type: image/jpeg");
MagickEchoImageBlob($src_image);
break;
case 3:
header("Content-type: image/png");
MagickEchoImageBlob($src_image);
break;
case 6:
header("Content-type: image/bmp");
MagickEchoImageBlob($src_image);
break;
default:
header("Content-type: image/jpeg");
MagickEchoImageBlob($src_image);
break;
}
}
}