ImageMagick installing and exploring it, a good alternative for the GD library

Although PHP GD library handles basic image operations quite good, you have probably run into the limitations of GD library as well, it is often slow, memory intensive and a bit complicated to use for advanced image effects. ImageMagick however is a very good alternative. It is an opensource software suite licensed under a BSD style license from IM itself. ImageMagick provides in all functionality that can be accomplished with the GD library but even goes a step further with support for more advanced image edit techniques. An example of such a technique is the recently added “liquid scaling” feature, this is a content aware scaling option.

Click the image below to see an example of liquid scaling:
Liquid Scaling with imagemagick

So how do I get such a result? Well with PHP GD library it would take a whole lot of code, thinking and beers to get a script that does the same without exceeding your memory_limit, with ImageMagick however it is just one simple command.

exec("convert inputimage.jpg  -liquid-rescale 250x500%\!  outputimage.jpg");

The nice thing about ImageMagick is that you can often accomplish very sophisticated image effects with just one command, you can also chain commands. Now although IM has a quite good documentation guide available you maybe just want to be able to perform basic image operations with IM without seeking your way trough the documentation all the time. Their are some PHP classes available that will make your life easier.

My personal favor is PhMagick or a home brew script, why? Well I like the idea of wrapper classes more, my code is somewhat more portable because I don’t have to install the IM extension on a server and another PHP extension to communicate with it, furthermore I think that using wrapper classes gives you more insight in IM itself, you will better understand what is going on, on the other hand you probably will spend some hours to figure out why the command is not doing what you expected it to do because you are missing a simple ! or ^ parameter option.

Personal experience on installing IM on the server
Some time ago I wanted to install IM on my new dev and live server, the dev server is running OSX and the live server is running a Fedora distribution. So the first step before I tried to install IM was to read the documentation (yeah I’m one of those guys that also actually reads the readme files and documentation 😉 of products). I followed the “Install from source” tutorial. So I started with the live server, after downloading and unpacking IM I ran the ./configure command immediately I was faced with the error “no acceptable c compiler found in $PATH”, now my Linux skills are far from topnotch, so after some googling I found out that the easiest way to fix this issue was to install GCC (GNU Compiler Collection) that already included a C compiler. After installing GCC and running the ./configure command everything went fine, IM was installed successfully. I wanted to test if it was working correctly so I tried to resize several images but again an error occurred “convert: no decode delegate for this image format”, okay perhaps I should read the documentation more carefully next time because before installing IM you should also install the image libraries that you will use. In my case this was “yum install libjpeg libjpeg-devel libpng libpng-devel libtiff libtiff-devel”, now again I needed to install IM again, not much work, but still something to remember when installing IM. On the dev OSX server installing ImageMagick was quite simple, I used a precompiled dmg and only needed to install the Apple XCode developer tools.

So to summarize:

Advantages of using ImageMagick:

  • it uses less resources, forget about the memory_limit issues with PHP when using GD and large images
  • it’s slighty faster (note: depending on the filetype and image size GD beats IM in speed when it comes to resizing
  • Image Magick has support for more filetypes
  • as I showed before, it is very simple to use
    exec('convert "'.$sSourcePath.'" -resize '.$iWidth.'x"'.$sDestinationPath.'"');
  • Some very nice features like liquid scaling or seam carving

Disadvantages of using Image Magick:

  • you need to have full access to your server, it isn’t bundled with PHP
  • compiling IM can give some trouble, you shouldn’t forget to get the image libraries you want to use

Useful links

Comments

4,260 responses to “ImageMagick installing and exploring it, a good alternative for the GD library”

  1. Pedrosot Avatar
    Pedrosot

    pet prescriptions online: Pet Canada Direct – canada pet meds

  2. Jasonelato Avatar
    Jasonelato

    legal online pharmacy: Pharm Rate – pharmacy order online

  3. PatrickAbomy Avatar
    PatrickAbomy

    http://pharmrate.com/# reliable online pharmacy

  4. PeterAwata Avatar
    PeterAwata

    best online pharmacy no prescription https://edmedscoupon.shop/# erection pills online

  5. Charlestag Avatar
    Charlestag

    Pet Canada Direct pet pharmacy online Pet Canada Direct

  6. Pedrosot Avatar
    Pedrosot

    Pharm Rate: Pharm Rate – Pharm Rate

  7. Jasonelato Avatar
    Jasonelato

    online drugs order: Pharm Rate – Pharm Rate

  8. PatrickAbomy Avatar
    PatrickAbomy
  9. Pedrosot Avatar
    Pedrosot

    cheap ed medicine: Ed Meds Coupon – pharmacy websites

  10. Jasonelato Avatar
    Jasonelato

    Pet Canada Direct: Pet Canada Direct – Pet Canada Direct

  11. PeterAwata Avatar
    PeterAwata

    online pharmacy no prescription http://edmedscoupon.com/# how to get ed pills

  12. PatrickAbomy Avatar
    PatrickAbomy

    https://petcanadadirect.com/# vet pharmacy online

  13. Pedrosot Avatar
    Pedrosot

    best online pharmacy: Pharm Rate – medicine online

  14. Charlestag Avatar
    Charlestag

    pet meds official website Pet Canada Direct dog medicine

  15. Jasonelato Avatar
    Jasonelato

    pet prescriptions online: Pet Canada Direct – pet med

  16. PatrickAbomy Avatar
    PatrickAbomy

    http://edmedscoupon.com/# where can i get ed pills

  17. Pedrosot Avatar
    Pedrosot

    п»їed pills online: Ed Meds Coupon – legitimate online pharmacy

  18. PeterAwata Avatar
    PeterAwata

    legal online pharmacy http://edmedscoupon.com/# cheap ed treatment

  19. Jasonelato Avatar
    Jasonelato

    cheap ed meds: cheapest ed meds – overseas pharmacy no prescription

  20. PatrickAbomy Avatar
    PatrickAbomy

    https://petcanadadirect.shop/# online pet pharmacy

  21. Pedrosot Avatar
    Pedrosot

    pet rx: dog medicine – pet med

  22. Charlestag Avatar
    Charlestag

    Pet Canada Direct best pet rx pet drugs online

  23. Jasonelato Avatar
    Jasonelato

    ed drugs online: Ed Meds Coupon – new pharmacy online

  24. PatrickAbomy Avatar
    PatrickAbomy
  25. PeterAwata Avatar
    PeterAwata

    overseas online pharmacy http://pharmrate.com/# Pharm Rate

  26. Pedrosot Avatar
    Pedrosot

    Pharm Rate: legal online pharmacies in the us – legit online pharmacy

  27. Jasonelato Avatar
    Jasonelato

    online vet pharmacy: pet rx – canada pet meds

  28. DanielAnank Avatar
    DanielAnank

    https://antibiotics.cheap/# over the counter antibiotics

  29. Edgaraligh Avatar
    Edgaraligh

    generic antibiotics online cheap: get antibiotics quickly – over the counter antibiotics

  30. PedroMorne Avatar
    PedroMorne

    https://stromectol.reviews/# stromectol reviews

  31. DavidBam Avatar
    DavidBam

    generic ivermectin stromectol reviews stromectol reviews

  32. EliasRaiff Avatar
    EliasRaiff

    stromectol coronavirus: ivermectin generic cream – stromectol reviews

  33. DanielAnank Avatar
    DanielAnank

    https://semaglutide.life/# semaglutide thyroid

  34. Edgaraligh Avatar
    Edgaraligh

    over the counter antibiotics: over the counter antibiotics – antibiotics over the counter

  35. DanielAnank Avatar
    DanielAnank

    https://stromectol.reviews/# stromectol reviews

  36. PedroMorne Avatar
    PedroMorne

    https://antibiotics.cheap/# buy antibiotics from india

  37. EliasRaiff Avatar
    EliasRaiff

    antibiotics cheap: antibiotics cheap – over the counter antibiotics

  38. Edgaraligh Avatar
    Edgaraligh

    antibiotics cheap: uti antibiotics online – over the counter antibiotics pills

  39. DavidBam Avatar
    DavidBam

    over the counter antibiotics antibiotics cheap over the counter antibiotics

  40. DanielAnank Avatar
    DanielAnank

    https://semaglutide.life/# difference between ozempic and rybelsus

  41. Edgaraligh Avatar
    Edgaraligh

    rybelsus vs wegovy for weight loss: compounded semaglutide reviews – buy drugs online

  42. PedroMorne Avatar
    PedroMorne

    https://stromectol.reviews/# stromectol 6 mg dosage

  43. 免费Binance账户 Avatar

    Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  44. EliasRaiff Avatar
    EliasRaiff

    stromectol reviews: ivermectin brand – stromectol oral

  45. DanielAnank Avatar
    DanielAnank

    https://semaglutide.life/# semaglutide maintenance dose every other week

  46. Edgaraligh Avatar
    Edgaraligh

    (rybelsus): semaglutide shelf life – top online pharmacy

  47. Регистрация в binance Avatar

    I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  48. DavidBam Avatar
    DavidBam

    antibiotics online pharmacy antibiotics cheap п»їbuy antibiotics

  49. DanielAnank Avatar
    DanielAnank

    https://stromectol.reviews/# cost of ivermectin pill

Leave a Reply

Your email address will not be published. Required fields are marked *