png output failure

85 views
Skip to first unread message

JMcCleery

unread,
Feb 1, 2012, 4:20:07 PM2/1/12
to Barby
Every time I try to generate a png using barby (on ruby 1.9.2, winXP),
the file comes up as an invalid image. I get no errors while
generating it. Is there something I need to change in my setup?

JMcCleery

unread,
Feb 2, 2012, 1:40:55 PM2/2/12
to Barby
I found that adding the "b" option to the file mode fixed the problem
in windows:
File.open('code128b.png', 'wb')
instead of:
File.open('code128b.png', 'w')

This forces binary mode, and suppresses the conversion to CRLF in
windows.

David Moghadasi

unread,
Aug 31, 2015, 10:51:05 AM8/31/15
to Barby
Hi,

I get same problem when I try to generate a png. The png-file has a size of 1 kb and I get an error message when I try to open the file. This is the code I use.

barcode = Barby::EAN13.new('732351090062')
File.open('barcode.png', 'wb'){|f| f.write barcode }

Br
David
Reply all
Reply to author
Forward
0 new messages