Lightest format for printing - image

I am printing an image (monochrome) from a portable thermal printer (model: Brother PJ-623) using Raspberry Pi. Image is stored in eps format.
Problem: It takes ~9-12 seconds before the printing is started. I think may be the issue is in format of the image. So is there any format which the printer can read faster than eps format?
Or any other solution if possible?
EDIT: I'm using gnuplot in Qt-creator to create the image file.
Any help would be highly appreciated.
Best regards,
Hammad Tariq

I tried other format like png and pdf using following command in GNUPLOT:
set term png size H,W
where H, W were resolution of the image generated.
But they were not helping in the start as the print contained distortions. It turned out the problem was with the dpi.
So after some research I found out following link:
GNUPLOT pdf terminal
I found the following commands using the above link:
set terminal postscript enhanced color
set output '| ps2pdf - plot.pdf'
It converts the ps file to pdf with the same result in pdf as was in the ps file.
And it was taking only 3seconds for the printer to read.
I hope it would help someone in future.
Regards,
Hammad

If your EPS if vector based you don't really have a choice in format. The only other option is a PDF, which is likely to be less efficient than an EPS. It's likely that the driver you're using is not very efficient at printing vector graphics. You can do a test by converting the image to a high resolution JPEG and seeing if there's a difference in print time.
However, if you're using the EPS format for raster images then you're better off using a high quality JPEG file anyways. EPS is inefficient for storing pixel information compared to TIFF and JPEG.
Of course I have to wonder what's so bad about a 10 second print time. Is it just a curiosity thing, or is it critical that these print super fast?

Related

Use gostscript 9.21 to convert text to outlines, and how to keep the resolution of the picture

I use gostscript to convert text to outlines with the following code :gswin32c.exe -sDEVICE=pdfwrite -sOutputFile=output.pdf -dQUIET -dNOPAUSE -dBATCH -dNoOutputFonts -f test_new.pdf,it works.But i got a very small output file from 2.5M to 70kb.Then i find the picture became blurred in pdf.
Add -dPDFSETTINGS=/default,This will have the same result.
I's better to use -dPDFSETTINGS=/printer or -dPDFSETTINGS=/prepress,but 300dpi is not enough for me(or for my boss).
Is there any way to keep the original resolution of the picture.
Or how to set a higher dpi for images in output pdf.
The test file is here.
Thanks in advance.
The answer to your question is 'yes' (but see later). Don't use PDFSETTINGS, that sets lots of things all in one go. If you want control then you need to specify each setting individually.
Rather than use this shotgun approach you need to read the documentation, decide which controls affect areas you want to change, and alter those controls only.
However, image downsampling is not your problem. If you don't use -dPDFSETTINGS then PDF file written by Ghostscript contains an image at exactly the same resolution as the image in the original file.
Your problem is that the image is being written with JPEG compression, and JPEG is a lossy compression, so you are losing fidelity. Note that in the original file the image is written uncompressed, which is why its so large.
It looks like the original image was a JPEG, and the free PDF editor you are using has realised that so it saved the image uncompressed (I may be giving it too much credit here, it may save all images uncompressed). Applying JPEG to an image which has already been quantised simply amplifies the artefacts.
Instead you need to specify that you want images compressed with Flate, which is a lossless compression. The documentation for the pdfwrite controls can be found here, you need to change AutoFilterColorImages and ColorImageFilter.
Note that by not applying JPEG quantisation (a second time) and DCT encoding, the compression is less than your first experience. For me the output file comes in at just over 600Kb (leaving the font in place, and the text as text, would be a couple of Kb smaller). However the image is identical, as expected.
Since you are clearly using Ghostscript in a commercial environment, can I just point you at the licence and ask you to check that your usage is compatible with the AGPL, bearing in mind that this covers software as a service usage as well.

Need to convert to a RAW file for a heightmap in Unity

I need to convert a grayscale heightmap I created into a RAW file to use in Unity. I have searched Google for a way to do this for a couple of hours, to no avail. Is there a way to do this without Photoshop? My file was saved as a JPG, but I could convert to a BMP if necessary.
Hi there are plenty of tools which work with the RAW format other than photoshop. Try using http://www.darktable.org/
Also for Unity it's just a matrix of 16 bit integers so fairly sure you could hack something up in octave or matlab pretty quickly to do the job.

Save uint16 tiff image as truecolor with Matlab

I am processing microscopy images (in Matlab) in the tiff format, normally uint8 or uint16. Basically I read them, put them in a cell array for processing and then export them in the tiff format either as an image sequence or a stack (using imwrite and either the 'overwrite' or 'append' writemode property of imwrite, respectively). Up to now everything works very well.
The problem I'm having is the following:
When I open the images with ImageJ, they are not in truecolor "RGB" color mode, but rather in composite mode. For example ImageJ reads the data as 8 bit, which it is, but does not open the image as a truecolor (Sorry for the bad choice of words I don't know the right terminology). Hence I have to manually combine the 3 channels together, which is bothersome for large datasets.
Here is a screen shot explaining. On the left is what I would like,i.e. what I obtain if I open the image directly with ImageJ, and on the right is what I currently have after saving images with Matlab and opening them with ImageJ, which I don't want.
The code I'm using to export the image sequence is the following. "FinalSequenceToExport" is the cell array containing the images.
for i = 1:SliceNumber
ExportedName = sprintf('%s%s%d.tiff',fileName,'Z',i);
imwrite(FinalSequenceToExport{i},ExportedName,'tif','WriteMode','overwrite','Compression','none');
end
If I ask Matlab the size of FinalSequenceToExport{1}, for instance, it gives 512 x 512 x 3.
If I open a given image in the command window and then save it with the same code as above, it does what I want and the resulting image opens as I want in ImageJ. Hence my guess would be that the problem arises from the use of the cell array but I don't understand how.
I hope I've been clear enough. If not please ask for more details.
Thanks for the help!
You need to specify the the 'ColorSpace'
Try this
imwrite(FinalSequenceToExport{i},ExportedName,...
'tif','WriteMode','overwrite','Compression','none', ...
'ColorSpace', 'rgb');
After revisiting this question I found the following to work, thanks to the hint from #Ashish:
imwrite(uint8(FinalSequenceToExport{i}/255),...);
I just needed to divide by 255 after converting to uint8.

Ghostscript Stamp Image on PDF

Is there any way to stamp or overlap a tiff image on a existing PDF file and output the result using Ghostscript?
I have two PDF which i want to merge in a result PDF with one over the other using ghostscript. I want to know if this can be done and how, or if it may work with one PDF as tiff image on top of the base PDF.
Can ghostscript make this stamp using layers in the PDF?
Thank you for your answers
The pdfwrite device in Ghostscript doesn't really support layers, so you can't use that. Also its unclear why you think layers would help.
TIFF isn't part of PostScript (or PDF), so you can't directly read a TIFF file into GS. I have elsewhere posted a PostScript program which reads TIFF files and renders them for output. You could use that to read a TIFF file.
However, you would have to mess about with either the PDF interpreter or a custom EndPage procedure in order to read and render the TIFF file. And unless you take specific kinds of action, it will be opaque, which may well not be what you want.
The Ghostscript PDF interpreter doesn't really lend itself to this kind of manipulation, have you considered using pdftk instead ?

PDF to TIFF free library in Windows?

i've got a hundred pages long high quality PDF (66MB) that needs to be converted to TIFF format (300 dpi, as high quality as possible :P).
I've tried Imagemagick/ghostscript, jpedal, Poppler, XPDF but they all produce different results due to the strange gradient of the PDF itself (blame the designers) and some actually take forever....
Does any one know any alternatives that i can try?
Thanks in advance,
M.
The GIMP does a pretty good job reading PDF files. Here's a Windows installer.
The GIMP will load each page of the PDF into its own layer, so you'll have to export each one as a TIFF. Luckily, this can be automated. I have no experience with the linked script, but if it doesn't suit your needs then it shouldn't be hard to modify it or write a quick script of your own to export each layer as a TIFF image.
Try using the Adobe Reader to flatten your PDF to PostScript (newer versions do that from the command line, but since it's just one file, you can print to a PS file) before going through Ghostscript. That might remove some weird PDF issues.

Resources