Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Imagick.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public function clone(): Imagick {}

public function getImageSize(): int {}

public function getImageBlob(): ?string {}
public function getImageBlob(): string {}

public function getImagesBlob(): string {}

Expand Down
9 changes: 1 addition & 8 deletions Imagick_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2002,14 +2002,7 @@ ZEND_END_ARG_INFO()

#define arginfo_class_Imagick_getImageSize arginfo_class_Imagick_getSizeOffset


#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_getImageBlob, 0, 0, IS_STRING, 1)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_getImageBlob, 0, 0, 0)
#endif

ZEND_END_ARG_INFO()
#define arginfo_class_Imagick_getImageBlob arginfo_class_Imagick___toString

#define arginfo_class_Imagick_getImagesBlob arginfo_class_Imagick___toString

Expand Down
3 changes: 2 additions & 1 deletion imagick_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -8475,7 +8475,8 @@ PHP_METHOD(Imagick, getImagesBlob)

image_contents = MagickGetImagesBlob(intern->magick_wand, &image_size);
if (!image_contents) {
return;
php_imagick_throw_exception(IMAGICK_CLASS, "Failed to get the image contents (empty or invalid image?)" TSRMLS_CC);
RETURN_THROWS();
}

IM_ZVAL_STRINGL(return_value, (char *)image_contents, image_size);
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ This extension requires ImageMagick version 6.5.3-10+ and PHP 5.6.0+.
<file name="328_Imagick_polaroidImageWithTextAndMethod_basic.phpt" role="test" />
<file name="329_imagick_getImageBlob_empty.phpt" role="test" />
<file name="330_Imagick_newImage.phpt" role="test" />
<file name="331_Imagick_getImagesBlob_empty.phpt" role="test" />
<file name="bug20636.phpt" role="test" />
<file name="bug21229.phpt" role="test" />
<file name="bug59378.phpt" role="test" />
Expand Down
23 changes: 23 additions & 0 deletions tests/331_Imagick_getImagesBlob_empty.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Imagick::getImagesBlob behaviour on invalid images
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

// Fails due to image having no format
$imagick = new Imagick();
try {
$imagick->newPseudoImage(200, 200, "xc:red");
$result = $imagick->getImagesBlob();
echo "Imagick failed to throw exception" . PHP_EOL;
} catch (ImagickException $e) {
echo "ImagickException: " . $e->getMessage() . PHP_EOL;
}

echo "Fin.\n";

?>
--EXPECTF--
ImagickException: Failed to get the image contents (empty or invalid image?)
Fin.
Loading