本文整理匯總了PHP中Imagick::clear方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::clear方法的具體用法?PHP Imagick::clear怎麽用?PHP Imagick::clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagick
的用法示例。
在下文中一共展示了Imagick::clear方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __destruct
/**
* Destroys allocated imagick resources
*/
public function __destruct()
{
if ($this->imagick instanceof \Imagick) {
$this->imagick->clear();
$this->imagick->destroy();
}
}
示例2: save
public function save($file, $gray = false, $quality = 100)
{
if ($gray) {
$this->gray();
}
$res = $this->image->writeImages($file, true);
$this->image->clear();
$this->image->destroy();
return $res;
}
示例3: loadFile
/**
* @see \wcf\system\image\adapter\IImageAdapter::loadFile()
*/
public function loadFile($file)
{
try {
$this->imagick->clear();
$this->imagick->readImage($file);
} catch (\ImagickException $e) {
throw new SystemException("Image '" . $file . "' is not readable or does not exist.");
}
$this->readImageDimensions();
}
示例4: _adapt
/**
* Adaptation the image.
* @param int $width
* @param int $height
* @param int $offset_x
* @param int $offset_y
*/
protected function _adapt($width, $height, $offset_x, $offset_y)
{
$image = new \Imagick();
$image->newImage($width, $height, 'none');
$image->compositeImage($this->im, \Imagick::COMPOSITE_ADD, $offset_x, $offset_y);
$this->im->clear();
$this->im->destroy();
$this->im = $image;
$this->width = $image->getImageWidth();
$this->height = $image->getImageHeight();
}
示例5: 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;
}
示例6: create_thumb
function create_thumb($source_file, $thumb_file, $edge = THUMBNAIL_CROP_EDGE, &$src_w = NULL, &$src_h = NULL)
{
$composite_img = new Imagick($source_file);
$blank_img = new Imagick();
$src_w = $composite_img->getImageWidth();
$src_h = $composite_img->getImageHeight();
if ($src_h > $edge && $src_w > $edge) {
$composite_img->cropThumbnailImage($edge, $edge);
$composite_img->setImageFormat('jpeg');
$composite_img->writeImage($thumb_file);
$composite_img->clear();
$blank_img = $composite_img;
} else {
$blank_img->newImage($edge, $edge, new ImagickPixel('#DEF'), "jpg");
if ($src_w > $src_h) {
$crop_x = $src_w / 2 - $edge / 2;
$crop_y = 0;
$offset_x = 0;
$offset_y = $edge / 2 - $src_h / 2;
} else {
$crop_x = 0;
$crop_y = $src_h / 2 - $edge / 2;
$offset_x = $edge / 2 - $src_w / 2;
$offset_y = 0;
}
$composite_img->cropImage($edge, $edge, $crop_x, $crop_y);
$blank_img->compositeImage($composite_img, Imagick::COMPOSITE_OVER, $offset_x, $offset_y);
$blank_img->setImageFormat('jpeg');
$blank_img->writeImage($thumb_file);
$blank_img->clear();
}
return $blank_img;
}
示例7: destroyWatermarkResource
public function destroyWatermarkResource()
{
if ($this->watermark) {
$this->watermark->clear();
$this->watermark = null;
}
}
示例8: 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;
}
}
示例9: resize
public function resize($file, $size = array('width' => 100, 'height' => 100), $type = 'png', $fixed = false)
{
$image = new Imagick($this->file);
$image->setBackgroundColor(new ImagickPixel('transparent'));
$image->setImageFormat($type);
if ($fixed === true) {
$newWidth = $size['width'];
$newHeight = $size['height'];
} else {
$imageprops = $image->getImageGeometry();
$width = $imageprops['width'];
$height = $imageprops['height'];
if ($width > $height) {
$newHeight = $size['height'];
$newWidth = $size['height'] / $height * $width;
} else {
$newWidth = $size['width'];
$newHeight = $size['width'] / $width * $height;
}
}
$image->resizeImage($newWidth, $newHeight, imagick::FILTER_LANCZOS, 1);
$image->writeImage($file . '.' . $type);
$image->clear();
$image->destroy();
}
示例10: alfath_svg_compiler
function alfath_svg_compiler($options)
{
global $wp_filesystem;
if (!class_exists('Imagick')) {
return new WP_Error('class_not_exist', 'Your server not support imagemagick');
}
$im = new Imagick();
$im->setBackgroundColor(new ImagickPixel('transparent'));
if (empty($wp_filesystem)) {
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
}
$file = get_template_directory() . '/assets/img/nav.svg';
$target = get_template_directory() . '/assets/img/nav-bg.png';
if ($wp_filesystem->exists($file)) {
//check for existence
$svg = $wp_filesystem->get_contents($file);
if (!$svg) {
return new WP_Error('reading_error', 'Error when reading file');
}
//return error object
$svg = preg_replace('/fill="#([0-9a-f]{6})"/', 'fill="' . $options['secondary-color'] . '"', $svg);
$im->readImageBlob($svg);
$im->setImageFormat("png24");
$im->writeImage($target);
$im->clear();
$im->destroy();
} else {
return new WP_Error('not_found', 'File not found');
}
}
示例11: 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;
}
示例12: apply
/**
* Apply the transformer on the absolute path and return an altered version of it.
*
* @param string $absolutePath
*
* @return string|false
*/
public function apply($absolutePath)
{
$info = pathinfo($absolutePath);
if (isset($info['extension']) && false !== strpos(strtolower($info['extension']), 'pdf') && file_exists($absolutePath)) {
// If it doesn't exist yet, extract the first page of the PDF
$previewFilename = $this->getPreviewFilename($absolutePath);
if (!file_exists($previewFilename)) {
$this->imagick->readImage($absolutePath . '[0]');
$this->imagick->setImageFormat('jpg');
$this->imagick->flattenimages();
$this->imagick->writeImage($previewFilename);
$this->imagick->clear();
}
$absolutePath = $previewFilename;
}
return $absolutePath;
}
示例13: destroy
/**
* @return void
*/
protected function destroy()
{
if ($this->resource) {
$this->resource->clear();
$this->resource->destroy();
$this->resource = null;
}
}
示例14:
function _resize_image($image_path, $max_width = 100, $max_height = 100)
{
$imagick = new \Imagick(realpath($image_path));
$imagick->thumbnailImage($max_width, $max_height, true);
$blob = $imagick->getImageBlob();
$imagick->clear();
return $blob;
}
示例15: testImageThumbnail
public function testImageThumbnail()
{
var_dump("123 Inside Image Thumbnail");
$thumb = new \Imagick('/home/vagrant/www/consult-api/app/myimage.jpg');
$thumb->scaleImage(200, 200, 1);
$thumb->writeImage('/home/vagrant/www/consult-api/app/mythumb.jpg');
$thumb->clear();
$thumb->destroy();
}