Convert image to GRF format

19,575

Solution 1

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

Solution 2

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.

Solution 3

For Ubuntu Linux, I came up with this process.

  1. Obtain the source image preferably as an uncompressed format. Examples include *.bmp, *.png, etc.

  2. Install ImageMagick on Ubuntu OS. Usually it is installed by default on the newer versions of Ubuntu.

  3. 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.

  4. 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;
}
  1. Type the following on terminal to compile the code:

    g++ -g rgb2gray.cc -o rgb2gray `pkg-config opencv --libs --cflags`

  2. 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

  1. Google internet to find ztoolssetup107.exe. I found one here http://www.hjollum.com/jari/zzbug/ztools/download.php

  2. Install Ztools using wine by right clicking on exe file and selecting open with wine.

  3. 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 .

  4. 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.

Share:
19,575
Angel
Author by

Angel

Updated on June 15, 2022

Comments

  • Angel
    Angel almost 2 years

    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...