PHP Imagick cannot use trimImage() function

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
JohnSmith
Posts: 11
Joined: 2012-10-01T16:41:10-07:00
Authentication code: 67789

PHP Imagick cannot use trimImage() function

Post by JohnSmith »

First i installed ImageMagick v6.7.9-9 as described here

then installed Imagick extension v3.0.1 stable from peclinstall did not work so i follwed this steps

Then i had nasty problem with libWand.so.10 and libMagic.so.10 not found that i solved by creating symlinc for both files in /usr/lib/ to /usr/local/lib/libMagickWand.so.5.0.0

Still have error Fatal error: Call to undefined method Imagick::trimimage() in .../myyscript.php on line 83

Code: Select all

getVersion() returns.

    array(2) {
      ["versionNumber"]=>
      int(1657)
      ["versionString"]=>
      string(61) "ImageMagick 6.7.9-9 2012-10-01 Q16 http://www.imagemagick.org"
    }
Cent OS 5.5, cPanel

I tried this code, it as well produced fatal error.

Code: Select all

    <?php

    $im = new Imagick( "test.png" );

    $im->setImageBackgroundColor( new ImagickPixel( "rgb(213,213,213)" ) );

    $im->trimImage( 0 );

    header( "Content-Type: image/" . $im->getImageFormat() );
    echo $im;
    ?>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP Imagick cannot use trimImage() function

Post by fmw42 »

All I can do is point you to http://www.php.net/manual/en/imagick.trimimage.php

and to the fact there is a more current Imagick at http://pecl.php.net/package/imagick/3.1.0RC2
JohnSmith
Posts: 11
Joined: 2012-10-01T16:41:10-07:00
Authentication code: 67789

Re: PHP Imagick cannot use trimImage() function

Post by JohnSmith »

I want to use stable version for production site, they release updates once half year so it might be some waiting. Besides on php.net website its saying function works since imagick v2.0

also they say on php.net that "works if imagick compiled against ImageMagick version 6.2.9 or newer." wonder what they mean compiled against i am not linux person and i believe they mean i need to install it in certain way?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PHP Imagick cannot use trimImage() function

Post by Bonzo »

Just a note this thread should be in the Imagick section of the forum.
"works if imagick compiled against ImageMagick version 6.2.9 or newer."
I pressume as you say it must be compiled against a certain version of Imagemagick as the operator was not available in Imagemagick before then?

I have tried it with this code and get an unmodified image so I assume there may be a problem:

Code: Select all

<?php  
$im = new Imagick( 'borderImage.jpg' ); 
$im->trimImage( 0 ); 
$im->writeImage( "trimImage.jpg" ); 
$im->destroy(); 
 ?> 
JohnSmith
Posts: 11
Joined: 2012-10-01T16:41:10-07:00
Authentication code: 67789

Re: PHP Imagick cannot use trimImage() function

Post by JohnSmith »

Yes it was not available before 6.2.9 i guess, but by complile they mean i compile or the author who wrote imagick should have?

The problem is not the functionality, but the fact that it gives me fatal error every time it gets to line with $im->trimImage(0);

I tried to install Imagick v3.1.0RC2 and got error with pecl and manual install

Its saying error: 1
MAKE EXIT STATUS
GNU make exits with a status of zero if all makefiles were successfully parsed and no targets that were built failed. A status of one will be returned if the -q flag was used and make determines that a
target needs to be rebuilt.
A status of two will be returned if any errors were encountered.

Code: Select all

/bin/sh /usr/src/imagick-3.1.0RC2/libtool --mode=compile cc  -I. -I/usr/src/imagick-3.1.0RC2 -DPHP_ATOM_INC -I/usr/src/imagick-3.1.0RC2/include -I/usr/src/imagick-3.1.0RC2/main -I/usr/src/imagick-3.1.0RC2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /usr/src/imagick-3.1.0RC2/imagick_file.c -o imagick_file.lo
 cc -I. -I/usr/src/imagick-3.1.0RC2 -DPHP_ATOM_INC -I/usr/src/imagick-3.1.0RC2/include -I/usr/src/imagick-3.1.0RC2/main -I/usr/src/imagick-3.1.0RC2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/src/imagick-3.1.0RC2/imagick_file.c  -fPIC -DPIC -o .libs/imagick_file.o
In file included from /usr/src/imagick-3.1.0RC2/imagick_file.c:21:
/usr/src/imagick-3.1.0RC2/php_imagick.h:49:31: error: wand/MagickWand.h: No such file or directory
In file included from /usr/src/imagick-3.1.0RC2/php_imagick_file.h:24,
                 from /usr/src/imagick-3.1.0RC2/imagick_file.c:22:
/usr/src/imagick-3.1.0RC2/php_imagick_defs.h:72: error: expected specifier-qualifier-list before 'MagickWand'
/usr/src/imagick-3.1.0RC2/php_imagick_defs.h:80: error: expected specifier-qualifier-list before 'DrawingWand'
/usr/src/imagick-3.1.0RC2/php_imagick_defs.h:86: error: expected specifier-qualifier-list before 'PixelIterator'
/usr/src/imagick-3.1.0RC2/php_imagick_defs.h:98: error: expected specifier-qualifier-list before 'PixelWand'
In file included from /usr/src/imagick-3.1.0RC2/imagick_file.c:22:
/usr/src/imagick-3.1.0RC2/php_imagick_file.h:43: error: 'MaxTextExtent' undeclared here (not in a function)
In file included from /usr/src/imagick-3.1.0RC2/imagick_file.c:22:
/usr/src/imagick-3.1.0RC2/php_imagick_file.h:77:32: warning: no newline at end of file
/usr/src/imagick-3.1.0RC2/imagick_file.c: In function 'php_imagick_file_init':
/usr/src/imagick-3.1.0RC2/imagick_file.c:75: error: 'MagickPath' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:75: error: (Each undeclared identifier is reported only once
/usr/src/imagick-3.1.0RC2/imagick_file.c:75: error: for each function it appears in.)
/usr/src/imagick-3.1.0RC2/imagick_file.c:99: error: 'HeadPath' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:100: error: 'TailPath' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c: In function 'php_imagick_read_image_using_imagemagick':
/usr/src/imagick-3.1.0RC2/imagick_file.c:124: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:124: error: 'MagickFalse' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:128: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:135: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:137: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c: In function 'php_imagick_read_image_using_php_streams':
/usr/src/imagick-3.1.0RC2/imagick_file.c:144: error: 'MagickBooleanType' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:144: error: expected ';' before 'status'
/usr/src/imagick-3.1.0RC2/imagick_file.c:177: error: 'status' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:177: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:179: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:184: error: 'MagickFalse' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:189: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:196: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c: In function 'php_imagick_write_file':
/usr/src/imagick-3.1.0RC2/imagick_file.c:247: error: 'MagickBooleanType' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:247: error: expected ';' before 'status'
/usr/src/imagick-3.1.0RC2/imagick_file.c:258: error: 'status' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:258: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:260: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:264: error: 'MagickFalse' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c: In function 'php_imagick_stream_handler':
/usr/src/imagick-3.1.0RC2/imagick_file.c:277: error: 'MagickBooleanType' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:277: error: expected ';' before 'status'
/usr/src/imagick-3.1.0RC2/imagick_file.c:306: error: 'status' undeclared (first use in this function)
/usr/src/imagick-3.1.0RC2/imagick_file.c:306: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:310: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:314: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:318: error: 'php_imagick_object' has no member named 'magick_wand'
/usr/src/imagick-3.1.0RC2/imagick_file.c:326: error: 'MagickFalse' undeclared (first use in this function)
make: *** [imagick_file.lo] Error 1
JohnSmith
Posts: 11
Joined: 2012-10-01T16:41:10-07:00
Authentication code: 67789

Re: PHP Imagick cannot use trimImage() function

Post by JohnSmith »

I managed to install 3.1.0.RC1 but there was problem too
/usr/bin/php: symbol lookup error: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/imagick.so: undefined symbol: MagickWandGenesis
Premature end of script headers: get_page.php
File does not exist: /home/500.shtml
I read here that it can be fixed by configuring PKG_CONFIG_PATH or whatever i dont know linux that much so i just skipped it and installed Imagick v2.3.0 and trimImage() works.


There were also another read i found saying need to add line using MagickLib::TrimImage to Include.h however it did not fix fatal error.

EDIT: installed v3.0.0 and it works too so i keep it for now.
Post Reply