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


PHP Imagick::setCompressionQuality方法代碼示例

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


在下文中一共展示了Imagick::setCompressionQuality方法的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: save

 /**
  * Saves the image to a file
  *
  * @param $filename string the name of the file to write to
  *
  * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
  * @access public
  */
 function save($filename, $type = '', $quality = null)
 {
     $options = is_array($quality) ? $quality : array();
     if (is_numeric($quality)) {
         $options['quality'] = $quality;
     }
     $quality = $this->_getOption('quality', $options, 75);
     // PIMCORE_MODIFICATION
     $this->imagick->setCompressionQuality($quality);
     $this->imagick->setImageCompressionQuality($quality);
     if ($type && strcasecmp($type, $this->type)) {
         try {
             $this->imagick->setImageFormat($type);
         } catch (ImagickException $e) {
             return $this->raiseError('Could not save image to file (conversion failed).', IMAGE_TRANSFORM_ERROR_FAILED);
         }
     }
     try {
         $this->imagick->writeImage($filename);
     } catch (ImagickException $e) {
         return $this->raiseError('Could not save image to file: ' . $e->getMessage(), IMAGE_TRANSFORM_ERROR_IO);
     }
     if (!$this->keep_settings_on_save) {
         $this->free();
     }
     return true;
 }
開發者ID:shanky0110,項目名稱:pimcore-custom,代碼行數:35,代碼來源:Imagick3.php

示例3: run

 public function run($file, $temp_dir)
 {
     $info = $this->getImageDetails($file);
     $image = new Imagick();
     $image->readImage($file);
     if ($info['ext'] == 'jpg') {
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setCompressionQuality($this->settings['quality']);
         $image->setImageFormat('jpeg');
     }
     if ($info['ext'] == 'gif') {
         //remove the canvas (for .gif)
         $image->setImagePage(0, 0, 0, 0);
     }
     //crop and resize the image
     $image->resizeImage($this->settings['width'], $this->settings['height'], Imagick::FILTER_LANCZOS, 1, true);
     $image->writeImage($file);
     return TRUE;
 }
開發者ID:ayuinc,項目名稱:laboratoria-v2,代碼行數:19,代碼來源:action.im_resize_image.php

示例4: generateMosaic

 public function generateMosaic($input_path, $libraries = array())
 {
     if (empty($libraries)) {
         throw new \RuntimeException('At least one metapixel library needs to be used.');
     }
     if (!is_file($input_path)) {
         throw new \RuntimeException(sprintf('%s does not exist or could not be read.', $input_path));
     }
     $opts = '';
     foreach ($libraries as $library) {
         $path = $this->library_path . '/' . $library;
         $opts .= "--library {$path} ";
     }
     $opts = rtrim($opts);
     $path_parts = pathinfo($input_path);
     $output_path = $path_parts['dirname'] . '/tmp_metapixel_' . uniqid() . '.png';
     $process = new Process("metapixel {$opts} --metapixel {$input_path} {$output_path} --scale={$this->scale}");
     $process->setTimeout(null);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     $im = new \Imagick($output_path);
     $width = floor($im->getImageWidth() / $this->scale);
     $height = floor($im->getImageHeight() / $this->scale);
     $im->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 1);
     $im->setImageFormat('jpg');
     $im->setCompressionQuality(90);
     $mosaic_path = preg_replace('/\\.png$/', '_converted.jpg', $output_path);
     $im->writeImage($mosaic_path);
     $_id = $this->mosaic_repository->storeMosaic($mosaic_path, array('mimetype' => 'image/jpeg', 'width' => $width, 'height' => $height));
     unlink($input_path);
     unlink($output_path);
     unlink($mosaic_path);
     return $_id;
 }
開發者ID:andreaspollak,項目名稱:phosaic,代碼行數:36,代碼來源:MetapixelBuilder.php

示例5: 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

示例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: setFile

 /**
  * Associates the model with the file
  * @param string $filePath
  * @return boolean
  */
 public function setFile($filePath)
 {
     if (!file_exists($filePath)) {
         return false;
     }
     $info = getimagesize($filePath);
     $imageWidth = $info[0];
     $imageHeight = $info[1];
     $image = new Imagick();
     $image->readimage($filePath);
     $image->setResourceLimit(Imagick::RESOURCETYPE_MEMORY, 1);
     $maxSize = 1920;
     if ($imageWidth > $maxSize && $imageWidth > $imageHeight) {
         $image->thumbnailimage($maxSize, null);
     } elseif ($imageHeight > $maxSize && $imageHeight > $imageWidth) {
         $image->thumbnailimage(null, $maxSize);
     }
     $image->setCompression(Imagick::COMPRESSION_JPEG);
     $image->setCompressionQuality(80);
     $image->stripimage();
     $this->size = filesize($filePath);
     $this->type = $info['mime'];
     $this->width = $info[0];
     $this->height = $info[1];
     $this->content = $image->getImageBlob();
     $this->expireAt(time() + static::EXP_DAY);
     return true;
 }
開發者ID:HardSkript,項目名稱:unsee.cc,代碼行數:33,代碼來源:Image.php

示例8: thumbnail

 /**
  * @param $file
  * @return string
  */
 public function thumbnail($file)
 {
     $format = '';
     $name = md5((new \DateTime())->format('c'));
     foreach ($this->sizes as $size) {
         $image = new \Imagick($file);
         $imageRatio = $image->getImageWidth() / $image->getImageHeight();
         $width = $size['width'];
         $height = $size['height'];
         $customRation = $width / $height;
         if ($customRation < $imageRatio) {
             $widthThumb = 0;
             $heightThumb = $height;
         } else {
             $widthThumb = $width;
             $heightThumb = 0;
         }
         $image->thumbnailImage($widthThumb, $heightThumb);
         $image->cropImage($width, $height, ($image->getImageWidth() - $width) / 2, ($image->getImageHeight() - $height) / 2);
         $image->setCompressionQuality(100);
         $format = strtolower($image->getImageFormat());
         $pp = $this->cachePath . '/' . $size['name'] . "_{$name}." . $format;
         $image->writeImage($pp);
     }
     return "_{$name}." . $format;
 }
開發者ID:ahonymous,項目名稱:crop-imagick,代碼行數:30,代碼來源:ImagickService.php

示例9: watermarkPrint_imagick

 private function watermarkPrint_imagick($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo)
 {
     try {
         // Open the original image
         $img = new Imagick($src);
         // Open the watermark
         $watermark = new Imagick($watermark);
         // Set transparency
         if (strtoupper($watermark->getImageFormat()) !== 'PNG') {
             $watermark->setImageOpacity($transparency / 100);
         }
         // Overlay the watermark on the original image
         $img->compositeImage($watermark, imagick::COMPOSITE_OVER, $dest_x, $dest_y);
         // Set quality
         if (strtoupper($img->getImageFormat()) === 'JPEG') {
             $img->setImageCompression(imagick::COMPRESSION_JPEG);
             $img->setCompressionQuality($quality);
         }
         $result = $img->writeImage($src);
         $img->clear();
         $img->destroy();
         $watermark->clear();
         $watermark->destroy();
         return $result ? true : false;
     } catch (Exception $e) {
         return false;
     }
 }
開發者ID:devsnippet,項目名稱:yona-cms,代碼行數:28,代碼來源:plugin.php

示例10: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $format = "png", $quality = 85, $filename = FALSE, $save = TRUE, $print = false)
 {
     $imgH = count($frame);
     $imgW = strlen($frame[0]);
     $col[0] = new \ImagickPixel("white");
     $col[1] = new \ImagickPixel("black");
     $image = new \Imagick();
     $image->newImage($imgW, $imgH, $col[0]);
     $image->setCompressionQuality($quality);
     $image->setImageFormat($format);
     $draw = new \ImagickDraw();
     $draw->setFillColor($col[1]);
     for ($y = 0; $y < $imgH; $y++) {
         for ($x = 0; $x < $imgW; $x++) {
             if ($frame[$y][$x] == '1') {
                 $draw->point($x, $y);
             }
         }
     }
     $image->drawImage($draw);
     $image->borderImage($col[0], $outerFrame, $outerFrame);
     $image->scaleImage(($imgW + 2 * $outerFrame) * $pixelPerPoint, 0);
     if ($save) {
         if ($filename === false) {
             throw new Exception("QR Code filename can't be empty");
         }
         $image->writeImages($filename, true);
     }
     if ($print) {
         Header("Content-type: image/" . $format);
         echo $image;
     }
 }
開發者ID:alveos,項目名稱:phpqrcode,代碼行數:33,代碼來源:QRimage.php

示例11: convert_to_IMG

function convert_to_IMG($attachment, $options)
{
    $path = get_path($attachment);
    $dir = get_dir($attachment);
    $basename = get_basename($attachment);
    $converted_images = array();
    $max_width = $options['max_width'] ? (int) $options['max_width'] : 0;
    $max_height = $options['max_height'] ? (int) $options['max_height'] : 0;
    $img_extension = $options['img_extension'] ? $options['img_extension'] : 'jpg';
    $pages_to_convert = $options["pages_to_convert"] ? (int) $options["pages_to_convert"] : 0;
    if ($pages_to_convert > 5) {
        $pages_to_convert = 5;
    }
    $pages_to_convert = $pages_to_convert - 1;
    $quality = $options['quality'] ? (int) $options['quality'] : 80;
    if ($quality > 100) {
        $quality = 100;
    }
    try {
        $imagick = new Imagick();
        $imagick->clear();
        $imagick->destroy();
        if ($options) {
            $imagick->setResolution(150, 150);
            $imagick->readimage($path);
            $imagick->setCompressionQuality($quality);
        } else {
            $imagick->setResolution(72, 72);
            $imagick->readimage($path);
        }
        foreach ($imagick as $c => $_page) {
            if ($pages_to_convert == -1 || $c <= $pages_to_convert) {
                $_page->setImageBackgroundColor('white');
                $_page->setImageFormat($img_extension);
                if ($max_width && $max_height) {
                    $_page->adaptiveResizeImage($max_width, $max_height, true);
                }
                $blankPage = new \Imagick();
                $blankPage->newPseudoImage($_page->getImageWidth(), $_page->getImageHeight(), "canvas:white");
                $blankPage->compositeImage($_page, \Imagick::COMPOSITE_OVER, 0, 0);
                if ($blankPage->writeImage($dir . "/" . $basename . '-' . $c . '.' . $img_extension)) {
                    array_push($converted_images, $dir . "/" . $basename . '-' . $c . '.' . $img_extension);
                }
                $blankPage->clear();
                $blankPage->destroy();
            }
        }
    } catch (ImagickException $e) {
        $converted_images = false;
    } catch (Exception $e) {
        $converted_images = false;
    }
    return $converted_images;
}
開發者ID:fedorenko-dmitriy,項目名稱:pdf2img-converter,代碼行數:54,代碼來源:core.php

示例12: makeThumbnailtoFile

 function makeThumbnailtoFile($destFile)
 {
     $returnVal = false;
     if (!$this->isWorking()) {
         return false;
     }
     $image = new Imagick($this->sourceFile);
     $image->setCompressionQuality($this->thumbQuality);
     $image->thumbnailImage($this->thumbWidth, $this->thumbHeight);
     $returnVal = $image->writeImage($destFile);
     unset($image);
     return $returnVal;
 }
開發者ID:RicterZ,項目名稱:pixmicat,代碼行數:13,代碼來源:thumb.imagick.php

示例13: using_imagick

function using_imagick()
{
    global $image, $mask, $clut, $final, $qual;
    $im = new Imagick($image);
    # Apply color lookup table
    $im->clutImage(new Imagick($clut));
    # Apply transparency mask
    $im->compositeImage(new Imagick($mask), imagick::COMPOSITE_COPYOPACITY, 0, 0);
    # Save the image
    $im->setCompressionQuality($qual);
    $im->setImageDepth(8);
    $im->setFormat("png");
    $im->writeImage($final);
}
開發者ID:Helioviewer-Project,項目名稱:api,代碼行數:14,代碼來源:im.php

示例14: storeBase64Image

 public function storeBase64Image($name, $dir, $fileContentBase64)
 {
     $uploadDir = $this->rootDir . '/../web' . $dir;
     if (!is_dir($uploadDir)) {
         mkdir($uploadDir, 0777, true);
     }
     $image = new \Imagick();
     $data = explode(',', $fileContentBase64);
     $fileContent = base64_decode($data[1]);
     $image->readImageBlob($fileContent);
     $filename = $name . "." . time() . '.jpg';
     $image->setImageFormat('jpeg');
     $image->setCompression(\Imagick::COMPRESSION_JPEG);
     $image->setCompressionQuality(50);
     $image->writeImage($uploadDir . $filename);
     return $filename;
 }
開發者ID:koalamon,項目名稱:koalamonframeworkbundle,代碼行數:17,代碼來源:UploadHandler.php

示例15: Imagen__CrearMiniatura

function Imagen__CrearMiniatura($Origen, $Destino, $Ancho = 100, $Alto = 100)
{
    $im = new Imagick($Origen);
    $im->setImageColorspace(255);
    $im->setCompression(Imagick::COMPRESSION_JPEG);
    $im->setCompressionQuality(80);
    $im->setImageFormat('jpeg');
    list($newX, $newY) = scaleImage($im->getImageWidth(), $im->getImageHeight(), $Ancho, $Alto);
    $im->thumbnailImage($newX, $newY, false);
    return $im->writeImage($Destino);
}
開發者ID:vlad88sv,項目名稱:BCA,代碼行數:11,代碼來源:__stubs.php


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