How do I get Imagemagick supported on my server ?

hi Eric

http://auto-software.co.uk/test.php

cheers
Rob

Mmm, okay.

You mentioned previously, but just to be certain – what is the output of this command:

cat /etc/php.d/imagick.ini

And can you run this one as well:

ls /usr/lib/php/modules/

Also, do you see any errors in $HOME/logs/error_log for that particular domain?
-Eric

hi Eric

the first command outputs this:

[root@domU-12-31-39-00-48-05:~] cat /etc/php.d/imagick.ini ; Enable imagick extension module extension=imagick.so [root@domU-12-31-39-00-48-05:~]

the second command outputs this:

[root@domU-12-31-39-00-48-05:~] ls /usr/lib/php/modules/ gd.so imap.so mcrypt.so mysql.so pdo_mysql.so pdo_pgsql.so pdo_sqlite.so phpcups.so xmlrpc.so imagick.so mbstring.so mysqli.so odbc.so pdo_odbc.so pdo.so pgsql.so snmp.so [root@domU-12-31-39-00-48-05:~]

In the error log I’m seeing hundreds of lines of this, repeated every 5 minutes - probably getting pinged by facebook every 5 minutes - looks like I need to fix errors in my facebook apps:

[Mon Apr 20 14:30:11 2009] [warn] mod_fcgid: stderr: PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '../php/facebook.php' (include_path='.:/usr/share/pear') in /home/auto-software/public_html/facebook-platform/appid.php on line 1 [Mon Apr 20 14:35:08 2009] [warn] mod_fcgid: stderr: PHP Warning: require_once(../php/facebook.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /home/auto-software/public_html/facebook-platform/appid.php on line 1

I can see this error caused by me trying to run a simple piece of imagick example php code to see if an image would be converted to a thumbnail:

[Sun Apr 19 21:04:40 2009] [warn] mod_fcgid: stderr: PHP Fatal error: Class 'Imagick' not found in /home/auto-software/public_html/test2.php on line 5

problem solved!

I found the solution to the problem here: http://www.centos.org/modules/newbb/viewtopic.php?topic_id=19667

imagick-2.2.2 was the culprit. I ran

pecl uninstall imagick

followed by

pecl install imagick-2.2.1

and now imagick is showing up in phpinfo();

I can’t yet get my test php file to resize an image to a thumbnail, but at least I’m back to learning OO php

Hey, that’s great news, as I was staring at your phpinfo() output and just not figuring out what was wrong there :slight_smile:

Glad you got it!
-Eric

hi everyone, I’m back again! I managed to get some coding done at last. Then I ran into a problem: The most up-to-date version of ImageMagick in the yum repository is 6.2.8. In order for one of my scrips to work (create images with rounded corners), I need at least version 6.2.9.

I’ve done a fair bit of googling and keep coming to the same conclusion: I need to uninstall ImageMagick and manually install the latest version (6.5.1). This is where I come unstuck - linux administration is not one of my strong points - hence why I use Virtualmin. I can probably follow the gist of the instructions here ok: http://www.imagemagick.org/script/install-source.php, but first, I don’t have a clue which directory to put ImageMagick.tar.gz in before I can unpack it.

So who better to ask about this kind of stuff, than the experts! Thanks in advance :wink:

I would strongly recommend you get ahold of a more recent SRPM and rebuild it for your system. This keeps things under control of the package manager on the system…so when you upgrade your OS a year or two from now, it’ll all go smooth and happy.

Fedora is usually where I go for the latest greatest SRPMS, and sure enough, you can find 6.5.1 in the development version of Fedora:

http://mirrors.kernel.org/fedora/development/source/SRPMS/ImageMagick-6.5.1.2-1.fc11.src.rpm

So, grab that, and try a rebuild. Assuming you already have gcc, rpm-build, and the rest of the development tools installed, and you have a little good luck, it’ll just work.

rpmbuild --rebuild ImageMagick-6.5.1.2-1.fc11.src.rpm

If it doesn’t just work, it’ll give you some clues about why. Missing dependencies, etc. This is where luck comes in…as long as the library doesn’t require extremely new versions of any of the libraries it builds against, you should be able to get all of the dependencies it needs using yum. If the versions available on your OS aren’t new enough, it might cause some problems. If you want to bring them up here, I can probably lend some guidance. I’ve built way more than my fair share of RPMs over the years.

hi Joe

I’m really clueless about where to start. I downloaded http://mirrors.kernel.org/fedora/development/source/SRPMS/ImageMagick-6.5.1.2-1.fc11.src.rpm onto my laptop, and reading the spec file gave me the impression I need the devel version in order for APIs such as imagick to work. So I’m not sure if I have the right version or not. But the biggie where I really come unstuck, is how do I go about getting http://mirrors.kernel.org/fedora/development/source/SRPMS/ImageMagick-6.5.1.2-1.fc11.src.rpm onto my server via SSH? Or should I just upload it via filezilla from my laptop, and if so, which directory do I upload it to? (yep, I really am a newbie).

Also, how do I uninstall my existing version of ImageMagck? I tried

[code:1]yum uninstall ImageMagick[/code:1]
but it seems uninstall is not a correct command. I tried

[code:1]yum remove ImageMagick[/code:1]
and that seemed to remove it. But when I check phpinfo(); I see ImageMagick is still there, and when I run one of my image resizing test scripts it still works - ImageMagick is clearly still there.

Cheers
Rob

You’re making this a lot harder than it needs to be. I never look at the spec file until I find out it won’t rebuild cleanly straight from the SRPM, and I wouldn’t remove it. I would just upgrade it once I had a new version.

Get it onto your server (don’t put it on your laptop first…that’s not where you want it, so why download it there?):

wget http://mirrors.kernel.org/fedora/development/source/SRPMS/ImageMagick-6.5.1.2-1.fc11.src.rpm

If you don’t have wget, install it with yum.

Then rebuild:

rpmbuild --rebuild ImageMagick-6.5.1.2-1.fc11.src.rpm

As I mentioned, you will need the gcc, and rpm-build packages at minimum. You can install them from yum. There will be a few dependencies that get installed along with those packages, and it may be all you need. If it isn’t, rpmbuild will ask for other dependencies. Install them using yum.

Bring me anything you don’t understand during the build process.

Don’t uninstall ImageMagick. Upgrade it with the new package:

rpm -Uvh /path/to/new/ImageMagick-blah-blah.i386.rpm

Oh, by the way…in the future, start a new topic when you’re asking an unrelated question. Just because the package happens to be the same, it isn’t the same question as the original poster, and the answers are very different.

hi Joe, yeah, I know downloading it onto my laptop is clueless… but well, I’m clueless. Anyway, I seem to be making a bit of progress now. I had to use yum to install rpm-build before I could run the command

rpmbuild --rebuild ImageMagick-6.5.1.2-1.fc11.src.rpm

but now I have this output:

[root@domU-12-31-39-00-48-05:~] rpmbuild --rebuild ImageMagick-6.5.1.2-1.fc11.src.rpm Installing ImageMagick-6.5.1.2-1.fc11.src.rpm warning: InstallSourcePackage: Header V3 RSA/SHA256 signature: NOKEY, key ID d22e77f2 warning: user mockbuild does not exist - using root warning: group mockbuild does not exist - using root error: unpacking of archive failed on file /usr/src/redhat/SOURCES/ImageMagick-6.4.0-multilib.patch;49fed25a: cpio: MD5 sum mismatch error: ImageMagick-6.5.1.2-1.fc11.src.rpm cannot be installed [root@domU-12-31-39-00-48-05:~]

I used yum again to install mock, but ran into the exact same problem. Seems to be some kind of problem with MD5 sum mismatch. Does this mean the ImageMagick download is corrupted? I tried downloading it 3 times.

BTW, I’ll try to remember the wget command in future so I don’t get so stupidly stuck on basics.

Oh! Yeah, I’ve actually seen that. For some reason the koji build environment produces corrupt MD5 headers.
Try this:

rpm -ivh --nomd5 ImageMagick-6.5.1.2-1.fc11.src.rpm
rpmbuild -bb /usr/src/redhat/SPECS/ImageMagick.spec

I tried that, and got a long list of dependencies which I worked my way through installing via yum. But 3 dependencies remain, and I’m sort of stuck:

[root@domU-12-31-39-00-48-05:~] rpm -ivh --nomd5 ImageMagick-6.5.1.2-1.fc11.src.rpm warning: ImageMagick-6.5.1.2-1.fc11.src.rpm: Header V3 RSA/SHA256 signature: NOKEY, key ID d22e77f2 1:ImageMagick warning: user mockbuild does not exist - using root warning: group mockbuild does not exist - using root warning: user mockbuild does not exist - using root warning: group mockbuild does not exist - using root ########################################### [100%] warning: user mockbuild does not exist - using root warning: group mockbuild does not exist - using root [root@domU-12-31-39-00-48-05:~] rpmbuild -bb /usr/src/redhat/SPECS/ImageMagick.spec error: Failed build dependencies: perl-devel is needed by ImageMagick-6.5.1.2-1.i386 djvulibre-devel is needed by ImageMagick-6.5.1.2-1.i386 jasper-devel is needed by ImageMagick-6.5.1.2-1.i386 [root@domU-12-31-39-00-48-05:~] yum install perl-devel Loading "installonlyn" plugin Setting up Install Process Setting up repositories Reading repository metadata in from local files Parsing package install arguments Nothing to do [root@domU-12-31-39-00-48-05:~]

OK, it’s getting a little intimidating, eh?

If you can wait a day or so, I’ll try to get a package into the bleeding edge repo after I get some sleep (it’s 6:17AM here, I’ve been up all night trying to wrap up the last bits of development on the new website).

So, if you did want to keep poking, you’d want to edit the spec file, and first try changing “perl-devel” to “perl” (I don’t think there is a perl-devel package on CentOS…I think it’s all in “perl”.

djvulibre-devel can just be removed (and check to see if there’s any other mention of it…specifically in the configure section of the spec file). djvu is an obscure format that you aren’t going to care about.

jasper-devel is a jpeg library…but libjpeg is the only jpeg library provided by CentOS. So, maybe try removing the jasper require and replacing it with libjpeg-devel (assuming libjpeg-devel isn’t already mentioned). If there are any other mentions of jasper, you might need to convert them to the correct libjpeg options.

Of course, if ImageMagick has deprecated support for libjpeg, this won’t work. I don’t know. I haven’t built or packaged ImageMagick in many years.

Joe, get some sleep!

No mad hurry to get it done… with patience and perseverance I’ll get it working somehow in the end. I’m not going to give up on it, no matter how intimidating it is - we control the machines - we don’t let the machines beat us!

we control the machines - we don't let the machines beat us!

Indeed, that’s why I’m going to see the new Terminator movie in a few weeks :wink:

If you don’t see an Imagemagick RPM pop up in a good timeframe, just pop a note on here and we’ll work through this further until Joe is able to get the RPM built.

Have a good one,
-Eric

hiya Eric :slight_smile:

I edited the spec file then proceeded to build… after a very long while and seemingly endless amounts of output, I got here:

RPM build errors: File not found by glob: /var/tmp/ImageMagick-6.5.1.2-1-root-root/usr/lib/ImageMagick-6.5.1/modules-Q16/coders/djvu.* File not found by glob: /var/tmp/ImageMagick-6.5.1.2-1-root-root/usr/lib/ImageMagick-6.5.1/modules-Q16/coders/djvu.* [root@domU-12-31-39-00-48-05:~]

I think I might be very close to getting there now… except I can’t find the rpm

[root@domU-12-31-39-00-48-05:~] rpm -Uvh /usr/src/redhat/BUILD/ImageMagick-6.5.1-2.i386.rpm error: open of /usr/src/redhat/BUILD/ImageMagick-6.5.1-2.i386.rpm failed: No such file or directory [root@domU-12-31-39-00-48-05:~]

Using filezilla I can quickly navigate through directories to find stuff, and /usr/src/redhat/BUILD/ImageMagick-6.5.1-2/ is chock-a-block with freshly installed files, but none of them end in i386.rpm

The /usr/src/redhat/RPMS/i386/ directory appears to be empty, though I think I may be getting a bit lost and off course, looking there…

I think the issue is that there’s still a reference to the “djvulibre-devel” related stuff you removed from the dependencies.

Towards the end of the spec file is a section that describes what files are produced by the compile, and what to do with them.

It will probably reference something like:

[code:1]/usr/lib/ImageMagick-6.5.1/modules-Q16/coders/djvu.*[/code:1]

You just need to comment that out or remove it (and anything else with "djvu" mentioned in it). And then rinse and repeat :slight_smile:
-Eric

hehe - that worked!

[root@domU-12-31-39-00-48-05:~] rpm -Uvh /usr/src/redhat/RPMS/i386/ImageMagick-6.5.1.2-1.i386.rpm Preparing... ########################################### [100%] 1:ImageMagick ########################################### [100%] [root@domU-12-31-39-00-48-05:~] rpm -Uvh /usr/src/redhat/RPMS/i386/ImageMagick-devel-6.5.1.2-1.i386.rpm Preparing... ########################################### [100%] 1:ImageMagick-devel ########################################### [100%] [root@domU-12-31-39-00-48-05:~]

Now I’m back to the same problem I had the other week - can’t find ImageMagick in phpinfo();

I restarted apache, reinstalled imagick-2.2.1

Still no sign of it in phpinfo();

Hmmm, I’ve made a right mess of it… or maybe I overlooked something simple and am just one step away from success?

The thing to remember is that Imagemagick is a system library.

What you’re seeing in the phpinfo() output is whether or not a PHP module to support a given system library exists. Installing the system library isn’t enough, you also need to install the related PHP module.

To solve this problem – I looked and saw there was no PHP package/module for Imagemagick on CentOS. From there, I did a Google search (on php imagemagick), and discovered from here that it’s available as a PHP PECL extension:

http://us2.php.net/manual/en/imagick.installation.php

So now what? We just need to figure out how to install PECL extensions, and discover which one to install.

Some more poking on php.net, and we can see that "pecl install MODULENAME" is the syntax we want, and in this case, the module we need is "imagick".

So for you, the next step is to run this:

pecl install imagick

You may at that point need to add this line to activate it to either the system configuration, or the specific Virtual Server php.ini:

extension=imagick.so

Let’s see how that goes :wink:
-Eric