Resizing an image with PHP

Hi,

In my application, I need to change the dimensions of an uploaded image. I did some research and learned that it was possible with the GD extension. I was wondering if there is another way which doesn’t require an extension.

Thanks for any ideas.

What is you reason for not using GD; It has been included in php for years.

SOLVED I revised my code using jQuery and I don’t need image resizing anymore, found an alternative way to accomplish what I wanted.

The reason is that this is an application that will be distributed and I didn’t want “You should have GD extension enabled” type of requirement in my application.

If you don’t want an extension then you can use ImageMagick if it is installed on the server, then you can run ImageMagick’s commands (convert, mogrify, etc.) directly with exec() in php. Many hosts have ImageMagick installed, some don’t. There’s also Imagick php extension for using ImageMagick so that is also an option if it’s installed.

I always use ImageMagick for image resizing and manipulation in php - in comparison with GD it creates better quality images, has more features, it’s faster and doesn’t choke on large images. Nowadays so many hosts offer ImageMagick that it’s not a problem at all - unless you want to make a distributed library for others to download and it needs to work on as many platforms as possible.

I hope your jQuery solution is not resizing images in the browser. Sometimes I can see web galleries where small thumbnails are actually large images that are made smaller in the browser by changing <img> dimensions - such pages are slow to load, waste bandwidth and often the quality of the small thumbnails is not very good.

Thanks for your detailed reply. If I ever need image resizing on my own website, I will most probably use it but as I said above, this application will be distributed and I can’t have GD or ImageMagick as a requirement. I just wanted to know if there was another PHP way and it seems not.

There is only one image in one certain section that is resized so even if it is resizing in the browser, that will not be a problem.

Can’t you just check if GD is available and if so use it, otherwise use the jQuery plugin? GD will be available most of the cases, making for a much nicer solution IMHO.