Why is TIFFRepresentation bigger than the actual image file?

437 Views Asked by At

Here's the code I use:

NSImage *image = [[NSBundle bundleForClass:[self class]] imageForResource:@"test.jpg"];
NSData *originalData = [image TIFFRepresentationUsingCompression:NSTIFFCompressionJPEG factor:1.];

The originalData.length gives me 1802224 bytes (1.7MB). While the image size on the disk is 457KB. Why does TIFFRepresentation get larger and which representation I should use in order to get original image (i want to transfer image over the network)?

1

There are 1 best solutions below

2
On

TIFF is much bigger than JPEG. No surprise there.

However, the answer to your actual question is: don't use any "representation". You have the data (namely, the file itself); send it! Don't turn the image file into an NSImage; grab it as an NSData.