Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing a particular PSD fails #11

Closed
bfoz opened this issue Jul 31, 2013 · 5 comments
Closed

Parsing a particular PSD fails #11

bfoz opened this issue Jul 31, 2013 · 5 comments

Comments

@bfoz
Copy link
Contributor

bfoz commented Jul 31, 2013

I have a PSD file that's a mock for an iOS app that I'm working on. When I try parsing it, I get the errors listed below. I'd be happy to provide the errant file, but it's too large to attach to this issue. If there's some other way I can send it to you, please let me know.

psd = PSD.new '1-Splash.psd'

<PSD:0x007fd86bc15ac0 @file=#PSD::File:1-Splash.psd, @opts={:parse_image=>false, :parse_layer_images=>false}, @Header=nil, @resources=nil, @layer_mask=nil, @parsed=false>

psd.parse!
Errno::EINVAL: Invalid argument - 1-Splash.psd
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/file.rb:80:in read' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/file.rb:80:inread_unicode_string'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:31:in parse_class' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:119:inparse_object_array'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:126:in block (2 levels) in parse_object_array' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:125:intimes'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:125:in block in parse_object_array' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:123:intimes'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:123:in parse_object_array' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:62:inparse_item'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:43:in parse_key_item' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:20:inblock in parse'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:19:in times' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:19:inparse'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:54:in parse_item' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:43:inparse_key_item'
... 4 levels...
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:43:in parse_key_item' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:20:inblock in parse'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:19:in times' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/descriptor.rb:19:inparse'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/layer_info/placed_layer.rb:11:in parse' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/layer.rb:314:inblock in parse_extra_data'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/layer.rb:310:in each' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/layer.rb:310:inparse_extra_data'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/layer.rb:69:in parse' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/layer_mask.rb:53:inblock in parse'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/layer_mask.rb:52:in times' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd/layer_mask.rb:52:inparse'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd.rb:90:in layer_mask' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/psd-0.3.3/lib/psd.rb:54:inparse!'
from (irb):20
from /Users/bfoz/.rvm/rubies/ruby-1.9.3-p448/bin/irb:16:in `

'>>
?> pp psd.tree.to_hash
{:children=>[], :document=>{:width=>640, :height=>960}}
{
:children => [],
:document => {
:width => 640,
:height => 960
}
}

@HBehrens
Copy link

I get a similar error when parsing a PSD with a smart object. Please find the sample file at http://cl.ly/2I1K3l0p1y1Z

@meltingice
Copy link
Member

@HBehrens thanks for the sample file, I'll check it out.

@meltingice
Copy link
Member

So the problem lies within a Descriptor, which represents a complex data structure of some kind, inside a PlacedLayer data block. It looks like the implementation for the object array (denoted with the ObAr) key is wrong. It also looks like there is a value with the key UnFl, which I believe to be a "unit float" (as opposed to the unit double).

The bytes in question are:

screen shot 2013-07-31 at 11 05 54 am

I'll keep working at it until I figure out the data structure. For now, I've pushed out a new version that catches parsing exceptions for these layer info blocks and continues to the next one so that parsing the PSD doesn't fail altogether.

@meltingice
Copy link
Member

Going to close this since parsing is fixed now, and open a separate issue for the Descriptor bug.

@bfoz
Copy link
Contributor Author

bfoz commented Aug 1, 2013

Thanks for looking into this. Version 0.3.4 seems to fix the crash for me (both on my file and the one provided by @HBehrens). I'll talk to our designer to see if there's anything special in our files that might be causing problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants