homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

resizing images
how to compress images so they look right

WebmasterWorld Senior Member 10+ Year Member

Msg#: 4460336 posted 12:51 pm on Jun 1, 2012 (gmt 0)

I am using the functions
to resize images that have been uploaded. But the images don't look right when they are re-sized.
What functions do you need to use to re-size the image so it looks like it has been re-sized in photoshop?



WebmasterWorld Senior Member 10+ Year Member

Msg#: 4460336 posted 3:01 pm on Jun 1, 2012 (gmt 0)

Generally, the advice I see suggests using imagecopyresampled() for better quality. Choosing an appropriate output file type can also often help, especially if you're using a file type that supports a quality setting like .jpg.

I don't have any real expertise with image manipulation, but I've gotten better results using ImageMagick for these tasks than I did with GD. There are a couple of PHP interfaces like IMagick that make it easy, but my current set-up makes that impractical so I just use system() and passthru() to execute the commands I need. For the simple tasks I have, it works fine. Good luck!


WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4460336 posted 4:13 pm on Jun 1, 2012 (gmt 0)

Agreed on ImageMagick, even if you use it just for simple resizing it is more efficient (see below.) What's required is:

- ImageMagick binaries installed (most 'nix installations already have this)
- PHP must be compiled with iMagick, the PHP interface to ImageMagick. Many installations do not have this by default, you'll have to re-compile it or get your host to do so.

GD performs all it's functions in memory. What this means is if you have a compressed jpg, it will map it out in memory as an UNcompressed bitmap, which can often be huge.

For images larger than 2 MB, which is most raw camera images, you will often get "XX bytes of memory exhausted" using GD. In shared environments, you'll rarely be allowed to up the memory usage near anything useful.

ImageMagick performs most of these actions in virtual memory on disk, conserving memory and is generally faster overall. It also has a lot of things you can't do in GD, and does them better.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved