08th Aug2014

Best way to manipulate images using PHP?

by Gyro

I have deployed lots of different solutions to manipulate images with PHP, but today I stumbled upon probably the best PHP library out there.

It is called WideImage (requires PHP 5.2+ with GD2 extension), and it makes resizing, cropping, rotating, adding watermarks. and much more super easy.

Check out WideImage, I'm sure you'll love it!

Enjoy! :crazy:

748

23rd Jan2014

Update/Install ImageMagick on CentOS 5 and CentOS 6

by Gyro

Today I had a classic example of what happens when you do not RTFM. I had to install ImageMagick on a webserver running CentOS 5 with cPanel. First I simply ran "yum install imagemagick", which did install ImageMagick just fine.

Now, the reason I had to install it was to do a batch resize of about 20,000 images and place the resized images in a new directory. So I did:
# mogrify -resize 250 -quality 70 -path /home/somesite/public_html/image/thumbs/ -format jpg /home/somesite/public_html/images/*

To my surprise I got the error message:

mogrify: unrecognized option `-path'.

After a quick google search, I realized that yum installed a super old version that was not supporting the -path option?!

So, after some more searching, I found this great guide on how to Install ImageMagick 6.6.5 and followed the instructions. But when I got to the final installation command, I got a dependencies error?!

After another google search, I came across a forum post saying "Make sure that RPMForge repository is installed first, and then everything works."… and when I looked back at the guide, I realized that it did in fact tell me to do that. The reason I did not see it was because it was a one liner with a link to another website, and I was expecting to be able to simply copy paste commands, so I skipped reading that line. I did not RTFM properly…

So, to make it easy for the future, I will combine these two pages, in order to have a step by step set of instructions without having to go to another website :)

Before starting, make you sure you know whether you are using a 32-bit or 64-bit system.
# uname -i
x86_64 would be 64-bit

OK, here we go!

1. Uninstall ImageMagick

# rpm -e --nodeps ImageMagick.i386 ImageMagick-devel.i386 ImageMagick.x86_64 ImageMagick-devel.x86_64
this actually didn't work for me, so I did:
# yum remove imagemagick

2. Add the EPEL repository to yum:

CentOS 6:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
CentOS 5:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

3. Download and Install RPMforge (Check here for newer version.)

CentOS 6:
Download RPMforge for 32-bit systems: rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
Download RPMforge for 64-bit systems: rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Install DAG's GPG key:
# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

If you get an error message like the following the key has already been imported:
error: http://apt.sw.be/RPM-GPG-KEY.dag.txt: key 1 import failed.

Verify the package you have downloaded:
# rpm -K rpmforge-release-0.5.3-1.el6.rf.*.rpm

Install RPMforge:
# rpm -i rpmforge-release-0.5.3-1.el6.rf.*.rpm

CentOS 5:
Download RPMforge for 32-bit systems: rpmforge-release-0.5.3-1.el5.rf.i386.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm
Download RPMforge for 64-bit systems: rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm

Install DAG's GPG key:
# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

If you get an error message like the following the key has already been imported:
error: http://apt.sw.be/RPM-GPG-KEY.dag.txt: key 1 import failed.

Verify the package you have downloaded
# rpm -K rpmforge-release-0.5.3-1.el5.rf.*.rpm

Install RPMforge
# rpm -i rpmforge-release-0.5.3-1.el5.rf.*.rpm

4. Install dependencies for ImageMagick 6.6

For 32-bit systems:
# yum install djvulibre OpenEXR jasper ghostscript librsvg2 libwmf libtool-ltdl
For 64-bit systems:
# yum install djvulibre OpenEXR jasper ghostscript librsvg2.x86_64 libwmf.x86_64 libtool-ltdl.x86_64

Systems running CentOS 6 will need the old version of libtool-ltdl installed:
For 32-bit systems:
# rpm -ivh --force ftp://ftp.muug.mb.ca/mirror/centos/5.9/os/i386/CentOS/libtool-ltdl-1.5.22-7.el5_4.i386.rpm
For 64-bit systems:
# rpm -ivh --force ftp://ftp.muug.mb.ca/mirror/centos/5.9/os/x86_64/CentOS/libtool-ltdl-1.5.22-7.el5_4.x86_64.rpm

5. Download and Install ImageMagick 6.6.5

Download for 32-bit systems: ImageMagick-6.6.5-10.i386.rpm
# wget http://www.lassosoft.com/_downloads/public/Lasso_Server/CentOS-Extra/ImageMagick-6.6.5-10.i386.rpm
Download for 64-bit systems: ImageMagick-6.6.5-10.x86_64.rpm
# wget http://www.lassosoft.com/_downloads/public/Lasso_Server/CentOS-Extra/ImageMagick-6.6.5-10.x86_64.rpm

Install ImageMagick
# rpm -ivh ImageMagick-6.6.5*

DONE! :crazy:

9723

14th Jun2012

Photoshop CS crashing when opening complex PSD files using Ubuntu/wine

by Gyro

I installed the new Photoshop CS6 trial version on Ubuntu using Wine 1.5.5, and had a strange error when I tried to open a complex psd file with multiple layers etc, Photoshop would just crash.

As much as I hate the way email lists look when searching for something, this time they were the only source I could find with the solution for this annoying problem.

(more…)

2537

18th May2012

Using touch and imagemagick To create PDF files

by Gyro

Dean Howell from ThePowerBase.com has written an excellent guide for Linux (Ubuntu/Debian) users on how to use imagemagick to create multi-page PDF files with ease.

(more…)

1072

13th May2012

Best Free Screenshot and Screen Capture Software 2012

by Gyro

If you are using Ubuntu (or another Linux Distro with the same GUI), I have a real treat for you!

Check out Nanoshot, it's probably the most handy screen capturing tool there is.

(more…)

2176