My application is downloading a set of image files from the network, and saving them to the local iPhone disk. Some of those images are pretty big in size (widths larger than 500 pixels, for instance). Since the iPhone doesn't even have a big enough display to show the image in its original size, I'm planning on resizing the image to something a bit smaller to save on space/performance.
Also, some of those images are JPEGs and they are not saved as the usual 60% quality setting.
How can I resize a picture with the iPhone SDK, and how can I change the quality setting of a JPEG image?
If anyone still looking for better option
you can use this code to scale image in required size.
If you image is in document directory, Add this URL extension:
Usage:
Note:- Change < LocalImagePath.jpg > with your local jpg image path.
I ended up using Brads technique to create a
scaleToFitWidth
method inUIImage+Extensions
if that's useful to anyone...then wherever you like
#import "UIImage+Extensions.h"
UIImage *newImage = [image scaleToFitWidth:100.0f];
Also worth noting you could move this further down into a
UIView+Extensions
class if you want to render images from a UIViewAdding to the slew of answers here, but I have gone for a solution which resizes by file size, rather than dimensions.
This will both reduce the dimensions and quality of the image until it reaches your given size.
Credit for scaling by size answer
Try this,It work for me,