skip to Main Content

I’m currently parsing PSD files. I’m using imagick for the rasterized layers but I need to get the font data for the font layers since imagick can’t do this I need to do it myself. Right now I am able to grab the text, font family, font color but not the font size.

There are some “/FontSize xx.xxx” in the PSDs but usally non of these are right. (by “sometimes I mean different PSDs):

• Sometimes all font sizes grabbed from here are off by the same scaling factor.
• Sometimes different layers differs by the same scaling factor.
• Sometimes all of the sizes are correct.

Adobe provides specifications for the PSD file format, but these are outdated and incomplete, they do not even mention font size.

I have tried using a copy of the same file only changing the font size but to no avail.

Is there anyone who have already done this or any ideas pointing me in the right direction?

2

Answers


  1. Chosen as BEST ANSWER

    The answer can be found here (note that the code supplied has a small error.)

    The answer is that one should multiply the font size with the yy component of the transform.

    From what I have come to understand this is due to and old Photoshop bug.


  2. I used psd.rb ruby gem in similar case.

    layervault/psd.rb: Parse Photoshop files in Ruby with ease

    require 'psd'
    require 'json'
    
    psd = PSD.new("/path/to/psd.psd")
    psd.parse!
    
    puts JSON.pretty_generate psd.tree.to_hash
    # do something
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search