2018-09-09

Printing, and microscopes!

I got a small £15 USB microscope off Amazon, as you do. Great fun, but there was a practical reason.

I have been trying to work out the logic of the printing from my Mac to a Brother QL-700 printer. I have this sussed when it comes to using linux (finally) with a lot of careful arguments to ghostscript and inkscape to take my initial SVGs and print them with no dithering. That is working well. But I am trying to work out how to print from a Mac when printing something that is fussy, like a bar code.

Printing PDFs

The most obvious choice was to make a PDF. I had carefully made the barcodes in the PDF to the exact print resolution of 300 dpi. Everything was vector based. On screen it is perfectly crisp and clear.

However, the printing from the Mac constantly insisted on scaling to fit page. Even when I put 100% scale the printing was not spot on, and did not read very well, if at all. In fact it was slightly better printed at 101%. This is silly.

Printing PNGs

So I tried PNGs. The good news is that by default, where the PNG has a resolution set, it defaults to print at 100% and seems to have the sense to align pixels well. I thought my problems were solved, and to the naked eye, the QR codes looked fine.

But I decided to check, which is where the microscope comes in!

I generated a PNG with a QR code at 100dpi with one PNG pixel per QR code unit/pixel.

This was the result!


As you can see, there are bits sticking out all over the place. It took me a while to work out what was happening! Basically, something in the process has decided to soften the edges of the pixels, and then something has decided to dither the greys that are then produced. Even tinkering with the dither settings I could not make it stop doing this. Surprisingly it does read, usually. (Yes, I also bought a 2D barcode reader from Amazon).

However, one small change makes it massively better. By making a PNG at 300dpi, and using 3x3 PNG pixels per QR unit/pixel I get this!


No bits sticking out. It is not quite perfect, but that may be the printer - it seems to bleed on the trailing edge of printing making all black slightly wider. I may be able to do something to compensate for that. This reads much more reliably than the previous one.

However, making a 600dpi image and 6x6 pixels did not help - it created anti-aliasing greys which dithered, though not as bad... If I was able to align this properly it would probably work as well.


So, the moral of the story is to make PNGs that match exactly the printer resolution, and ensure you have way more than 1x1 pixels for the bar code units. For this printer I would say at least 3 print pixels per unit.

P.S. linux pdfinfo command shows resolution in DPI and then has "(pixels per meter)" which is very confusing.

1 comment:

  1. Could the issue be with the printer driver doing some sort of image 'enhancement'? Does it come out better if you turn off all the fancy features on the printer and maybe use a postscript driver?

    ReplyDelete

Comments are moderated purely to filter out obvious spam, but it means they may not show immediately.