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

IOError: closed stream when saving to PNG #16

Closed
bfoz opened this issue Aug 1, 2013 · 1 comment
Closed

IOError: closed stream when saving to PNG #16

bfoz opened this issue Aug 1, 2013 · 1 comment

Comments

@bfoz
Copy link
Contributor

bfoz commented Aug 1, 2013

Saving example.psd to a PNG throws an error, however the image appears to be generated correctly despite the error. Error output is below.

Here's my ruby version:
09:32 bfoz@nancy-dt:test$ ruby --version
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]

Here's the error:

09:10 bfoz@nancy-dt:test$ irb

require 'psd'
true
psd = PSD.new 'example.psd'

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

psd.image.save_as_png 'example.png'
IOError: closed stream
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:191:in directory?' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:191:inawesome_file'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:26:in format' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:137:inunnested'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:104:in awesome' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/awesome_print-1.1.0/lib/awesome_print/core_ext/kernel.rb:10:inai'
from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/awesome_print-1.1.0/lib/awesome_print/core_ext/kernel.rb:15:in ap' from /Users/bfoz/.rvm/gems/ruby-1.9.3-p448/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:31:inoutput_value'
from /Users/bfoz/.rvm/rubies/ruby-1.9.3-p448/bin/irb:16:in `

'

@meltingice
Copy link
Member

The reason it's still outputting an image is because it's an issue with the awesome_print gem, not PSD.rb. It looks like awesome_print is integrated into IRB such that it replaces the default printer. It's attempting to read the PNG file contents, but the file has been closed by ChunkyPNG, thus causing an error.

If you want to avoid the error in the console, you can do something like:

psd.image.save_as_png('example.png') and false

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

2 participants