#!/usr/bin/env perl
use strict;
use warnings;
use GD;
use Data::Dumper;
my $xoffs = 20;
my $yoffs = 20;
my $minwhite = 200;
my $verbose = 0;
my $image = GD::Image->new('examplelogo.png');
my $w = $image->width();
my $h = $image->height();
print "Image size: $w x $h\n";
open(my $ofh, '>', 'savelogo.zpl') or die($!);
# Start of form;
print $ofh "^XA\n";
for(my $x = 0; $x < $w; $x++) {
for(my $y = 0; $y < $h; $y++) {
my $index = $image->getPixel($x,$y);
my ($r,$g,$b) = $image->rgb($index);
if($r < $minwhite) {
print "#" if $verbose;
print $ofh '^FO' , ($x*1) + $xoffs, ',' , ($y*1) + $yoffs, '^GB1,1,1,B,0^FS', "\n";
} else {
print " " if $verbose;
}
}
print "\n" if $verbose;
}
# Save graphic to flash mem
print $ofh "^ISR:LOGO.GRF,Y\n";
# End of form
print $ofh "^XZ\n";
close $ofh;
####
^XA
^FO55,74^GB1,1,1,B,0^FS
^FO55,75^GB1,1,1,B,0^FS
^FO55,76^GB1,1,1,B,0^FS
^FO55,77^GB1,1,1,B,0^FS
^FO55,78^GB1,1,1,B,0^FS
...
^FO561,126^GB1,1,1,B,0^FS
^FO561,127^GB1,1,1,B,0^FS
^FO561,128^GB1,1,1,B,0^FS
^ISR:LOGO.GRF,Y
^XZ
##
##
lpr -P yourprintername -o raw savelogo.zpl
##
##
^XA
^ILR:LOGO.GRF^FS
^FO110,140^FH\^A0N,50,50^FDXXCAPTIONXX^FS
^XZ
##
##
lpr -P yourprintername -o raw label.zpl
##
##
hg clone https://cavac.at/public/mercurial/zpl_storedlogo/