开发者

Reduce DPI resolution of UIImage

I am sending an image via-email using mfmailcomposeviewcontroller:

[mailComposer addAttachmentData:UIImageJPEGRepresentation(self.开发者_如何学JAVAeditedImageView.image, 1.0f)
                           mimeType:@"image/jpeg" 
                           fileName:@"yourPhotoWithBestGlasses.jpg"];

The picture I see in my email is 160 DPI resolution.

How can I reduce it to 72 DPI, to decrease kb size, without losing quality?


NSData = UIImageJPEGRepresentation(rightPhoto, 0.5);

then initwithdata back .

the detail code

NSData *imageData = UIImageJPEGRepresentation(originalImage, 0.5);

UIImage *tImage = [[UIImage alloc] initWithData:imageData];

originalImage = [tImage copy];

[tImage release];


You can't really reduce the kb size without compromising quality in some way. Also, it's misleading to talk about DPI as a measure of an image's resolution; you'd do better to look at reducing the pixel size. A 160dpi image at 10x10 inches is the same in terms of pixels as a 72dpi image at 22.2x22.2 inches, so one would be resized and the other would not, despite both images looking exactly the same on a computer monitor, and both images requiring the same number of bytes.

The important part of the answer though is that you're going to have to compromise quality, either by pixel size, or by JPEG compression quality.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜