Reduce UIImage size to a manageable size (reduce bytes)?

If you wish to simply compress your UIImage, you can use.

If you wish to simply compress your UIImage, you can use NSData *dataForPNGFile = UIImagePNGRepresentation(yourImage); to generate an NSData version of your image encoded as a PNG (easily inserted into an NSDictionary or written to disk), or you can use NSData *dataForPNGFile = UIImageJPEGRepresentation(yourImage, 0.9f); to do the same, only in a JPEG format. The second parameter is the image quality of the JPEG. Both of these should produce images that are smaller, memory-wise, than your UIImage.

Resizing a UIImage to create a smaller thumbnail (pixels-wise) using published methods is a little trickier. _imageScaledToSize is from the private API, and I'd highly recommend you not use it. For a means that works within the documented methods, see this post.

I ran into this problem the other day and did quite a bit of research. I found an awesome solution complete with code here: vocaro.com/trevor/blog/2009/10/12/resize....

You need to draw the image into a graphics context at a smaller size. Then, release the original image.

“reduce bytes” “physical size, not dimension size” I do believe he wants to compress the image without changing its dimensions. – Peter Hosey Jan 28 '09 at 23:35 Yeah, I think you're right. I misinterpreted it as being "I want to reduce the number of pixels, not make the overall dimensions smaller." – Mike Abdullah Jan 29 '09 at 0:22.

Because you can just change the printer page size. Are you talking about the number of pixels used to capture the image? As in, if you have a pixel array of 3000x2000, and you only want 150x150, then you can crop the images.

At the time of capture, if you have a scientific imager, then you can just set the area that will be captured. The camera driver would include instructions for that. If you want to capture 3000x2000 in 1500x1000, you can try to bin the image, if that's what you need.

Or, you can use resampling post-capture in order to make the image smaller. One such algorithm is bicubic resampling, also linear resampling-- there are many variations. I'm thinking this last is what you're most interested in... in which case, check out this Wikipedia page on the algorithm.

Or, you can go to FreeImage and get a library that will read in the image and can also resize images.

Thanks for your input, but i'm looking for built in classes in ObjectiveC that can serve the purpose. Don't have time to write the algos from scratch. Thanks.

– Mustafa Jan 29 '09 at 14:14.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions