Converting ESC/P2 output for modern printing

Anything QL Software or Programming Related.
User avatar
XorA
Site Admin
Posts: 1359
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: Converting ESC/P2 output for modern printing

Post by XorA »

vanpeebles wrote:Will it have a small speaker, and make a grrrp grrp thump thump grrrp noise? :lol:
One free VP with every printout!


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Converting ESC/P2 output for modern printing

Post by RWAP »

It would also have to hang in the middle and jam the print head to the side chewing up the paper...


User avatar
Peter
QL Wafer Drive
Posts: 1953
Joined: Sat Jan 22, 2011 8:47 am

Re: Raspberry Pi - A commercial use?

Post by Peter »

RWAP wrote:The Rasberry Pi takes about 1 1/2 minutes to convert a page at the moment which seems slow when testing, but is faster than a dot matrix printer :)
That must be about 10x faster than a Q60... which again is about 10x faster than the likes of a SuperGoldCard... so we'd be in the range of several hours :(


User avatar
Dave
SandySuperQDave
Posts: 2765
Joined: Sat Jan 22, 2011 6:52 am
Location: Austin, TX
Contact:

Re: Converting ESC/P2 output for modern printing

Post by Dave »

If it is slow, it may be running as a single thread. Even then, if it is taking 90 seconds something is off.


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Converting ESC/P2 output for modern printing

Post by RWAP »

Dave wrote:If it is slow, it may be running as a single thread. Even then, if it is taking 90 seconds something is off.
As I say - I am open to suggestions. The main delay occurs around:

a) Writing the PNG image using libPNG
b) The ImageMagick routine to convert the PNG to PDF which is incredibly slow for some reason.

The other option would be to write the image data direct to a PDF if anyone knows how to do this.


User avatar
Peter
QL Wafer Drive
Posts: 1953
Joined: Sat Jan 22, 2011 8:47 am

Re: Converting ESC/P2 output for modern printing

Post by Peter »

How long does generating the uncompressed bitmap take, without PNG and PDF creation?
There should be a more direct way to get from uncompressed bitmap to PDF.


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Converting ESC/P2 output for modern printing

Post by RWAP »

Peter wrote:How long does generating the uncompressed bitmap take, without PNG and PDF creation?
There should be a more direct way to get from uncompressed bitmap to PDF.
Roughly 4 seconds to get so far as the write_png() function (so that is one page all converted).
The write_png() function then takes 23 seconds. We originally used an uncompressed bitmap in the file, but the filesize made the conversion even longer (without the bitmap creation being apparently much quicker).

ImageMagick is then taking roughly 26 seconds to convert the PNG to a PDF.

Altering the amount of PNG compression does not seem to make any real difference to these figures.


User avatar
Dave
SandySuperQDave
Posts: 2765
Joined: Sat Jan 22, 2011 6:52 am
Location: Austin, TX
Contact:

Re: Converting ESC/P2 output for modern printing

Post by Dave »

What are the sizes of the PNG and PDF being created? Are they being stored in RAM or written to a file on the SD card? If you're sending bytes to a file on an SD card, that can be very slow. When you copy a file, the size is known and the OS and SD card do a single write operation per block. If you write a stream of bytes, it can't strategize the write or do it efficiently.

Many SD cards also do not do wear leveling, so minimizing small writes really does help them last longer - especially in an appliance.

Just a side thought.


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Converting ESC/P2 output for modern printing

Post by RWAP »

Dave wrote:What are the sizes of the PNG and PDF being created? Are they being stored in RAM or written to a file on the SD card? If you're sending bytes to a file on an SD card, that can be very slow. When you copy a file, the size is known and the OS and SD card do a single write operation per block. If you write a stream of bytes, it can't strategize the write or do it efficiently.
The problem is the size of the image - A4 at 720dpi gives a pixel resolution of 5954 x 8417

As we build the image up in memory, we use a byte per pixel (because we have to support 6 colours in ESC/P2 + white).

I have however, now switched to use libharu as a different PDF library. This allows you to create a raw image in memory and write that direct to the PDF, which does save time (down to around 30 seconds in total per page), but means another 5954 x 8417 x 3 bytes to store 8 bit RGB for each pixel !

Ideally I would find a method to store the raw image using 1 byte per pixel (RRRGGGBB RGB format) which would reduce memory requirements. However, making an accurate method of merging the 6 colours (as would happen on an Epson printer) is proving problematic. Can anyone find a C program to convert CMYK to 1 byte RGB (or possibly re-write the cmyk_to_rgb() function in the PrinterConvert.c )?


User avatar
Dave
SandySuperQDave
Posts: 2765
Joined: Sat Jan 22, 2011 6:52 am
Location: Austin, TX
Contact:

Re: Converting ESC/P2 output for modern printing

Post by Dave »

(5945 * 8417 * 3) / 1024 = 146599K or 144MB. Hmmmm. Then that doesn't sound so bad then :)

Can you assemble multiple page PDFs in RAM? With 1GB RAM on Pi3, maybe 600MB usable, what is your PDF page limit? Or are you treating each page as a separate standalone print job?


Post Reply