eymlo / python-escpos

Automatically exported from code.google.com/p/python-escpos
GNU General Public License v3.0
1 stars 0 forks source link

Print image limited to 255px height #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello there,

I am trying to print images that are bigger than 255px in height but it throws 
ImageSizeError(). Is there any reason to limit the image size in hieght ? 

Thanks

Original issue reported on code.google.com by benoit.g...@gmail.com on 23 May 2014 at 6:06

GoogleCodeExporter commented 9 years ago
Hi benoit.guigal,

Thank you for your interest in the project.

Think the limitation is due the size of the buffer,
but I can remember clear :(

Maybe, you can try to change and report back the results?

Any feedback will be much appreciated.

Thank you!

Original comment by manpaz on 4 Jun 2014 at 7:22

GoogleCodeExporter commented 9 years ago
Hi,

Thank you for your answer. 
According to the EPSON documentation, the command you use is "Print Raster 
Image"
GS V 0 m xl xh yl yh d1...dk 
where width = xl + xh * 256 and height = yl + yh * 256 
Nevertheless in the code 
buffer = "%02X%02X%02X%02X" % (((size[0]/size[1])/8), 0, size[1], 0) 
So you always set the higher byte to 0, which means we can't print anything 
bigger than 255. 

I ended up not using the command GS V 0 (which seem obsolete as per EPSON 
documentation) but rather ESC * and it seems to work. 

Original comment by benoit.g...@gmail.com on 5 Jun 2014 at 7:53

GoogleCodeExporter commented 9 years ago
Thank you for your time invested in the documentation,
seems like definitively, I might need to make some changes,
to the code.

Once again, thank you for your interest in the project.

Original comment by manpaz on 5 Jun 2014 at 4:31

GoogleCodeExporter commented 9 years ago
Yes, the 255 px limit is slightly annoying, but if it's all the author needs, 
I'm fine with that. The GS v 0 command should be able to print up to 4095 px 
long, and I've successfully printed 450 mm images with my own crude code.

It took me a while to work out the headers, but here's some simple code that 
prints almost any image file. It's probably best to do your own dithering 
first, as PIL's routines aren't ideal: 
https://gist.github.com/scruss/36c31a9b653779b2b7d1

Original comment by scr...@gmail.com on 27 Jul 2014 at 1:04