ZPL guide 8 of 9

Printing images and logos

Three ways to get a bitmap onto a ZPL label: inline with ^GF, stored with ~DG and recalled with ^XG, or downloaded as PNG with ~DY. Includes the byte arithmetic and the guide's own contradictions.

Three ways to print an image

Question How does ZPL print an image, and how do I print a logo once?

ZPL has three documented routes by which an image reaches the printer as dots: inline in the label with ^GF, stored with ~DG and recalled with ^XG, or downloaded as a file with ~DY and recalled with ^IM or ^IL.pp. 175, 181, 215, 247, 248, 373

TipFor a logo that appears once, put the data straight in the label with ^GF. For a logo that appears on every label, store it once so you do not resend it.p. 215

Inline with ^GF, and the byte arithmetic

Question How do I calculate the byte counts?

^GF puts graphic data into the printer's bitmap at the field's position, following the same conventions as other fields. Its values are the compression type (A for ASCII hexadecimal, the default; B for binary; C for compressed binary), a byte count, a graphic field count and the bytes per row, then the data.p. 215

In ASCII form each image byte is two hexadecimal digits, and the number of pairs must match the field count. The byte count should equal the field count for ASCII data. A comma in the data fills the rest of the current row with 00, which saves space.p. 215

Work the numbers in dots. Bytes per row is the image width in dots divided by 8, rounded up to a whole byte. The total is bytes per row times rows. A 24 mm by 10 mm image on an 8 dots per millimeter printer is 192 by 80 dots, so 24 bytes per row and 1920 bytes in all.pp. 175, 176

The guide's formulas use your printer's dots per millimeter. The same bitmap therefore prints at a different physical size on a different density; scale the image on your side before you encode it.p. 175

A one in the data is a black dot, and the leftmost dot of a byte is its highest bit: the guide's own illustration encodes four white dots followed by four black ones as 00001111, which is 0F.p. 176

WarningWith ASCII hexadecimal data, a caret or tilde in the data prematurely aborts the download. Binary data is the exception: control prefixes are ignored until the stated number of bytes has arrived.p. 215

example.zplZPL
^XA
^FO40,40^GFA,8,8,1,FF818181818181FF^FS
^XZ

An 8 by 8 dot bitmap, one byte per row and eight rows. The first and last rows are all ones; the six between have only the end dots set, which draws a hollow square.

Store once, recall many times

Question How do I send an image once and print it on many labels?

~DG downloads a graphic into printer memory. Its values are a device (R:, E:, B: or A:, default R:), a name of 1 to 8 alphanumeric characters, the .GRF extension, the total bytes, the bytes per row and the ASCII hexadecimal data.p. 175

WarningDo not put spaces or periods in a graphic's name. Sending a second graphic with the same name erases and replaces the first.p. 176

^XG recalls a stored graphic and can enlarge it from 1 to 10 times on each axis, default 1, as many times as you like in one format. ^IM moves the same image without sizing, and the guide says it may need less formatting time if the image sits on an 8-, 16- or 32-bit boundary.pp. 248, 373

example.zplZPL
~DGR:SQUARE.GRF,8,1,FF818181818181FF
^XA
^FO40,40^XGR:SQUARE.GRF,4,4^FS
^FO200,40^XGR:SQUARE.GRF,2,2^FS
^XZ

The first line stores the 8 by 8 bitmap in DRAM as SQUARE.GRF. The label then recalls it twice at different magnifications.

PNG files with ~DY

Question Which image types does ~DY accept, and what must the image look like?

~DY downloads graphics or fonts in any supported format and can be used in place of ~DG. It accepts PNG: choose the P data format, ZB64 encoded, and store the file as .PNG. Recall it with ^IM or, at the start of a format, ^IL.pp. 181 to 183

For a PNG, ~DY takes a device, a file name of 1 to 8 alphanumeric characters, the data format (P), the stored extension (P), the size in bytes of the file itself, a bytes-per-row value that the printer ignores for PNG, and then the data.pp. 181 to 183

The guide says graphic files should be monochrome (black and white) or dithered for good results. Make that conversion before you send the file, and do not assume the printer handles color or gray levels.p. 183

ZB64 is Base64, optionally compressed first, with an identifying header and a trailing check value. It uses only printable characters, so it avoids the caret and tilde, and adds 33 percent to the data compared with 100 percent for hexadecimal.pp. 1602 to 1604

The guide disagrees with itself in two places. The ~DY entry prints ~DV in its Format line, although its heading and the contents say ~DY. And ~DG is described as taking ASCII hexadecimal only, yet the ZB64 section lists ~DG among the commands that accept the new encodings.pp. 175, 181, 1604

Templates and storage

Question How do I speed up repeated labels, and where do stored images live?

^IS saves the format built so far as an image rather than as ZPL. Later, ^IL loads it at the top of a format at position 0,0 and you overlay variable data. The guide says this greatly increases throughput. The ^IS option to print after storing defaults to yes.pp. 247, 249

The alternative, ^DF with ^XF and numbered fields (^FN), stores the format as text. It cuts transmission time but saves no formatting time, and the guide says ^IS and ^IL are processed faster.pp. 57, 174, 200, 372

Stored objects live on a device letter: R:, E:, B: or A:. R: is DRAM and volatile, so its stored formats are lost when power goes off. Which of the others exist depends on the printer.pp. 56, 1753, 1764

^ID deletes stored objects, with * as a wildcard in the name and extension. Stored file names accept only certain characters, and ^ and ~ are not allowed in them unless the command prefixes have been changed.pp. 58, 245

example.zplZPL
^XA
^FO30,30^GB300,100,3^FS
^FO45,50^A0N,30,30^FDShip to^FS
^ISR:PANEL.GRF,N^FS
^XZ
^XA
^ILR:PANEL.GRF
^FO45,90^A0N,30,30^FDHarbor Foods^FS
^XZ

The first format draws the constant panel and saves it as PANEL.GRF without printing. The second loads it and adds the variable line.

The same label with BarcoderX

Question How does BarcoderX handle images?

BarcoderX is pre-launch and its API is not final. It is designed to let you describe the label once in .NET and emit ZPL or EPL. The published samples on the Developers page do not show image calls yet, so there is no code here.

Questions

Can ZPL print a PNG?

Yes, through ~DY with the PNG data format, then ^IM or ^IL. The guide advises monochrome or dithered images.pp. 181 to 183

Where are stored images kept, and do they survive a power cycle?

On R:, E:, B: or A:. R: is DRAM and is lost when power is turned off; the others depend on the printer.pp. 56, 1764

How do I delete a stored image?

Use ^ID with the device and name, for example a wildcard to delete every graphic of one extension.p. 245

Commands in this guide

BarcoderX is a .NET SDK for thermal labels and barcodes. See how it prints and exports labels.

Source Zebra, ZPL II, ZBI 2, Set-Get-Do, Mirror, WML Programming Guide, P1134473-11EN Rev A, 2026/07/05, pages 56 to 58, 60, 174 to 176, 181 to 183, 200, 201, 204, 210, 215, 216, 245, 247 to 249, 372, 373, 1602 to 1604, 1753, 1754, 1764.

Written by BarcoderX in its own words. Checked against the guide on 2026-11-14.

ZPL and ZPL II are trademarks of Zebra Technologies Corporation. This reference is written by BarcoderX in its own words from Zebra's published programming guide. BarcoderX is an independent product and is not affiliated with, endorsed by or sponsored by Zebra Technologies.