Reading Adobe Photoshop header, Obj-C
Reading Adobe Photoshop header, Obj-C
- Subject: Reading Adobe Photoshop header, Obj-C
- From: Kevin Muldoon <email@hidden>
- Date: Tue, 28 Jun 2011 09:23:51 -0400
Was writing a program to create thumbnails using SIPS, GhostScript,
ImageMagick. During testing I found I needed to read the header file
of Adobe Photoshop native documents directly because Duotone image
color mode simply wasn't returning the proper color mode (in a variety
of programs).
So I threw together this bit of code which works great for the first
tag, but....
// References
//http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#50577409_pgfId-1055726
//http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/psir/ps_image_resources.pdf
NSFileHandle *fileHandler = [NSFileHandle
fileHandleForReadingAtPath:@"/Users/kevin/Desktop/balloon.psd"];
NSData *psdFileHeader = [NSData dataWithData:[fileHandler
readDataOfLength:26]]; // read entire PSD header
NSData *signature = [psdFileHeader subdataWithRange: NSMakeRange(0,4)];
NSData *version = [psdFileHeader subdataWithRange: NSMakeRange(4,2)];
NSData *reserved = [psdFileHeader subdataWithRange: NSMakeRange(6,6)];
NSLog(@"Raw string is '%s' (length %d)\n", [signature bytes],
[signature length]);
NSLog(@"Raw string is '%s' (length %d)\n", [version bytes], [version
length]);
NSLog(@"Raw string is '%s' (length %d)\n", [reserved bytes],
[reserved length]);
As you can see from the output, the 'version' & 'reserved' isn't being
read at all. Must I coerce/parse something here? Much thanks...
[Session started at 2011-06-28 09:14:31 -0400.]
2011-06-28 09:14:31.458 Read Standard Input[65929:10b] Raw string is
'8BPS' (length 4)
2011-06-28 09:14:31.460 Read Standard Input[65929:10b] Raw string is
'' (length 2)
2011-06-28 09:14:31.460 Read Standard Input[65929:10b] Raw string is
'' (length 6)
Kevin Muldoon
e: email@hidden
_______________________________________________
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