[Pkg-php-pecl] Bug#784124: php5-imagick: readimage() sends ghostscript PDF error directly to stdout, and cannot be suppressed.
Michael
michael.billington at gmail.com
Sun May 3 10:24:04 UTC 2015
Package: php5-imagick
Version: 3.2.0~rc1-1
Severity: normal
Hi,
This bug appears when reading a PDF with readImage() in imagick-php. Most
errors are thrown as an ImagickException. However, when an out-of-range page is
requested from a PDF, output is also sent directly to standard output, in
addition to the exception. Unlike normal output, it is impossible to suppress
this extra text with the normal tools (catch, @readImage, ob_start(), see
also[1]).
Example ('doc.pdf' contains two blank pages- any short file will work):
<?php
$im = new Imagick();
try {
$im -> readImage("doc.pdf[5]");
$im -> destroy();
} catch(ImagickException $e) {
echo "Error: " . $e -> getMessage() . "\n";
}
?>
Which prints:
Requested FirstPage is greater than the number of pages in the file: 2
No pages will be processed (FirstPage > LastPage).
Error: Failed to read the file
The extra output (aside from being incorrect) should be triggered as a
notice/warning, or included with the exception. The text appears to be
generated by GhostScript.
See attached test and example doc.
-Michael Billington
[1] http://stackoverflow.com/questions/13299590/how-does-one-suppress-error-
output-when-instantiating-a-class-in-php
-- System Information:
Debian Release: jessie/sid
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.16-3-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages php5-imagick depends on:
ii libc6 2.19-11
ii libgomp1 4.9.1-16
ii libmagickcore-6.q16-2 8:6.8.9.9-5
ii libmagickwand-6.q16-2 8:6.8.9.9-5
ii php5-common [phpapi-20131226] 5.6.7+dfsg-1
Versions of packages php5-imagick recommends:
ii ghostscript 9.06~dfsg-2
ii ttf-dejavu-core 2.34-1
php5-imagick suggests no packages.
*** bug-outp.phpt
--TEST--
Output when calling readimage on PDF for out-of-range page
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc');
--FILE--
<?php
$im = new Imagick();
try {
$im -> readImage("doc.pdf[5]");
$im -> destroy();
} catch(ImagickException $e) {
echo "Error: " . $e -> getMessage() . "\n";
}
?>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: doc.pdf
Type: application/pdf
Size: 6681 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-php-pecl/attachments/20150503/ff3837db/attachment.pdf>
More information about the Pkg-php-pecl
mailing list