当前位置: 首页>>代码示例>>PHP>>正文


PHP MagickReadImage函数代码示例

本文整理汇总了PHP中MagickReadImage函数的典型用法代码示例。如果您正苦于以下问题:PHP MagickReadImage函数的具体用法?PHP MagickReadImage怎么用?PHP MagickReadImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MagickReadImage函数的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);
 }
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:28,代码来源:ImageMagickUtility.class.php

示例2: makeGifFromZip

 public static function makeGifFromZip($zip_file_path, $delay)
 {
     $dir = $zip_file_path . 'dir/';
     $zip = new ZipArchive();
     $res = $zip->open($zip_file_path);
     if ($res === TRUE) {
         $zip->extractTo($dir);
         $zip->close();
     }
     $files = glob($dir . '/*');
     ksort($files);
     $mw = NewMagickWand();
     for ($i = 0, $l = count($files); $i < $l; $i++) {
         $rw = NewMagickWand();
         MagickReadImage($rw, $files[$i]);
         MagickSetImageDelay($rw, intval($delay) / 10);
         //magickwand比较特殊,>用的不是毫秒,所以毫秒需要转成1/100秒
         MagickAddImage($mw, $rw);
         DestroyMagickWand($rw);
     }
     MagickSetFormat($mw, 'gif');
     $gif_file_path = $zip_file_path . '.gif';
     MagickWriteImages($mw, $gif_file_path, true);
     DestroyMagickWand($mw);
     //todo 删除目录
     return $gif_file_path;
 }
开发者ID:sinkcup,项目名称:choose-api,代码行数:27,代码来源:ImgLib.php

示例3: prepare

 /**
  * @return Uploader
  */
 public function prepare()
 {
     if (is_array($this->session)) {
         $this->digital = (string) $this->session['digital'];
         $this->public = (bool) $this->session['fg_publico'];
     } else {
         throw new Exception('Não foi possível recuperar os dados da sessão!');
     }
     if ($this->_isFile()) {
         $this->hash = (string) hash_file('md5', $this->file["tmp_name"]);
         $this->type = (string) substr($this->file["name"], -3);
         $this->size = (int) $this->file["size"];
         try {
             MagickReadImage($object = NewMagickWand(), $this->file["tmp_name"]);
             $this->width = MagickGetImageWidth($object);
             $this->height = MagickGetImageHeight($object);
             $this->codeType = MagickGetImageFormat($object);
             $this->sizeBytes = MagickGetImageSize($object);
             $this->compression = MagickGetImageCompression($object);
             $this->compressionQuality = MagickGetImageCompressionQuality($object);
             $this->resolution = MagickGetImageResolution($object);
             $this->resolutionUnits = MagickGetImageUnits($object);
         } catch (Exception $e) {
             throw new Exception('Ocorreu um erro!');
         }
     } else {
         throw new Exception('O arquivo está ausente!');
     }
     return $this;
 }
开发者ID:roquebrasilia,项目名称:sgdoc-codigo,代码行数:33,代码来源:Uploader.php

示例4: load

 public function load($sourcePath)
 {
     parent::load($sourcePath);
     $this->_getResource();
     try {
         MagickReadImage($this->_resource, $sourcePath);
     } catch (Exception $e) {
         throw new Bbx_Media_Image_Processor_Exception('Failed to load image ' . $sourcePath);
     }
 }
开发者ID:rdallasgray,项目名称:bbx,代码行数:10,代码来源:Magickwand.php

示例5: 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);
 }
开发者ID:yindonghai,项目名称:msk.com,代码行数:12,代码来源:magickwand.php

示例6: 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;
 }
开发者ID:RicterZ,项目名称:pixmicat,代码行数:14,代码来源:thumb.magickwand.php

示例7: getImgWand

 public function getImgWand($resource = "", $size = array())
 {
     $result = NewMagickWand();
     if (count($size) == 2) {
         MagickSetWandSize($result, $size[0], $size[1]);
     }
     if (IsMagickWand($resource)) {
         $result = CloneMagickWand($resource);
     } elseif (is_array($resource) && count($resource) == 3) {
         MagickNewImage($result, $resource[1], $resource[2], $resource[0]);
     } elseif (!empty($resource)) {
         MagickReadImage($result, $resource);
     }
     return $result;
 }
开发者ID:laiello,项目名称:mystep-cms,代码行数:15,代码来源:magickwand.class.php

示例8: 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;
}
开发者ID:kailIII,项目名称:liberty,代码行数:39,代码来源:processor.magickwand.php

示例9: _import_MagickWand

 /**
  * Imports the given file using the MagickWand extension if possible. (Internal only)
  * @param SloodleModulePresenter $presenter An object representing the Presenter we are importing into.
  * @param string $srcfile Full path of the PDF file we are importing
  * @param string $destpath Folder path to which the imported files will be added.
  * @param string $viewurl URL of the folder in which the imported files will be viewed
  * @param string $destfile Name for the output files (excluding extension, such as .jpg). The page numbers will be appended automatically, before the extension
  * @param string $destfileext Extension for destination files, not including the dot. (e.g. "jpg" or "png").
  * @param string $destname Basic name to use for each imported slide. The page numbers will be appended automatically.
  * @param integer $position The position within the Presentation to add the new slides. Optional. Default is to put them at the end.
  * @return integer|bool If successful, an integer indicating the number of slides loaded is displayed. If the import does not (or cannot) work, then boolean false is returned.
  * @access private
  */
 function _import_MagickWand($presenter, $srcfile, $destpath, $viewurl, $destfile, $destfileext, $destname, $position = -1)
 {
     global $CFG;
     // Only continue if the MagickWand extension is loaded (this is done by the check_compatibility function)
     if (!extension_loaded('magickwand')) {
         return false;
     }
     // Load the PDF file
     sloodle_debug('Loading PDF file... ');
     $mwand = NewMagickWand();
     if (!MagickReadImage($mwand, $srcfile)) {
         sloodle_debug('failed.<br/>');
         return false;
     }
     sloodle_debug('OK.<br/>');
     // Quick validation - position should start at 1. (-ve numbers mean "at the end")
     if ($position == 0) {
         $position = 1;
     }
     // Go through each page
     sloodle_debug('Preparing to iterate through pages of document...<br/>');
     MagickSetFirstIterator($mwand);
     $pagenum = 0;
     $page_position = -1;
     do {
         // Determine this page's position in the Presentation
         if ($position > 0) {
             $page_position = $position + $pagenum;
         }
         $pagenum++;
         // Construct the file and slide names for this page
         $page_filename = "{$destpath}/{$destfile}-{$pagenum}.{$destfileext}";
         // Where it gets uploaded to
         $page_slidesource = "{$viewurl}/{$destfile}-{$pagenum}.{$destfileext}";
         // The URL to access it publicly
         $page_slidename = "{$destname} ({$pagenum})";
         // Output the file
         sloodle_debug(" Writing page {$pagenum} to file...");
         if (!MagickWriteImage($mwand, $page_filename)) {
             sloodle_debug('failed.<br/>');
         } else {
             sloodle_debug('OK.<br/>');
         }
         // Add the entry to the Presenter
         sloodle_debug("  Adding slide \"{$page_slidename}\" to presentation at position {$page_position}... ");
         if (!$presenter->add_entry($page_slidesource, 'image', $page_slidename, $page_position)) {
             sloodle_debug('failed.<br/>');
         } else {
             sloodle_debug('OK.<br/>');
         }
     } while (MagickNextImage($mwand));
     sloodle_debug('Finished.<br/>');
     DestroyMagickWand($mwand);
     return $pagenum;
 }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:68,代码来源:pdfimporter.php

示例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");
 }
开发者ID:rchicoria,项目名称:epp-drs,代码行数:9,代码来源:class.PhotoFilter.php

示例11: resize

 /**
  * Resize an image to a specific width/height
  *
  * @param   int    $maxWidth  maximum image Width (px)
  * @param   int    $maxHeight maximum image Height (px)
  * @param   string $origFile  current images folder path (must have trailing end slash)
  * @param   string $destFile  destination folder path for resized image (must have trailing end slash)
  * @param   int    $quality   Percentage image save quality 100 = no compression, 0 = max compression
  *
  * @return  object  image
  */
 public function resize($maxWidth, $maxHeight, $origFile, $destFile, $quality = 100)
 {
     $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 (JString::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 (JString::strtolower($origInfo['extension']) == 'pdf') {
             $pdfThumbType = 'png';
             // OK, it's a PDF, so first we need to add the page number we want to the source filename
             $pdfFile = $origFile . '[0]';
             if (is_callable('exec')) {
                 $destFile = str_replace('.pdf', '.png', $destFile);
                 // Output File
                 $convert = "convert " . $pdfFile . "  -colorspace RGB -resize " . $maxWidth . " " . $destFile;
                 // Command creating
                 exec($convert);
                 // Execution of complete command.
             } else {
                 // Now just load it, set format, resize, save and garbage collect.
                 // Hopefully IM will call the right delegate (ghostscript) to load the PDF.
                 $im = new Imagick($pdfFile);
                 $im->setImageFormat($pdfThumbType);
                 $im->thumbnailImage($maxWidth, $maxHeight, true);
                 $im->writeImage($destFile);
                 // as destroy() is deprecated
                 $im->clear();
             }
         } 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 thumbnail 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);
     }
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:74,代码来源:image.php

示例12: 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'];
//.........这里部分代码省略.........
开发者ID:bitweaver,项目名称:liberty,代码行数:101,代码来源:liberty_lib.php

示例13: 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);
 }
开发者ID:voguegroup,项目名称:moxhullmc,代码行数:30,代码来源:incResize.php

示例14: 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);
 }
开发者ID:syjzwjj,项目名称:quyeba,代码行数:59,代码来源:clip.php

示例15: 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;
 }
开发者ID:akswosn,项目名称:tossi,代码行数:42,代码来源:ImageProcess.php


注:本文中的MagickReadImage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。