Jump to content

PSD specifications help

- - - - -

  • Please log in to reply
3 replies to this topic

#1
brock123

brock123

    Newbie

  • Members
  • Pip
  • 3 posts
I'm writing a program (in Python for now) for reading PSD files. I'm using this specification: Adobe Photoshop: Summary from the Encyclopedia of Graphics File Formats Here it says

BYTE Name[]; /* Even-length Pascal-format string, 2 bytes or longer */

Um, 2 bytes or longer? How am I supposed to find out how ling it is? I don't know what "Pascal-format string" means either. Thanks in advance.

EDIT: Heres a direct link to the official PSD specification (pdf): http://forums.adobe....3C10A1EBF.node0 Look in page 9, under "Image Resource Blocks"

#2
brock123

brock123

    Newbie

  • Members
  • Pip
  • 3 posts
Of course reading one byte at a time and checking if it's an ASCII character won't work.

python code

# Name: Pascal string, padded to make the size even (a null name consists of two bytes of 0)

name = []

while True:

	char = file.read(1)

	try:

		char.decode('ascii')

		name.append(char)

	except UnicodeDecodeError:

		break

		

print 'name:', str(name)
Please help. Im out of ideas.

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
From Essential Pascal on marcocantu.com

"In Borland's Turbo Pascal and in 16-bit Delphi, the typical string type is a sequence of characters with a length byte at the beginning, indicating the current size of the string. "
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
brock123

brock123

    Newbie

  • Members
  • Pip
  • 3 posts
Thank you :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users