1

The UIImageJPEGRepresentation not return the original image. It will return compressed value of an actual image. Need to load original image data set in NSData. Is there any way to read actual data from image?

1 Answers1

-2

I think you have tried below code to using UIImageJPEGRepresentation

NSData *imageData = UIImageJPEGRepresentation(image, 1.0);

You can convert image to data like this and vice-versa like this.

Convert UIImage to NSData (png) :

UIImage *image = [UIImage imageNamed:@"imageName.png"];
NSData *imageData = UIImagePNGRepresentation(image);

Convert NSData to UIImage :

NSData *data = ... // data that you received
UIImage *image = [UIImage imageWithData:data];
Wolverine
  • 4,264
  • 1
  • 27
  • 49