I have a Zebra Gk420t printer that allows me to make stickers and I need to print an image on them. I read that the images must be in GRF format (pure hex).
Someone knows how can I convert the images to GRF format in Linux? I read about Ztools software on Windows, but nothing interesting on Linux...
Zebra provides a Java API that can convert graphics to GRF. You can use the command line interface to convert images to GRF like so :
java -jar ZSDK_API.jar graphic myImage.jpeg -s myConvertedImage.GRF
Someone knows how can I convert the images to GRP format in Linux?
You're over-thinking this.
Modern versions of CUPS ship with Zebra printer drivers. CUPS is the printing system used by most modern *nixes, including most Linux distributions.
Setting up the printer via CUPS will allow you to print any supported content to it, including PDFs, JPEGs, GIFs and PNGs. Just invoke /usr/bin/lp
or /usr/bin/lpr
with the printer name and file name. See their manual pages for the exact syntax required. For example,
/usr/bin/lp -d Zebra_GK420t ./foo.png
Note that you may need to set some command line options, including ppi=203
or fiddle with landscape/portrait modes. You will also either need to specify the media type (label size) or have the printer configured with the default media type.
For Ubuntu Linux, I came up with this process.
Obtain the source image preferably as an uncompressed format. Examples include *.bmp, *.png, etc.
Install ImageMagick on Ubuntu OS. Usually it is installed by default on the newer versions of Ubuntu.
Use GIMP to scale the images as required DPI. Prefer cubic, bi-cubic or better scaling algorithms to minimize loss of data during the scaling.
Now execute these statements.
Install OpenCV, Dosbox and Wine using
sudo apt-get install libopencv-* dosbox wine
and save the following program as rgb2gray.cc
//#include <cv.h>
//#include <highgui.h>
#include <opencv2/opencv.hpp>
#include <cstdio>
#include <cstdlib>
using namespace cv;
int main( int argc, char** argv )
{
if( argc != 3 )
{
printf( " No image data \n " );
printf( "Usage: ./rgb2gray <colorimage>.<ext> <grayimage>.<ext> \n" );
printf( "Usage: ./rgb2gray colorimage.png grayimage.png \n" );
exit(0);
}
char* imageName = argv[1];
Mat image;
image = imread( imageName, 1 );
Mat gray_image;
cvtColor( image, gray_image, CV_BGR2GRAY );
imwrite( argv[2], gray_image );
namedWindow( imageName, CV_WINDOW_AUTOSIZE );
namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );
imshow( imageName, image );
imshow( "Gray image", gray_image );
waitKey(0);
return 0;
}
Type the following on terminal to compile the code:
g++ -g rgb2gray.cc -o rgb2gray `pkg-config opencv --libs --cflags`
Now, execute the following commands.
./rgb2gray colorimage.png grayimage.png
convert -compress none grayimage.png logo.tif
Note: Make sure the tif image name is not longer than 8 characters, otherwise you may face problems in further steps
Google internet to find ztoolssetup107.exe. I found one here http://www.hjollum.com/jari/zzbug/ztools/download.php
Install Ztools using wine by right clicking on exe file and selecting open with wine.
Navigate to the following path where Ztools are installed
cd ~/.wine/drive_c/ztools
and copy the logo.tif you created previously there cp <path to tif image>/logo.tif .
Now for the final steps
Open Dosbox by executing dosbox .
and inside the Dosbox terminal type ZIMAGLIT.EXE logo.tif logo.grf
and thats it!!!
Note: If you do not see ZIMAGLIT.EXE you may have to obtain it via Google. I am hoping the ZImage link above contains the same.
Troubleshooting:
Q. Why is my GRF completely all 0s?
A. Because the source monochrome images should be binary (after rgb2gray conversion). i.e. every pixel on the image should be either black or while. Avoid shades of Gray or convert Gray areas in the image to jet black (pixel values = 255). Then retry the process.
Q. ZIMAGLIT.EXE is unable to convert my TIF image to GRF?
A. Because the tif image name (not including tif extension) should be less than or equal to 8 characters preferably all alphabets. Rename the same if it does not match this condition. Then retry the process.
Try this one ...
https://mega.co.nz/#!DJBgwYzD!09rTYzwi_2OfEVKN20osMlMdLClv2qyDXUbFYra82ks
It is for Windows and require comdlg32
I was facing tons of issues back in 2005 when was coding some libraries in C++ for those printers and found a lot of info on ZPL guide.
For GRF files I created this app to help me on daily basis image conversion.
Didn't touched this code anymore since then .. so probably has some room to improvement .. but a quick test and look like working fine (except the image size max to 600x600 .. something related to old systems 9 years ago .. maybe memory .. maybe screen resolution .. can't remember)