0

I want to be able to find out what fonts a psd file has using Python. I was able to read a psd file as a binary file and convert the contents into hex.

>>> with open(test_file,'rb') as f:
...     content = f.read()
...     hex_content = binascii.hexlify(content)

Then I decoded the hex contents into a text file.

>>> with open('./decoded1.txt', 'w') as f:
...     f.write(hex_content.decode("hex"))

Near the bottom of the decoded file, I found some sort of header named /FontSet, which I think is what I am looking for.

/FontSet [
  <<
  /Name (þÿ A d o b e I n v i s F o n t)
  /Script 0
  /FontType 0
  /Synthetic 0
  >>
  <<
  /Name (þÿ M y r i a d P r o - R e g u l a r)
  /Script 0
  /FontType 0
  /Synthetic 0
  >>
  ]

Am I on the right track? I recognize MyriadPro-Regular as the font used in my test file. What is AdobeInvisFont? Is this the Adobe Blank font?

Christopher Spears
  • 1,105
  • 15
  • 32
  • 1
    There's actually [a spec]](http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_72092), although that seems incomplete at a glance. There are also some open source implementations you can look at. Judging from [this answer](http://stackoverflow.com/a/5355949/660921) PSD is not exactly an easy format to work with. There are also many different versions, and what works for one version may not work for the next. Doing a string-dump or writing a half-arsed ad-hoc parser doesn't strike me as a particularly great idea. I would suggest looking at existing tools (ImageMagick?) – Martin Tournoij Mar 09 '16 at 18:39
  • 1
    Does https://github.com/psd-tools/psd-tools not work for you? It even has links to *other* Python packages for PSD reading. – Mike 'Pomax' Kamermans Mar 09 '16 at 19:35

0 Answers0