note 119756 added to imagick.newimage
| From: | EduardSukharev | Date: | Thu, 18 Aug 2016 16:39:02 +0000 |
| Subject: | note 119756 added to imagick.newimage | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206315@lists.php.net to get a copy of this message | ||
It's not obvious and may be related only to some specific versions of ImageMagick (tested only
for 6.7.7 and 6.8.9), but $cols and $rows must be a positive non-zero value.
<?php
$image = new Imagick();
$image->newImage(0, 100, new ImagickPixel('red'));
$image->setImageFormat('png');
file_put_contents('image.png', $image);
?>
In this case imagemagick will crash without throwing any exception and you'll get something
along the lines (in your apache error log or console output):
unable to acquire cache view `No such file or directory' @
fatal/cache-view.c/AcquireAuthenticCacheView/121.
This might be the case when you calculate $cols and $rows (say, based on user input and predefined
target image DPI):
<?php
$image = new Imagick();
$img->newImage($userInput->getWidth() * $defaultPpi, $userInput->getHeight() * $defaultPpi,
new ImagickPixel('white'));
?>
In this case if user requested image with 0.006 width (in inches), the code would work for
$defaultPpi = 300 ppi, but would crash for
$defaultPpi = 72 ppi
----
Server IP: 72.52.91.14
Probable Submitter: 81.177.125.226
----
Manual Page -- http://php.net/manual/en/imagick.newimage.php
Edit -- https://master.php.net/note/edit/119756
Del: integrated -- https://master.php.net/note/delete/119756/integrated
Del: useless -- https://master.php.net/note/delete/119756/useless
Del: bad code -- https://master.php.net/note/delete/119756/bad+code
Del: spam -- https://master.php.net/note/delete/119756/spam
Del: non-english -- https://master.php.net/note/delete/119756/non-english
Del: in docs -- https://master.php.net/note/delete/119756/in+docs
Del: other reasons-- https://master.php.net/note/delete/119756
Reject -- https://master.php.net/note/reject/119756
Search -- https://master.php.net/manage/user-notes.php