Hi All,
I have a big question in my mind that, When we use cropping functionality on a re-sized image do we lose quality?
Suppose original image dimensions are 4500X4500 and when this gets uploaded we can not display this much size image on the webpage or webscreen. So we need to resize it to some 50% or 25% to provide the crop functionality on the image.
So because of this resize functionality on the original image do we lose the quality or it will be having perfect quality of the image?
When we upsample the image do we lose quality? if so what is the necessary step i need to take not to lose the quality of the image/picture?
Please kindly get me the guidance how to handle this issue.
Waiting for your reply.
Thanks and regards,
Dharprog
Php GD Question for Crop and resize
Moderator: General Moderators
Re: Php GD Question for Crop and resize
Think about it. Just think about it for a second.
When you resize an image you go from X number of pixels to Y number of pixels:
- If X>Y (shrinking) then those X-Y pixels are lost. You cannot get them back. There is no Recycle Bin for pixels.
- If X<Y (enlarging) then you're creating Y-X pixels out of thin air. You aren't "undeleting" them from a previous image.
When shrinking you lose quality. Generally you get around this by manipulating the original image* and trying to combine multiple colors into one pixel. It can look good, but you've still lost quality.
When enlarging you gain fake quality, and if you enlarge too much then the larger image typically looks worse than the smaller original.
* And by this I mean manipulating the cropped image... Easy to misunderstand that, I know
When you resize an image you go from X number of pixels to Y number of pixels:
- If X>Y (shrinking) then those X-Y pixels are lost. You cannot get them back. There is no Recycle Bin for pixels.
- If X<Y (enlarging) then you're creating Y-X pixels out of thin air. You aren't "undeleting" them from a previous image.
When shrinking you lose quality. Generally you get around this by manipulating the original image* and trying to combine multiple colors into one pixel. It can look good, but you've still lost quality.
When enlarging you gain fake quality, and if you enlarge too much then the larger image typically looks worse than the smaller original.
* And by this I mean manipulating the cropped image... Easy to misunderstand that, I know
Last edited by requinix on Wed Aug 04, 2010 7:43 am, edited 1 time in total.
Re: Php GD Question for Crop and resize[Solved]
This is absolutely true and found the solution how i can handle it now without losing any quality for cropping.tasairis wrote:Think about it. Just think about it for a second.
When you resize an image you go from X number of pixels to Y number of pixels:
- If X>Y (shrinking) then those X-Y pixels are lost. You cannot get them back. There is no Recycle Bin for pixels.
- If X<Y (enlarging) then you're creating Y-X pixels out of thin air. You aren't "undeleting" them from a previous image.
When shrinking you lose quality. Generally you get around this by manipulating the original image and trying to combine multiple colors into one pixel. It can look good, but you've still lost quality.
When enlarging you gain fake quality, and if you enlarge too much then the larger image typically looks worse than the smaller original.
Thanks a lot.
Re: Php GD Question for Crop and resize
Cropping & resizing are different. Cropping means cutting out part of the picture. Resizing means keeping the entire picture, but changing the dimensions. Cropping will not lose you any quality, but you will lose part of the picture.
Resizing either up or down will always result in a loss of detail. Always. If you use imagecopyresampled() instead of imagecopyresized(), then the loss in quality will be much less. Basically exactly what ~tasairis said.
Resizing either up or down will always result in a loss of detail. Always. If you use imagecopyresampled() instead of imagecopyresized(), then the loss in quality will be much less. Basically exactly what ~tasairis said.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Php GD Question for Crop and resize
Hi Pickle,
The difference is correct, And i will use imagcopyresized() as per your suggestion to not to lose the quality.
Thank you very much for valuable suggestion for both of you.
Thanks and regards,
Dharprog
The difference is correct, And i will use imagcopyresized() as per your suggestion to not to lose the quality.
Thank you very much for valuable suggestion for both of you.
Thanks and regards,
Dharprog
Re: Php GD Question for Crop and resize
1. imagecopyresampled will lose quality. What pickle said was that the loss in quality would be less, not zero.
2. If you're concerned about quality, don't use GD. It's good for quick-n-dirty tasks but isn't good for need-it-done-well tasks. Try ImageMagick instead.
2. If you're concerned about quality, don't use GD. It's good for quick-n-dirty tasks but isn't good for need-it-done-well tasks. Try ImageMagick instead.
Re: Php GD Question for Crop and resize
Did you mean that, ImageMagick is more efficient than GD? And is this ImageMagick good quality results in image processing?tasairis wrote:1. imagecopyresampled will lose quality. What pickle said was that the loss in quality would be less, not zero.
2. If you're concerned about quality, don't use GD. It's good for quick-n-dirty tasks but isn't good for need-it-done-well tasks. Try ImageMagick instead.
If it is so then i will be going working with ImageMagick for all the image processing tasks.
Thanks and regards,
Dharprog
Re: Php GD Question for Crop and resize
It's pointless (not to mention difficult) to compare "efficiency" between the two. ImageMagick is better than GD at everything I can think of, with the disadvantage that it doesn't come bundled with PHP so you have to install it yourself - on shared hosting that can be a problem.