For questions related to the UIImageJPEGRepresentation method for the UIImage class on the iOS platform, a method commonly used to convert images to JPEG.
Questions tagged [uiimagejpegrepresentation]
91 questions
84
votes
9 answers
How to zoom in/out an UIImage object when user pinches screen?
I would like to zoom in/out an UIImage object when the user performs the standard pinch action on my application. I'm currently using a UIImageView to display my image, if that detail helps in any way.
I'm trying to figure out how to do this, but no…

jpm
- 16,622
- 34
- 63
- 66
26
votes
7 answers
image compression by size - iPhone SDK
I would like to compress images (camera/photo library) and then send it to the server. I know I can compress by height and width, but I would like to compress the images by size to a fixed size (200 KB) only and keep the original height and width.…

DonDyck
- 1,451
- 5
- 20
- 35
24
votes
3 answers
What should compressionQuality be when using UIImageJPEGRepresentation?
I would like to apply a filter to a photo from the user's library then write it back to disk. I'm using UIImageJPEGRepresentation. This function takes a UIImage and a compressionQuality value between 0.0 and 1.0. Because I want to preserve the…

Jordan H
- 52,571
- 37
- 201
- 351
18
votes
3 answers
Using ALAssetsLibrary and ALAsset take out Image as NSData
I wish to extract the image using ALAssetsLibrary and ALAsset directly in the form of a NSData object.
Using a NSURL I take out the image in the following manner.
NSURL *referenceURL =newURL;
ALAssetsLibrary *library = [[ALAssetsLibrary alloc]…

Shishir Shetty
- 2,021
- 3
- 20
- 35
12
votes
2 answers
How to compress image size using UIImagePNGRepresentation - iOS?
I'm using UIImagePNGRepresentation to save an image. The result image is of size 30+ KB and this is BIG in my case.
I tried using UIImageJPEGRepresentation and it allows to compress image, so image saves in < 5KB size, which is great, but saving it…

Hyder
- 1,163
- 2
- 13
- 37
11
votes
1 answer
iOS UIImageJPEGRepresentation error: Not a JPEG file: starts with 0xff 0xd9
I am writing a .jpg file to my app's Documents directory like this:
NSData *img = UIImageJPEGRepresentation(myUIImage, 1.0);
BOOL retValue = [img writeToFile:myFilePath atomically:YES];
Later, I load that image back into a UIImage using:
UIImage…

viperacr99
- 423
- 2
- 5
- 10
8
votes
1 answer
PNG/JPEG representation from CIImage always returns nil
I'm currently making a photo editing app.
When a photo is selected by the user, it is automatically converted into black and white using this code:
func blackWhiteImage(image: UIImage) -> Data {
print("Starting black & white")
let orgImg =…

benfernandes
- 179
- 3
- 13
7
votes
2 answers
Given a CIImage, what is the fastest way to write image data to disk?
I'm working with PhotoKit and have implemented filters users can apply to photos in their Photo Library. I am currently obtaining the image, applying a filter, returning the edited version as a CIImage, then I convert the CIImage into NSData using…

Jordan H
- 52,571
- 37
- 201
- 351
6
votes
1 answer
Why are images from UIImagePickerController sometimes cropped incorrectly?
Sometimes images picked from the photo album with UIImagePickerController are cropped differently than how the user wants to crops it. This happens in approx. 1 of 50 image uploads.
When it happens the images are always cropped to a part of the…

Manuel
- 14,274
- 6
- 57
- 130
6
votes
1 answer
Why .jpeg file save via writetofile using UIImageJPEGRepresentation method have large size then UIImageWriteToSavedPhotosAlbum in ios
I am trying to save an UIImage object to an .jpeg file in device
and I am using this code:
-(void)saveImageToDocumentsDirectory:(UIImage *)mimage withFileName:(NSString *)fileName
{
UIImageWriteToSavedPhotosAlbum(mimage,nil,nil,nil);
NSData…

Sushobhit
- 305
- 4
- 18
6
votes
1 answer
How to get exact size of image in bytes?
I have calculated image size in bytes by converting image into NSData and its data length got wrong value.
NSData *data = UIImageJPEGRepresentation(image,0.5);
NSLog(@"image size in bytes %lu",(unsigned long)data.length);

Nagendra
- 357
- 2
- 13
5
votes
0 answers
UIImageJPEGRepresentation throws EXC BAD ACCESS
I have function, which received 2 arguments - image and number. Function below throws EXC BAD ACCESS on line "imgData = UIImageJPEGRepresentation(image, 1.0);". I don't know why :-( Any ideas?
- (void)saveImages:(UIImage*)image row:(int)row {
if…

Michal Jurník
- 820
- 1
- 8
- 23
5
votes
1 answer
From the results of UIImagePickerControlleHow, how do I get JPEG with metadata included in it?
On iOS 4.2 when I use UIImagePickerController to let the user select a image from the photo library these are the dictionary keys that are returned to me:
2011-03-02 13:15:59.518 xxx[15098:307] didFinishPickingMediaWithInfo:
info dictionary: {
…

Chris Markle
- 2,076
- 4
- 25
- 46
5
votes
1 answer
UIImageJPEGRepresentation - memory release issue
On a iPhone app, I need to send a jpg by mail with a maximum size of 300Ko (I don't no the maximum size mail.app can have, but it's another problem). To do that, I'm trying to decrease quality until obtain an image under 300Ko.
In order to obtain…

FredM
- 175
- 2
- 9
5
votes
3 answers
how to know this image is jpg or png iphone
i will like to pick an images from UIImagepicker, there are PNG and JPG format in camera roll.
and i need to convert it into NSData. However i need to know if this images is UIImageJPEGRepresentation or UIImagePNGRepresentation so i could convert…

Desmond
- 5,001
- 14
- 56
- 115