Re: TIFFRepresentation makes big file!
Re: TIFFRepresentation makes big file!
- Subject: Re: TIFFRepresentation makes big file!
- From: Jean-Daniel Dupas <email@hidden>
- Date: Thu, 11 Dec 2008 14:51:24 +0100
Le 11 déc. 08 à 14:05, Caroline a écrit :
Hello all,
I have some Questions.
1. I try to write NSImage to file.
NSImage *image = [NSImage imageNamed:@"test.png"];
NSBitmapImageRep *imageRep;
imageRep = [[NSBitmapImageRep alloc] initWithData:[image
TIFFRepresentation]];
NSData *imageData;
imageData = [imageRep representationUsingType:NSPNGFileType
properties:nil];
[imageData writeToFile:@"result.png" atomically:YES];
I got "result.png".
But!!
"result.png" has diffrent size with "test.png".
When I try to NSLog(@"image info : %@",test.png); and NSLog(@"image
info : %@",result.png);
Then, test.png (original image) size is {1599.8, 1199.85} and
result.png size is {1600,1200}.
Why?
Why do they have different file size?
Where is wrong? or TIFFRepresentation rounded up?
NSImage size is not the pixel size, but the screen size. This size is
computed using image resolution and image pixel size.
According to the original size, I think NSImage use 72.01 ppi for the
resolution. Converting to TIFF and then back to PNG probably affect
the resolution and change it to 72.
But the actual image size in pixel does not change.
2. And, Some original/saved files have same width, height size, But
they have different file size!!
Although 'test.png' and 'result.png' are {1600,1200}, But they have
500KB(test.png) and 700KB(result.png).
I know the PNG file doesn't compress, so I don't know why they have
different file size...
What make you think so ?
http://en.wikipedia.org/wiki/Portable_Network_Graphics#Compression
3. Last one,
when I use JPEG file, I have to know the compression of original
image.
(When I save the new image, compression is needed.)
How can I know/get the compression of JPEG file?
I don't think the compression factor is saved in the file (and I don't
think it is relevant, as it is compressor dependent).
NSImage does not provide lossless jpeg editing, and you have to
recompress the file if you change it .
This recompression will alter the image quality whatever your
compression factor is, and whatever the original factor was.
You should probably either use a default value you choose, or ask the
use what he want to use (as all compressor do).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden