本文整理匯總了PHP中Imagick::getImageBlob方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::getImageBlob方法的具體用法?PHP Imagick::getImageBlob怎麽用?PHP Imagick::getImageBlob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagick
的用法示例。
在下文中一共展示了Imagick::getImageBlob方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getBlob
/**
* @return string
* @throws CM_Exception
*/
public function getBlob()
{
$this->_imagick->setImageCompressionQuality($this->getCompressionQuality());
try {
if ($this->_getAnimationRequired($this->getFormat())) {
$imageBlob = $this->_imagick->getImagesBlob();
} else {
$imageBlob = $this->_imagick->getImageBlob();
}
} catch (ImagickException $e) {
throw new CM_Exception('Cannot get image blob', null, ['originalExceptionMessage' => $e->getMessage()]);
}
return $imageBlob;
}
示例2: render
function render()
{
//Example Imagick::stripImage
$imagick = new \Imagick(realpath("../imagick/images/Biter_500.jpg"));
$bytes = $imagick->getImageBlob();
echo "Image byte size before stripping: " . strlen($bytes) . "<br/>";
$imagick->stripImage();
$bytes = $imagick->getImageBlob();
echo "Image byte size after stripping: " . strlen($bytes) . "<br/>";
//Example end
}
示例3: renderImage
public function renderImage()
{
//Create a ImagickDraw object to draw into.
$draw = new \ImagickDraw();
$darkColor = new \ImagickPixel('brown');
//http://www.imagemagick.org/Usage/compose/#compose_terms
$draw->setStrokeColor($darkColor);
$draw->setFillColor('white');
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($darkColor);
$draw->setStrokeWidth(2);
$draw->setFont("../fonts/CANDY.TTF");
$draw->setFontSize(140);
$draw->setFillColor('none');
$draw->rectangle(0, 0, 1000, 300);
$draw->setFillColor('white');
$draw->annotation(50, 180, "Lorem Ipsum!");
$imagick = new \Imagick(realpath("images/TestImage.jpg"));
$draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick);
//Create an image object which the draw commands can be rendered into
$imagick = new \Imagick();
$imagick->newImage(1000, 300, "SteelBlue2");
$imagick->setImageFormat("png");
//Render the draw commands in the ImagickDraw object
//into the image.
$imagick->drawImage($draw);
//Send the image to the browser
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例4: getAction
public function getAction($systemIdentifier, Request $request)
{
$width = $request->get('width');
$height = $request->get('height');
$system = $this->getDoctrine()->getRepository('KoalamonIncidentDashboardBundle:System')->findOneBy(['identifier' => $systemIdentifier, 'project' => $this->getProject()]);
$webDir = $this->container->getParameter('assetic.write_to');
if ($system->getImage() == "") {
$imageName = $webDir . self::DEFAULT_IMAGE;
} else {
$imageName = $webDir . ScreenshotCommand::IMAGE_DIR . DIRECTORY_SEPARATOR . $system->getImage();
}
$image = new \Imagick($imageName);
if ($height || $width) {
if (!$height) {
$ratio = $width / $image->getImageWidth();
$height = $image->getImageHeight() * $ratio;
}
if (!$width) {
$ratio = $height / $image->getImageHeight();
$width = $image->getImageWidth() * $ratio;
}
$image->scaleImage($width, $height, true);
}
$headers = array('Content-Type' => 'image/png', 'Content-Disposition' => 'inline; filename="' . $imageName . '"');
return new Response($image->getImageBlob(), 200, $headers);
}
示例5: refresh
/**
* @param Thumbnail $thumbnail
* @return void
* @throws Exception\NoThumbnailAvailableException
*/
public function refresh(Thumbnail $thumbnail)
{
try {
$filenameWithoutExtension = pathinfo($thumbnail->getOriginalAsset()->getResource()->getFilename(), PATHINFO_FILENAME);
$temporaryLocalCopyFilename = $thumbnail->getOriginalAsset()->getResource()->createTemporaryLocalCopy();
$documentFile = sprintf(in_array($thumbnail->getOriginalAsset()->getResource()->getFileExtension(), $this->getOption('paginableDocuments')) ? '%s[0]' : '%s', $temporaryLocalCopyFilename);
$width = $thumbnail->getConfigurationValue('width') ?: $thumbnail->getConfigurationValue('maximumWidth');
$height = $thumbnail->getConfigurationValue('height') ?: $thumbnail->getConfigurationValue('maximumHeight');
$im = new \Imagick();
$im->setResolution($this->getOption('resolution'), $this->getOption('resolution'));
$im->readImage($documentFile);
$im->setImageFormat('png');
$im->setImageBackgroundColor('white');
$im->setImageCompose(\Imagick::COMPOSITE_OVER);
$im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_RESET);
$im->thumbnailImage($width, $height, true);
$im->flattenImages();
// Replace flattenImages in imagick 3.3.0
// @see https://pecl.php.net/package/imagick/3.3.0RC2
// $im->mergeImageLayers(\Imagick::LAYERMETHOD_MERGE);
$resource = $this->resourceManager->importResourceFromContent($im->getImageBlob(), $filenameWithoutExtension . '.png');
$im->destroy();
$thumbnail->setResource($resource);
$thumbnail->setWidth($width);
$thumbnail->setHeight($height);
} catch (\Exception $exception) {
$filename = $thumbnail->getOriginalAsset()->getResource()->getFilename();
$sha1 = $thumbnail->getOriginalAsset()->getResource()->getSha1();
$message = sprintf('Unable to generate thumbnail for the given document (filename: %s, SHA1: %s)', $filename, $sha1);
throw new Exception\NoThumbnailAvailableException($message, 1433109652, $exception);
}
}
示例6: 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;
}
示例7: renderOriginalImage
function renderOriginalImage()
{
$imagick = new \Imagick(realpath("./images/chair.jpeg"));
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
return;
}
示例8: 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;
}
示例9: display
/**
* Displays image without saving and lose changes
*
* This method adds the Content-type HTTP header
*
* @param string type (JPG,PNG...);
* @param int quality 75
*
* @return bool|PEAR_Error TRUE or a PEAR_Error object on error
* @access public
*/
function display($type = '', $quality = null)
{
$options = is_array($quality) ? $quality : array();
if (is_numeric($quality)) {
$options['quality'] = $quality;
}
$quality = $this->_getOption('quality', $options, 75);
$this->imagick->setImageCompression($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 {
$image = $this->imagick->getImageBlob();
} catch (ImagickException $e) {
return $this->raiseError('Could not display image.', IMAGE_TRANSFORM_ERROR_IO);
}
header('Content-type: ' . $this->getMimeType($type));
echo $image;
$this->free();
return true;
}
示例10: renderOriginalImage
public function renderOriginalImage()
{
$imagick = new \Imagick();
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
return;
}
示例11: updateModel
/**
* Update the model data if the image has been changed
*
* @param EventInterface $event The event instance
*/
public function updateModel(EventInterface $event)
{
$image = $event->getArgument('image');
if ($image->hasBeenTransformed()) {
$image->setBlob($this->imagick->getImageBlob());
}
}
示例12: brightnessContrastImage
function brightnessContrastImage($path_image, $brightness, $contrast, $channel)
{
$imagick = new Imagick(realpath($path_image));
$imagick->brightnessContrastImage($brightness, $contrast, $channel);
header("Content-Type: image/jpeg");
echo $imagick->getImageBlob();
}
示例13:
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;
}
示例14: thumbnailImage
function thumbnailImage($imagePath)
{
$imagick = new \Imagick(realpath($imagePath));
$imagick->setbackgroundcolor('rgb(64, 64, 64)');
$imagick->thumbnailImage(300, 300, true, true);
//header("Content-Type: image/jpg");
return $imagick->getImageBlob();
}
示例15: getPng
public function getPng($resolutionX = 100, $resolutionY = 100)
{
$img = new \Imagick();
$img->setResolution($resolutionX, $resolutionY);
$img->readImageBlob($this->get());
$img->setImageFormat('png');
return $img->getImageBlob();
}