getting photoshop to read my multi-layer CGImageRef tiff

559 views Asked by At

Photoshop is making me quite confused.

I am able to create a multi-layer tif image from photoshop and read it into my program (cocoa build)

I am able to create a multi-layer tif in my program and have it read by tiffutil.

photoshop, however, will not recognize my file as a multi-layer tif. Only the first image comes in.

what sort of information do I need to include? And how do I go about doing that? When I write out a gif (kUTTypeGIF) instead of a tif (kUTTypeTIFF) everything turns out fine.


Here's a bit of code to show what I'm doing... (Using Xcode 4.1 CoreFoundation) The below code should take in 3 JPEG images and create separate layers writing out a multi-layer tiff file. It works fine with GIF but not with TIFF

// create CFURLRef for 3 separate images.
NSString *filePath1 = [[NSBundle mainBundle] pathForResource:@"1image" ofType:@"jpg"];
CFURLRef url1 = (CFURLRef)[NSURL fileURLWithPath:filePath1];

NSString *filePath2 = [[NSBundle mainBundle] pathForResource:@"2image" ofType:@"jpg"];
CFURLRef url2 = (CFURLRef)[NSURL fileURLWithPath:filePath2];

NSString *filePath3 = [[NSBundle mainBundle] pathForResource:@"3image" ofType:@"jpg"];
CFURLRef url3 = (CFURLRef)[NSURL fileURLWithPath:filePath3];


// setup to write to data object
NSMutableData          * finalImageData = [NSMutableData data];
CGImageSourceRef       imageSourceRef = nil;
// this one does not work
CGImageDestinationRef  imageDestRef = CGImageDestinationCreateWithData((CFMutableDataRef)finalImageData, kUTTypeTIFF, 3, nil);
// This one works
// CGImageDestinationRef  imageDestRef = CGImageDestinationCreateWithData((CFMutableDataRef)finalImageData, kUTTypeGIF, 3, nil);

// build the final image
imageSourceRef = CGImageSourceCreateWithURL(url1, nil);
CGImageDestinationAddImageFromSource(imageDestRef, imageSourceRef, 0, nil);

imageSourceRef = CGImageSourceCreateWithURL(url2, nil);
CGImageDestinationAddImageFromSource(imageDestRef, imageSourceRef, 0, nil);

imageSourceRef = CGImageSourceCreateWithURL(url3, nil);
CGImageDestinationAddImageFromSource(imageDestRef, imageSourceRef, 0, nil);

CGImageDestinationFinalize(imageDestRef);
CFRelease(imageDestRef);
CFRelease(imageSourceRef);

// write out the final image data
[finalImageData writeToFile:@"outfile.tif" atomically:YES];
// [finalImageData writeToFile:@"outfile.gif" atomically:YES];
0

There are 0 answers