Narendra Dhami

My Site

Handling Images with PHP

Posted by Narendra Dhami on July 8, 2008

If you want user interaction on your website then you probably accept the upload of some media, including images. Within PHP there are two different libraries available that provide functionality for handling images. The first is GD which is based on libgd and the second is the Imagick PECL extension.
Which should I use?

Both libraries have their strengths and weaknesses. GD is tightly bundled with PHP and has been enabled by default since 4.3.2, so there is a good chance that any version of PHP you are going to use already has this enabled. Imagick is based on the ImageMagick library and provides similar functionality as well as a few helper functions to make things easier.

If you have deployable code and can’t guarantee what will be available, then you have little choice but to support both libraries. For the purpose of this article I’ll show code samples for both and I’ll also assume that the image file is already uploaded to the server so just the image related parts can be shown. more…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: