ImageMagick PHP errors

1,885 views
Skip to first unread message

Alex Kerr

unread,
Dec 22, 2015, 6:03:05 PM12/22/15
to Google App Engine
Hi,

Trying a very simple test of ImageMagick - code below.

1.) ImageMagick extension not available on local dev server it seems - how come? Only seems to allow ImageMagick functions on the live GAE server.

2.) Can't access my test image in my img/ dir - not sure why - this is set to be app readable and is there as I can view it via direct URL.
Error I get is:

Fatal error: Uncaught exception 'ImagickException' with message 'UnableToOpenBlob `image.png': No such file or directory @ error/blob.c/OpenBlob/2709' in /base/data/home/apps/s~[myappname]/1.389452794920602844/imgcompress.php:5 Stack trace: #0 /base/data/home/apps/s~[myappname]/1.389452794920602844/imgcompress.php(5): Imagick->__construct('image.png') #1 {main} thrown in /base/data/home/apps/s~[myappname]/1.389452794920602844/imgcompress.php on line 5

My php.ini has the line: extension = "imagick.so"


Code:

<?php
    $image = 'img/image.png'; 
$a = file_get_contents('img/fonts1.png'); // Test to prove files in img/dir are app readable
    $compression_type = Imagick::COMPRESSION_UNDEFINED; 
   
    $im = new Imagick($image); 

    $im->setImageCompression($compression_type); 
    $im->setImageCompressionQuality(0); 
    $im->stripImage();
    $im->writeImage('image2.png'); 
?>

Many thanks for any info!
Alex

Mars Lan

unread,
Dec 23, 2015, 3:45:51 PM12/23/15
to Google App Engine
Did you set the "application_readable" option for "img/image.png" (see https://cloud.google.com/appengine/docs/php/config/appconfig#PHP_app_yaml_Static_file_handlers for more details)?

ImageMagick should work on local dev server. What platform are you on?

Alex Kerr

unread,
Dec 23, 2015, 4:33:08 PM12/23/15
to Google App Engine
Thanks. I thought I'd set the handler - relevant section of app.yaml is as follows:

handlers:
# Serve images as static resources.
- url: /(.+\.(gif|png|jpg|svg))$
  static_files
: \1
  upload
: .+\.(gif|png|jpg|svg)$
  application_readable
: true

Locally I'm running on Win 7. Error message when run locally is:

Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\Google\google_appengine\php\php-5.5-Win32-VC11-x86\imagick.so' - The specified module could not be found. in Unknown on line0
X-Powered-By: PHP/5.5.26 Content-type: text/html 
Fatal error: Class 'Imagick' not found in C:\Users\Alex\Desktop\RP\Code\AppEngine\testing\imgcompress.php on line 4


Thanks

Alex Kerr

unread,
Dec 23, 2015, 4:40:23 PM12/23/15
to Google App Engine
To follow from my other reply just now, the folder "C:\Program Files\Google\google_appengine\php\php-5.5-Win32-VC11-x86\" does contain php_imagick.dll - if that helps? I'm using App Engine SDK 1.9.30 too.


On Wednesday, December 23, 2015 at 8:45:51 PM UTC, Mars Lan wrote:

Stuart Langley

unread,
Dec 23, 2015, 6:07:42 PM12/23/15
to Google App Engine
Change your php.ini to use php_imagick.dll instead of imagick.so.

In the dev environment the name matters (dll for windows). In production the name does not matter (either dll or so will work), so you don't need to alter the ini file before deploying to production. 
Reply all
Reply to author
Forward
0 new messages