benoitguigal / python-epson-printer

A python library for Epson thermal printers based on ESC/POS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Max Theoretical Image Size

andystevensname opened this issue · comments

I went for the gusto and tried printing an image sized 512x4483, weighing in at 344kb. After a short wait watching the terminal window, I was returned to the prompt and nothing happened. I'm assuming I maxed something out. So, what is the theoretical max on printed image size? Is it based on image file-size or image width and height? I'm using a TM-T88V if that helps. Thanks again for your patience.

Taylor

I've done so preliminary tests. Here's what I found.

After printing an image that was too long for the printer, I printed an image that was much shorter. Instead or receiving the image that was much shorter, I instead received part of the image that was too long for the printer, cropped to a certain size. This was repeatable, so I assumed the failure left this image in the printer's memory.

I printed an image that contained lines spaced 20px apart in lengths of 1000, 1500 and 2000px. The 2000px image printed, but was again cropped to a certain size. I kept shortening the length of the 2000px image until I came to the conclusion that the max image length is ~1654px. I'm not sure if this is the maximum length for any Epson printer or just mine.

So I decided to try splitting the too-long image and stitching the peices back together when printing. However, there's spacing between images when printing, about the size of one line feed. So my new question is, can two images be printed seamlessly together, without this line feed?

I'm sorry to keep bumping my own thread, but in looking at the source code I found the print_images(self, *printable_images) function. Can you provide an example of what type of data *printable_images might be? I've tried passing an array, a tuple and a string and I can't seem to get this function working. I'm hoping it does what I think it does, printing without stopping to make a space between images. Even if it doesn't, I'm still curious about this function.

Many thanks again.

There is indeed a max height to the image that can be printed with this lib. I have also encountered this problem but never found the theoretical value from the Epson documentation. I am glad you provide an experimental number.
This is related to the fact that images are printed in "page mode" for a better result. In "page mode", the printer buffers the drawing commands in memory before dumping the buffer to the paper in one shot. The limit we encounter correspond the limit of the buffer I guess.
print_images won't help, it is just a utility function to combine data from different images before sending it to the printer. We would hit the same limit.
You might consider giving a try to the library https://github.com/benoitguigal/png2pos. I think @petrkutalek is taking a different approach that does not rely on page mode.

Hi guys, you probably should check pages 158 -- 162 in Epson Documentation on maximum printable area size (height incl.) in page mode.

@benoitguigal Thank you for your response, and @petrkutalek thank you for the Epson Documentation link. Unfortunately it doesn't cover my printer, the TM-T88V, but the specs on the TM-T88IV seem to be fairly close to my own observations so I don't see a problem with using that as a guideline.

In the meantime I wrote a script with PIL that crops the image into n 1600px length chunks and then prints them out in series, where n is the math.ceil(height/1600). There is a slight break between the images, which I'm looking to fix, but it will do for now.

I'm very interested in png2pos, as I could just include that in my .py script with a subprocess. A few observations (and I wish I could pull an issue ticket on that repository): I could only install with sudo make install and not sudo make install-strip or sudo make install-rpi.

Also, as I'm connected to my printer straight through usb I don't think I have anything at /dev/usb/lp0, at least ls /dev/usb doesn't show any lp. Is there another method to send to a usb printer, or to find my printer's address? Sorry for such a newb question.

Thank you again.

  • Taylor

UPDATE: I unplugged my usb printer and plugged it back in. lp0 now exists, but I still don't have permissions to use it. My user is in the lp/lpadmin group.

UPDATE2: I changed permissions and got it working. Unfortunately the print quality does not match that of the python-epson-printer running at printer speed 1. I will mess with the options to see if I can print out better quality text. Boy does it print fast!

@taylorstevens, png2pos is a utility to print PNG images pixel-to-pixel. That's all, it is not a @benoitguigal's python-epson-printer's competitor. It is fast, because it is a specialised tool, png2pos utilises GS 8 L ESC/POS command.

For best results you have to prepare B/W image you want to print and png2pos will do it for you best way you can imagine. :-) Nevertheless, it has also extended capabilities of image printing with preprocessing and dithering (-p option).

As far as I know, current version of png2pos does not have a install-strip… target in Makefile. sudo make install automatically strips binary before copying.

install : strip man
    mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/share/man/man1
    install -m755 $(EXEC) $(DESTDIR)$(PREFIX)/bin
    install -m644 $(EXEC).1.gz $(DESTDIR)$(PREFIX)/share/man/man1

Thank you, @petrkutalek, for your hard work and your explanation. I had seen those make options on @benoitguigal's repository. I agree with you, I see png2pos's application. And the reason I think png2pos might not be the best application for me is that my images are text. You see, I'm building a machine that prints poems on demand from phantomjs screen shots, which are antialiased in nature. So while the speed of png2pos is absolutely a thing I'm looking for, I can't find a threshold that maintains the crisp nature of python-epson-printer's PIL images (converted to mode 1). However, I'll be looking forward to using this via python subprocess to print author photos 👍 . So again, thank you for your hard work.

And @benoitguigal, FYI, I looked closer at the code and found that if I stitch together images sized 1608px's long, no additional white space is added between them because 1608 is divisible by 24. The transition between images is that of a slightly faded line, but completely readable. There's a small delay when the image is transferred/loaded by the printer, but not bad at all.