Jump to content
Larry Ullman's Book Forums

Resizing Images Without Losing Quality.


Recommended Posts

i'm currently confused on how to resized an image without losing its quality. for example i have 1920x1080 picture and i resized it to 400x225 i am bit satisfy as it succeeded but the things is that, the picture losed its resolution. my formula is here: new height = (original height/original width) * new width and vice versa. while maintaining the aspect ratio i noticed that the resolution degrades and get pixelated. any advice sir?

Link to comment
Share on other sites

Do you use JPEG or PNG here? The last argument for imagejpeg() will allow you to set the image quality. The standard is 75, so raising the number will improve the quality.

 

The reason for loss in quality is that the algorithms used in GD are bad compared to the ones in Photoshop. (that's their job) Writing good compression algorithms is tricky.

 

You can switch to PNG, but it will store larger files. Hope that helps.

Link to comment
Share on other sites

As Antonio stated, image editing software is much better at resizing images (because that's what it's designed to do).

Something else that's important to consider is the fact that loading a large image to display a tiny thumbnail is often a waste of resources and time consuming.

As such, the best approach is generally to use Photoshop to create a second, smaller version of images and then use both versions of the images on the site as necessary.

Link to comment
Share on other sites

Timthumb is also an alternative if you don't want to store images on the server (well it does cache images after the first http request) and dynamically resize them by simply passing height and width as parameters to the timthumb script:

 

http://code.google.com/p/timthumb/

 

 

I particularly like it because there is no overhead of storing images, or confining your scripts to a certain height/width. Usage is also fairly simple.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...