exporting image files to disk using CGImageDestination
exporting image files to disk using CGImageDestination
- Subject: exporting image files to disk using CGImageDestination
- From: Kevin Meaney <email@hidden>
- Date: Mon, 24 Feb 2014 17:00:28 +0000
I've written a command line tool that takes an image file (when testing I'm using JPEG files) and applies a custom CIFilter (a naive chroma key filter I've written) and saves a file to disk. Sampling the command line tool when processing files shows it is spending 90% of its time writing the png file of which most of this time is spent in a function called deflate in libz. The final file quality is good. I'm using CGImageDestination to export the file with default settings. I thought I'd try exporting the image file as tiff instead using CGImageDestination with default settings. The command line tool is about 5 times faster but the display of the tiff file in Preview is much worse than the display of the png file.
The tiff files are about twice the size of the png files. I've now tried setting kCGImageDestinationLossyCompressionQuality to 1.0 when adding an image to be exported to the CGImageDestination object when exporting as tiff without any improvement in the tiff image quality.
Trying to see what the problem with tiff file image is, it is almost like there is only a 1 bit alpha channel. But checking the tiff image file using tiffinfo gives:
Image Width: 2272 Image Length: 1704
Bits/Sample: 8
Sample Format: unsigned integer
Compression Scheme: none
Photometric Interpretation: RGB color
Alpha: Present
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 4
Rows/Strip: 14
Number of Strips: 122
Planar Configuration: Not planar
Profile Name: sRGB IEC61966-2.1
I don't particularly care whether I am exporting as tiff or png, and not too fussed about the file size. But I'd like the quality I'm getting with the png file but I would like saving to be faster. Does anyone have suggestions? Is there a known issue(s)?
I've just tried exporting as png with the kCGImageDestinationLossyCompressionQuality set to 1.0 but this doesn't change things.
I hadn't really expected kCGImageDestinationLossyCompressionQuality to make a difference as it seems really designed for saving jpeg files. The only thing I've not tried but like setting kCGImageDestinationLossyCompressionQuality it seems pointless. I could try LZW compression when saving the tiff file. But since both uncompressed and LZW are meant to be lossless I can't see how this could make a difference. The PNG file reports the same colorspace, profile and bits per channel as the tiff file and contains an alpha channel.
Kevin
_______________________________________________
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