PHP error "Call to undefined method... getImageOrientation"

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
AMarchant
Posts: 5
Joined: 2014-02-22T21:20:46-07:00
Authentication code: 6789

PHP error "Call to undefined method... getImageOrientation"

Post by AMarchant »

Hi - I'm sorry if this is the wrong forum, I'm very new to all of this (PHP, Linux, Imagick).

I'm attempting to use the jQuery File Upload widget from here: https://github.com/blueimp/jQuery-File-Upload
It uses Imagick to display thumbnails of files to be uploaded from a web form. I'm in the early stages of integrating it into a page on my website, but an error is thrown when I attempt to upload a file:
Call to undefined method Imagick::getImageOrientation()
Google doesn't return any results when I search for this error. I'm running an old Ubuntu 7.10 server install with PHP "Version 5.2.3-1ubuntu6.5". The PHP Info pages shows this information about IMagick:

Image

When I look at the PHP.net documentation for the getImageOrientation method it says at the top of the page "PECL imagick 2.0.0". I don't know whether this is related to the "imagick module version 2.0.0-alpha" shown in my screenshot. But if it is, perhaps the "alpha" version didn't include this function? I'm having a difficult time understanding what the cause might be otherwise.

If - from the command line of the Linux server - I type:

Code: Select all

sudo apt-get install php5-imagick
The system response is:

Code: Select all

Reading package lists... Done
php5-imagick is already the newest version
0 upgraded, 0 newly installed, 0 to remove and 80 not upgraded
I'd be very grateful if someone could suggest how I might proceed from here! Thank you in advamce
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP error "Call to undefined method... getImageOrientati

Post by fmw42 »

My guess is that your IM 6.2.4 is way too old. The call is probably newer than your version of IM will support. IM 6.2.4 is over 600 versions old. Currently IM is at 6.8.8.7. It is also possible but less likely that your IMagick alpha has bugs. It is alpha!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PHP error "Call to undefined method... getImageOrientati

Post by Bonzo »

The version should be OK; have you checked out this page: http://www.php.net/manual/en/imagick.ge ... tation.php
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP error "Call to undefined method... getImageOrientati

Post by fmw42 »

Bonzo wrote:The version should be OK; have you checked out this page: http://www.php.net/manual/en/imagick.ge ... tation.php

Are you sure that the image orientation property was even available at the 6.2.4 IM version? I thought it was not available until more recently. Though I have no proof. The earliest reference in the changelog is


2009-10-01 6.5.6-7 Cristy <quetzlzacatenango@image...>
Properly update the EXIF orientation tag.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PHP error "Call to undefined method... getImageOrientati

Post by Bonzo »

Are you sure that the image orientation property was even available at the 6.2.4 IM version?
The Imagick webpage said it was available in version 2 but I did not think about Imagemagick. It used to say something like "available if compiled with version .... of Imagemagick" but no longer seems to say that.
AMarchant
Posts: 5
Joined: 2014-02-22T21:20:46-07:00
Authentication code: 6789

Re: PHP error "Call to undefined method... getImageOrientati

Post by AMarchant »

Thank you very much for your replies. I suspected IMagick was desperately out-of-date, it seems reasonable to assume that this is the reason for the missing function.
I'd very happily update to something more recent, but that's my next issue - I don't know how to go about doing it. I realise we're getting into Linux specific commands at this point, but as I say, my attempts to install a newer IMagick haven't come to very much - the Advanced Packaging Tool just tells me I'm already running the most recent version when I do.

Maybe this is because the repository it connects to doesn't list anything more recent for my version of Ubuntu. Maybe because I'm trying to update the wrong components? I'm really a beginner with all of these things so I'm finding it quite difficult to figure out where I'm going wrong.

Any suggestions?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP error "Call to undefined method... getImageOrientati

Post by fmw42 »

Your Imagick at alpha 2.0.0 is likely rather old. I suspect your ISP just needs to upgrade their version of Imagick and Imagemagick. Contact your hosting company. If this is not from a shared host and is your own private system, then you would need to upgrade them yourself.

You might also post a simple PHP script that uses the command you want? Perhaps user bonzo or someone else can test the equivalent on their PHP system.
AMarchant
Posts: 5
Joined: 2014-02-22T21:20:46-07:00
Authentication code: 6789

Re: PHP error "Call to undefined method... getImageOrientati

Post by AMarchant »

Thanks fmw42 - the Linux server is actually running on a VMWare Virtual Machine on my local PC while I put the website together, so I do have full control - just not very full knowledge!

I'll see if I can find any detailed instructions for upgrading Imagemagick online; the trouble I've had in the past is that - because it's a very old version of Ubuntu server (7.10) - any documentation I come across is for much more recent versions. I've stuck with this aging VMWare image because it's very compact and uses an extremely modest amount of RAM, which my host system doesn't have in abundance.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PHP error "Call to undefined method... getImageOrientati

Post by Bonzo »

Imagick can be a pain to setup on Windows - I had it running for a couple of years but have never been able to get it running since.

Hopefully you will have better luck on Linux. If you do upgrade different things there was a problem with php 5.4 and Imagick which was sorted out in a later version of Imagick; I had to disable it on my server due to an ever increasing error file!
AMarchant
Posts: 5
Joined: 2014-02-22T21:20:46-07:00
Authentication code: 6789

Re: PHP error "Call to undefined method... getImageOrientati

Post by AMarchant »

Hey again fmw42. Between my last message and now, I've been grappling with Linux from the command line, and I've managed to update IMagick and Imagemagick - more by luck than judgement. Unfortunately I didn't document each of the steps that this involved, but I'll try to include a synopsis below for anyone else in my position. The PHP Info page now reports:

Code: Select all

imagick module version 3.1.2
ImageMagick version ImageMagick 6.8.8-7 Q16 i686 2014-02-23 http://www.imagemagick.org 
And the error I was seeing before has gone away (as far as I can tell, haven't tested this thoroughly yet).

1) Update the source.list file in Ubuntu. This file contains a list of URLs that the Advanced Packaging Tool consults when it is asked to install or update software. The file was completely outdated. Because Ubuntu 7.10 hasn't been supported since 2009, the Ubuntu repositories no longer host any software packages for this version - but they *are* available in from the "old-releases" Ubuntu host. So I had to comment out most of the lines in that file, and replace them with the set below. On Ubuntu Linux 7.10 the sources.list file is contained within the "/etc/apt/" directory:

Code: Select all

deb http://old-releases.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ gutsy main restricted
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-updates main restricted
deb http://old-releases.ubuntu.com/ubuntu/ gutsy universe
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-updates universe
deb http://old-releases.ubuntu.com/ubuntu/ gutsy multiverse
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-updates multiverse
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-security main restricted
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-security universe
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-security multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ gutsy main restricted
deb-src http://old-releases.ubuntu.com/ubuntu/ gutsy-updates main restricted
deb-src http://old-releases.ubuntu.com/ubuntu/ gutsy universe
deb-src http://old-releases.ubuntu.com/ubuntu/ gutsy-updates universe
deb-src http://old-releases.ubuntu.com/ubuntu/ gutsy multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ gutsy-updates multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
I came across this thread on this forum: viewtopic.php?f=1&t=24284
Which proved invaluable, though I had to change a few things and add some extra steps.

2)

Code: Select all

sudo apt-get update
-> this worked fine after I'd modified sources.list

Code: Select all

sudo apt-get install build-essential checkinstall libx11-dev libxext-dev zlib1g-dev libpng12-dev libjpeg-dev libfreetype6-dev libxml2-dev
-> this worked OK too

Code: Select all

sudo apt-get build-dep imagemagick
-> this caused some problems, but I've forgotten what I did to overcome them! ...

3) Modified version of the next step from that thread. I didn't know where I should put the downloaded file, but following the advice from this page (http://www.linuxjournal.com/article/4121) I navigated to the "/opt/" directory and ran the wget command below from there.

Code: Select all

cd /opt/
wget http://www.imagemagick.org/download/ImageMagick-6.8.8-7.tar.gz
tar -xzvf ImageMagick-6.8.8-7.tar.gz
cd ImageMagick-6.8.8-7
chmod +x ./configure
./configure
sudo checkinstall
I was told that the installation had completed successfully, but nothing seemed to have changed. Then I found this page: http://hasin.me/2008/02/06/installing-i ... buntu-710/ and followed the additional steps there.

4) Modified version of steps from that page. When I tried to run "phpize" I was told something like "command not found". Googling this error turned up the solution - I had to install php5-dev first:

Code: Select all

apt-get install php5-dev
wget http://pecl.php.net/get/imagick-3.1.2.tgz
tar zxf imagick-3.1.2.tgz
cd imagick-3.1.2
phpize && ./configure
sudo make
sudo make install
I skipped step 3 from the hasin.me page (
Now add “extension=imagick.so” in your php.ini (You may need to write the full path of imagick.so based on your configuration)
), but did restart Apache after this:

Code: Select all

/etc/init.d/apache2 restart
Once I'd done that the PHP Info page displayed the updated information. Many thanks to everyone for your help and suggestions!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP error "Call to undefined method... getImageOrientati

Post by fmw42 »

congratulations. good work. and thank for everyone else for your notes.
AMarchant
Posts: 5
Joined: 2014-02-22T21:20:46-07:00
Authentication code: 6789

Re: PHP error "Call to undefined method... getImageOrientati

Post by AMarchant »

Thank you! And embarrassingly I've just realised that the jQuery File Upload actually has a configuration setting so that you can choose between GD and ImageMagick - and it's set to ImageMagick by default, although I knew GD to be working on that VMWare image. Sheesh. So I probably didn't need to go through all of this, but I'm glad to have ended up with a fully-functioning ImageMagick installation at the end of it anyway!
Post Reply