• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reading Adobe Photoshop header, Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Reading Adobe Photoshop header, Obj-C
      • From: Thomas Engelmeier <email@hidden>
    • Re: Reading Adobe Photoshop header, Obj-C
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: sorting a pair of arrays
  • Next by Date: Re: dispatch_async Performance Issues
  • Previous by thread: Re: sorting a pair of arrays
  • Next by thread: Re: Reading Adobe Photoshop header, Obj-C
  • Index(es):
    • Date
    • Thread