Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
jabsalud

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?

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...