Hi -%26lt;br /%26gt;%26lt;br /%26gt;I'm trying to read a layered TIFF image generated by Photoshop, and according to the TIFF Technical notes (http://partners.adobe.com/public/developer/en/tiff/TIFFphotoshop.pdf) page 11 , the ImageSourceData section should start with the null terminated character sequence, ''Adobe Photoshop Document Data Block''. However on, reading I get:%26lt;br /%26gt;%26lt;br /%26gt;%26lt;xapMM:DocumentID%26gt;adobe:docid:photoshop:688c7d73-5fb3-11db-97df-d46af1c0ee86%26lt; /xapMM:DocumentID%26gt;%26lt;br /%26gt; %26lt;/rdf:Description%26gt;%26lt;br /%26gt;%26lt;br /%26gt;%26lt;/rdf:RDF%26gt;%26lt;br /%26gt;%26lt;/x:xapmeta%26gt;%26lt;br /%26gt;%26lt;br /%26gt;// lots of space%26lt;br /%26gt;%26lt;br /%26gt;%26lt;?xpacket end='w'?%26gt; %26lt;br /%26gt;%26lt;br /%26gt;Before I get the 4 byte signature, '8BIM' (I had to read till I encountered the null character to get all that). Also, the next 4 bytes I isn't aren't the characters, 'Layr', 'LMsk', 'Patt', or 'Anno' as the docs say. %26lt;br /%26gt;%26lt;br /%26gt;Has Adobe changed the structure of its TIFF image? Thanks,%26lt;br /%26gt;%26lt;br /%26gt;- OlumideReading/Parsing a Photoshop generated...
You're off by a few bytes in reading the data.
What you show is partway into the XMP data block.
Reading/Parsing a Photoshop generated...
Got it, thanks. 
All I had to do was to read the offset value of the ImageSourceData tag.
I've finally got my program to the point where it is able to read and decode RLE (Packbits) compressed pixel data by layer. Here's a sample output of my program's pixel count per channel per layer (after decompression of RLE)
// Layer 1
[Channel -1] Pixel count: 31381
[Channel 0] Pixel count: 29728
[Channel 1] Pixel count: 29728
[Channel 2] Pixel count: 29728
// Layer 2
[Channel -1] Pixel count: 61530
[Channel 0] Pixel count: 52202
[Channel 1] Pixel count: 52202
[Channel 2] Pixel count: 52202
// Layer 3
[Channel -1] Pixel count: 71170
[Channel 0] Pixel count: 55406
[Channel 1] Pixel count: 55406
[Channel 2] Pixel count: 55406
Here's the question. I thought the pixel count for each was supposed to be the equal to: image_width * image_height ??? Also, these pixel counts are not equal to:
(layRecords-%26gt;bottom - layRecords-%26gt;top) * (layRecords-%26gt;right - layRecords-%26gt;left)
... in my case, it isn't :-( . My image is 600 x 600 .
Thanks.
Channel -1?
Normally computer arithmetic starts at zero....
You could be using the wrong compression scheme or otherwise are off in the data somewhere.
Also, layers can write only the non-blank potions (keep the file a lot smaller).
That's why each layer has another rect associated with it.
According to the Photoshop file format specification (which that Photoshop's layered TIFFs are based on), the channel ID -1 indicates the transparency mask, 0 for red, 1 for green etc. 
On blank and non blank protions, I guessed thats done to keep file sizes smaller, but and thats why I calculated 
(layerRecords.top - layerRecords.bottom) * (layerRecords.right - layerRecords.left). In each case, the answer did not equal the pixel count I got after decompressing the RLE data. 
... I wonder why the transparency channel pixel count isn't equal to the the pixel count values I got for the other layers? Is this normal?
Thanks
Got it (I think)! The problem has had to do with the way I was unpacking the data.
Reading the spec c a r e f u l l y is always a good idea :-D .
videohead{at_char_here}mail.com wrote:
%26gt; Got it (I think)! The problem has had to do with the way I was unpacking the data.
%26gt; 
%26gt; Reading the spec c a r e f u l l y is always a good idea :-D .
Then read it again :)
-X
Subscribe to:
Post Comments 
(Atom)
 
No comments:
Post a Comment