PHP.mk документација

Imagick::getImageBlob

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

imagick.getimageblob.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека imagick.getimageblob.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Imagick::getImageBlob

Референца за `imagick.getimageblob.php` со подобрена типографија и навигација.

imagick.getimageblob.php

Imagick::getImageBlob

(PECL imagick 2, PECL imagick 3)

Imagick::getImageBlobReturns the image sequence as a blob

= NULL

public Imagick::getImageBlob(): string

Implements direct to memory image formats. It returns the image sequence as a string. The format of the image determines the format of the returned blob (GIF, JPEG, PNG, etc.). To return a different image format, use Imagick::setImageFormat().

Параметри

Оваа функција нема параметри.

Вратени вредности

Returns a string containing the image.

Errors/Exceptions

Фрла ImagickException при грешка.

Белешки од корисници 4 белешки

Vee W
пред 9 години
For who want to show "animated" gif. This getImageBlob() will showing only one frame of image.
Use getImagesBlob() instead.

Example:

<?php
$Imagick = new \Imagick($real_source_image_path_animated_gif);
header("Content-Type: image/gif");
echo $Imagick->getImagesBlob();
?>
anonymous at internet dot domain
пред 1 година
Function returns NULL without any error if ImageMagick policy.xml blocks handling the file format, i.e. PDF.
For PDF output edit /etc/ImageMagick-6/policy.xml and remove the line which disables rights for PDF.
If you use other functions, e.g. readImage() for PDF, ImageMagick nags about it and outputs the error message but this function fails silently.
Trevor
пред 14 години
It seems that this method can return a zero-length string if faced with large-ish data.  No exceptions are thrown.

<?php
  $image = new Imagick();
  if (!$image->newImage(1000,1,'white')) throw new Exception();
  if (!$image->scaleImage(0,200)) throw new Exception();
  print "Image size: {$image->getImageWidth()},{$image->getImageHeight()}\n";
  if (!$image->setImageFormat("jpeg")) throw new Exception();
  $a = $image->getImageBlob();
  print "Rendered to ".strlen($a)." bytes\n";
?>

Restrict your output image size, or ensure that the blob you get back isn't empty.  (Note that IM seems to be doing the work, it delays for some time.  But there's no indication of any error anywhere.)
jim at jimohalloran dot com
пред 4 години
Further to Trevor's note above about getImageBlob potentially returning an empty string for large images.  

This seems image format dependent.  I have a large (12046x8363) image which is returned ok.  But if I call setImageFormat('pdf') and then call getImageBlob() again.  Example:

<?php
// Image Manipulation here.
$pngData = $imagick->getImageBlob();  // Returns a large PNG.
$imagick->setImageFormat('pdf');
$pdfData = $imagick->getImageBlob(); // Returns empty string immediately
?>
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.