當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Imagick::writeImage方法代碼示例

本文整理匯總了PHP中Imagick::writeImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::writeImage方法的具體用法?PHP Imagick::writeImage怎麽用?PHP Imagick::writeImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Imagick的用法示例。


在下文中一共展示了Imagick::writeImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: IMAGEN_tipo_normal

function IMAGEN_tipo_normal()
{
    $escalado = 'IMG/i/m/' . $_GET['ancho'] . '_' . $_GET['alto'] . '_' . $_GET['sha1'];
    $origen = 'IMG/i/' . $_GET['sha1'];
    $ancho = $_GET['ancho'];
    $alto = $_GET['alto'];
    if (@($ancho * $alto) > 562500) {
        die('La imagen solicitada excede el límite de este servicio');
    }
    if (!file_exists($escalado)) {
        $im = new Imagick($origen);
        $im->setCompression(Imagick::COMPRESSION_JPEG);
        $im->setCompressionQuality(85);
        $im->setImageFormat('jpeg');
        $im->stripImage();
        $im->despeckleImage();
        $im->sharpenImage(0.5, 1);
        //$im->reduceNoiseImage(0);
        $im->setInterlaceScheme(Imagick::INTERLACE_PLANE);
        $im->resizeImage($ancho, $alto, imagick::FILTER_LANCZOS, 1);
        $im->writeImage($escalado);
        $im->destroy();
    }
    $im = new Imagick($escalado);
    $output = $im->getimageblob();
    $outputtype = $im->getFormat();
    $im->destroy();
    header("Content-type: {$outputtype}");
    header("Content-length: " . filesize($escalado));
    echo $output;
}
開發者ID:vlad88sv,項目名稱:360,代碼行數:31,代碼來源:imagen.php

示例2: mkbilder

 function mkbilder()
 {
     $this->err->write('mkbilder', 'IN');
     if (!class_exists("Imagick")) {
         $this->err->out("Imagick-Extention nicht installiert", true);
         return false;
     }
     $handle = new Imagick();
     if (!$handle->readImage("./tmp/tmp.file_org")) {
         return false;
     }
     $d = $handle->getImageGeometry();
     if ($d["width"] < $d["height"]) {
         $faktor = $d["height"] / $d["width"];
     } else {
         $faktor = $d["width"] / $d["height"];
     }
     $thumbheight = floor($this->thumbwidth * $faktor);
     $handle->thumbnailImage($this->thumbwidth, $thumbheight);
     $rc = $handle->writeImage("./tmp/tmp.file_thumb");
     $handle->readImage("./tmp/tmp.file_org");
     $popupheight = floor($this->popupwidth * $faktor);
     $handle->thumbnailImage($this->popupwidth, $popupheight);
     $rc = $handle->writeImage("./tmp/tmp.file_popup");
     $handle->readImage("./tmp/tmp.file_org");
     $infoheight = floor($this->infowidth * $faktor);
     $handle->thumbnailImage($this->infowidth, $infoheight);
     $rc = $handle->writeImage("./tmp/tmp.file_info");
     return $rc;
 }
開發者ID:vanloswang,項目名稱:kivitendo-crm,代碼行數:30,代碼來源:PictureXTC.php

示例3: index

 public function index()
 {
     $ps = array();
     $user = $this->session->all_userdata();
     if (isset($_POST['submit']) && isset($user) && isset($user['users_id']) && isset($_FILES['uploaded_image']['tmp_name'])) {
         $imageFile = time() . '.' . end(explode(".", $_FILES['uploaded_image']['name']));
         $photoData = $_POST['photo'];
         $image = new Imagick($_FILES['uploaded_image']['tmp_name']);
         $height = $image->getImageHeight();
         $width = $image->getImageWidth();
         if ($width > 800 || $height > 800) {
             if ($height < $width) {
                 $image->scaleImage(800, 0);
             } else {
                 $image->scaleImage(0, 600);
             }
         }
         $image->writeImage('./storage/photos/b/' . $imageFile);
         $image->cropThumbnailImage(100, 100);
         $image->writeImage('./storage/thumbs/' . $imageFile);
         $ps['photo_b'] = '/storage/photos/b/' . $imageFile;
         $ps['thumb'] = '/storage/thumbs/' . $imageFile;
         $data = array('iname' => $photoData['iname'] ? $photoData['iname'] : 'noname', 'idesc' => $photoData['idesc'] ? $photoData['idesc'] : '', 'path' => '/storage/photos/', 'file' => $imageFile, 'thumb' => $ps['thumb'], 'add_date' => time(), 'allow_comments' => isset($photoData['allow_comments']) ? 1 : 0, 'users_id' => $user['users_id']);
         $this->db->insert('photos', $data);
         $photos_id = $this->db->insert_id();
         $this->load->model('m_users');
         $this->load->model('m_logs');
         $this->m_users->update(array('num_photos' => $user['num_photos'] + 1), $user['users_id']);
         $this->m_logs->add(array('users_id' => $user['users_id'], 'action' => 1, 'object_type' => 2, 'object_id' => $photos_id));
     }
     $ps['_activeMenu'] = 'upload';
     $this->tpl->view('frontend/upload/', $ps);
 }
開發者ID:randix0,項目名稱:DEVils,代碼行數:33,代碼來源:uploader.php

示例4: save

 function save($file_name = null, $quality = null)
 {
     $type = $this->out_type;
     if (!$type) {
         $type = $this->img_type;
     }
     if (!self::supportSaveType($type)) {
         throw new lmbImageTypeNotSupportedException($type);
     }
     $this->img->setImageFormat($type);
     $this->img->setImageFilename($file_name);
     if (!is_null($quality) && strtolower($type) == 'jpeg') {
         if (method_exists($this->img, 'setImageCompression')) {
             $this->img->setImageCompression(imagick::COMPRESSION_JPEG);
             $this->img->setImageCompressionQuality($quality);
         } else {
             $this->img->setCompression(imagick::COMPRESSION_JPEG);
             $this->img->setCompressionQuality($quality);
         }
     }
     if (!$this->img->writeImage($file_name)) {
         throw new lmbImageSaveFailedException($file_name);
     }
     $this->destroyImage();
 }
開發者ID:snowjobgit,項目名稱:limb,代碼行數:25,代碼來源:lmbImImageContainer.class.php

示例5: save

 /**
  * @see Fizzy_Image_Adapter_Interface
  */
 public function save($destination)
 {
     //if(!is_writable($destination)) {
     //    throw new Fizzy_Image_Exception("Destination '{$destination}' is not writable.");
     //}
     $this->_image->writeImage($destination);
     return $this;
 }
開發者ID:jtietema,項目名稱:Fizzy,代碼行數:11,代碼來源:ImageMagick.php

示例6: save

 /**
  * @param  $path
  */
 public function save($path, $format = null, $quality = null)
 {
     if (!$format) {
         $format = "png";
     }
     $this->resource->stripimage();
     $this->resource->setImageFormat($format);
     if ($quality) {
         $this->resource->setCompressionQuality((int) $quality);
         $this->resource->setImageCompressionQuality((int) $quality);
     }
     $this->resource->writeImage($path);
     return $this;
 }
開發者ID:nblackman,項目名稱:pimcore,代碼行數:17,代碼來源:Imagick.php

示例7: apply

 /**
  * {@inheritDoc}
  */
 public function apply($absolutePath)
 {
     $info = pathinfo($absolutePath);
     if (isset($info['extension']) && false !== strpos(strtolower($info['extension']), 'pdf')) {
         // If it doesn't exists, extract the first page of the PDF
         if (!file_exists("{$absolutePath}.png")) {
             $this->imagick->readImage($absolutePath . '[0]');
             $this->imagick->setImageFormat('png');
             $this->imagick->writeImage("{$absolutePath}.png");
             $this->imagick->clear();
         }
         $absolutePath .= '.png';
     }
     return $absolutePath;
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:18,代碼來源:PdfTransformer.php

示例8: Imagick

 function imagick_thumbnail($image, $timage, $ext, $thumbnail_name, $imginfo)
 {
     try {
         $imagick = new Imagick();
         $fullpath = "./" . $this->thumbnail_path . "/" . $timage[0] . "/" . $thumbnail_name;
         if ($ext == "gif") {
             $imagick->readImage($image . '[0]');
         } else {
             $imagick->readImage($image);
         }
         $info = $imagick->getImageGeometry();
         $this->info[0] = $info['width'];
         $this->info[1] = $info['height'];
         $imagick->thumbnailImage($this->dimension, $this->dimension, true);
         if ($ext == "png" || $ext == "gif") {
             $white = new Imagick();
             $white->newImage($this->dimension, $this->dimension, "white");
             $white->compositeimage($image, Imagick::COMPOSITE_OVER, 0, 0);
             $white->writeImage($fullpath);
             $white->clear();
         } else {
             $imagick->writeImage($fullpath);
         }
         $imagick->clear();
     } catch (Exception $e) {
         echo "Unable to load image." . $e->getMessage();
         return false;
     }
     return true;
 }
開發者ID:logtcn,項目名稱:gelbooru-fork,代碼行數:30,代碼來源:image.class.php

示例9: write

 /**
  * Write current image to a file
  *
  * @param string $file (OPTIONAL) The file to write to. Default: original file
  * @param string $type (OPTIONAL) The output image type. Default: jpeg
  * @return Engine_Image_Adapter_Gd
  * @throws Engine_Image_Adapter_Exception If unable to write
  */
 public function write($file = null, $type = 'jpeg')
 {
     $this->_checkOpenImage();
     // Set file type
     if ($type == 'jpg') {
         $type = 'jpeg';
     }
     $type = strtoupper($type);
     if ($type !== $this->_resource->getImageFormat()) {
         $this->_resource->setImageFormat($type);
     }
     // Set quality
     if (null !== $this->_quality) {
         $this->_resource->setImageCompressionQuality($this->_quality);
     }
     // Write
     if (null === $file) {
         $return = $this->_resource->writeImage();
     } else {
         $return = $this->_resource->writeImage($file);
     }
     // Error
     if (!$return) {
         if (!$file) {
             $file = $this->_resource->getImageFilename();
         }
         throw new Engine_Image_Adapter_Exception(sprintf('Unable to write image to file "%s"', $file));
     }
     return $this;
 }
開發者ID:febryantosulistyo,項目名稱:ClassicSocial,代碼行數:38,代碼來源:Imagick.php

示例10: makeThumb

 public function makeThumb($path, $W = NULL, $H = NULL)
 {
     $image = new Imagick();
     $image->readImage($ImgSrc);
     // Trasformo in RGB solo se e` il CMYK
     if ($image->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
         $image->transformImageColorspace(Imagick::COLORSPACE_RGB);
     }
     $image->profileImage('*', NULL);
     $image->stripImage();
     $imgWidth = $image->getImageWidth();
     $imgHeight = $image->getImageHeight();
     if ((!$H || $H == null || $H == 0) && (!$W || $W == null || $W == 0)) {
         $W = $imgWidth;
         $H = $imgHeight;
     } elseif (!$H || $H == null || $H == 0) {
         $H = $W * $imgHeight / $imgWidth;
     } elseif (!$W || $W == null || $W == 0) {
         $W = $H * $imgWidth / $imgHeight;
     }
     $image->resizeImage($W, $H, Imagick::FILTER_LANCZOS, 1);
     /** Scrivo l'immagine */
     $image->writeImage($path);
     /** IMAGE OUT */
     header('X-MHZ-FLY: Nice job!');
     header(sprintf('Content-type: image/%s', strtolower($image->getImageFormat())));
     echo $image->getImageBlob();
     $image->destroy();
     die;
 }
開發者ID:andreaganduglia,項目名稱:dpr-detector,代碼行數:30,代碼來源:image_processor.php

示例11: createMissingThumbsAction

 public function createMissingThumbsAction()
 {
     $this->initCommonParams($this->getRequest());
     $this->outputMessage('[light_cyan]Creating missing thumbs.');
     $dbAdapter = $this->getServiceLocator()->get('dbAdapter');
     $apartments = $dbAdapter->createStatement('
     SELECT ai.*, a.`name`
     FROM `ga_apartment_images` ai LEFT JOIN `ga_apartments` a
       ON ai.`apartment_id` = a.`id`
     ')->execute();
     foreach ($apartments as $apartment) {
         $this->outputMessage('[cyan]Looking into [light_blue]' . $apartment['name'] . '[cyan] images...');
         for ($i = 1; $i <= 32; $i++) {
             if ($apartment['img' . $i]) {
                 $imgPathComponents = explode('/', $apartment['img' . $i]);
                 $originalFileName = array_pop($imgPathComponents);
                 $originalFilePath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_APARTMENT . $apartment['apartment_id'] . '/' . $originalFileName;
                 $thumbFilePath = str_replace('_orig.', '_555.', $originalFilePath);
                 if (!file_exists($originalFilePath)) {
                     $this->outputMessage('[error] Original file for image ' . $i . ' is missing.');
                 } else {
                     if (file_exists($thumbFilePath)) {
                         $this->outputMessage('[light_blue] Thumb for image ' . $i . ' exists.');
                     } else {
                         $thumb = new \Imagick($originalFilePath);
                         $thumb->resizeImage(555, 370, \Imagick::FILTER_LANCZOS, 1);
                         $thumb->writeImage($thumbFilePath);
                         $this->outputMessage('[success] Added thumb for image ' . $i);
                     }
                 }
             }
         }
     }
     $this->outputMessage('Done!');
 }
開發者ID:arbi,項目名稱:MyCode,代碼行數:35,代碼來源:OneTimeController.php

示例12: upload_image

function upload_image($arr_image, $location, $compression = null, $width = 245, $height = 170)
{
    $image_location = "";
    $allowedExts = array("gif", "jpeg", "jpg", "png", "JPG", "JPEG", "GIF", "PNG", "pdf", "PDF");
    $temp = explode(".", $arr_image["file"]["name"]);
    $extension = end($temp);
    if (($arr_image["file"]["type"] == "image/gif" || $arr_image["file"]["type"] == "image/jpeg" || $arr_image["file"]["type"] == "image/jpg" || $arr_image["file"]["type"] == "image/pjpeg" || $arr_image["file"]["type"] == "image/x-png" || $arr_image["file"]["type"] == "image/png") && $arr_image["file"]["size"] < 1024 * 1000 * 10 && in_array($extension, $allowedExts)) {
        if ($arr_image["file"]["error"] > 0) {
            echo "Return Code: " . $arr_image["file"]["error"] . "<br>";
        } else {
            $compression_type = Imagick::COMPRESSION_JPEG;
            $image_location = $location . "." . $extension;
            if (move_uploaded_file($arr_image["file"]["tmp_name"], $image_location)) {
                //echo "Image Uploaded to : ".$image_location;
            } else {
                //echo "Image not uploaded";
            }
            if (is_null($compression)) {
                $im = new Imagick($image_location);
                $im->setImageFormat('jpg');
                $im->setImageCompression($compression_type);
                $im->setImageCompressionQuality(95);
                $im->stripImage();
                $im->thumbnailImage($width, $height);
                $image_location = $location . ".jpg";
                $im->writeImage($image_location);
            }
        }
    }
    return $image_location;
}
開發者ID:dturakhia,項目名稱:ryametrostar,代碼行數:31,代碼來源:upload.php

示例13: save

 /**
  * {@inheritdoc}
  */
 public function save($file, $quality = 95)
 {
     // Set image quality
     $this->image->setImageCompressionQuality($quality);
     // Save image
     $this->image->writeImage($file);
 }
開發者ID:muhammetardayildiz,項目名稱:framework,代碼行數:10,代碼來源:ImageMagick.php

示例14: save

 protected function save($path)
 {
     $pathinfo = pathinfo($path);
     if (!file_exists($pathinfo['dirname'])) {
         mkdir($pathinfo['dirname'], 0777, true);
     }
     try {
         $image = new \Imagick($this->source);
         $image->thumbnailImage($this->width, $this->height, true);
         if ($this->color) {
             $thumb = $image;
             $image = new \Imagick();
             $image->newImage($this->width, $this->height, $this->color, $pathinfo['extension']);
             $size = $thumb->getImageGeometry();
             $x = ($this->width - $size['width']) / 2;
             $y = ($this->height - $size['height']) / 2;
             $image->compositeImage($thumb, \imagick::COMPOSITE_OVER, $x, $y);
             $thumb->destroy();
         }
         $image->writeImage($path);
         $image->destroy();
     } catch (\Exception $e) {
     }
     return $this;
 }
開發者ID:disdain,項目名稱:thumb,代碼行數:25,代碼來源:Thumb.php

示例15: crop

 public function crop(ImageInterface $image, Size $sizeDest, Point $cropIniPoint = null, $middleCrop = true)
 {
     $imagick = new \Imagick($image->getPath());
     $widthSrc = $imagick->getImageWidth();
     $heightSrc = $imagick->getImageHeight();
     $widthDest = $sizeDest->getWidth();
     $heightDest = $sizeDest->getHeight();
     $cropX = 0;
     $cropY = 0;
     if ($middleCrop) {
         $cropX = ($widthSrc - $widthDest) / 2;
         $cropY = ($heightSrc - $heightDest) / 2;
     } else {
         if (isset($cropIniPoint)) {
             $cropX = $cropIniPoint->getX();
             $cropY = $cropIniPoint->getY();
         }
     }
     $imagick = new \Imagick($image->getPath());
     $imagick->cropImage($widthDest, $heightDest, $cropX, $cropY);
     $addToName = "_croped_" . $widthDest . "x" . $heightDest;
     list($name, $extension) = explode(".", $image->getOriginalName());
     list($path, $extension) = explode(".", $image->getPath());
     $newPath = $path . $addToName . "." . $extension;
     $newName = $name . $addToName . "." . $extension;
     $newImageSize = new Size($imagick->getImageWidth(), $imagick->getImageHeight());
     $imagick->writeImage($newPath);
     return $this->ImagickToImage($imagick, $image, $newPath, $newName, $newImageSize);
 }
開發者ID:vzaramel,項目名稱:Arkivar,代碼行數:29,代碼來源:ImagickImageManipulator.php


注:本文中的Imagick::writeImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。