Jump to content

Labels

From base48
Revision as of 10:03, 20 March 2026 by Klubko (talk | contribs) (Created page with "== QR codes == Thebys' Brother printer can print monochrome PNG files of height 128px. === Creating the PNG files === One way to do it is with this simple Perl script: use GD::Barcode::QRcode; use GD; use strict; use warnings; my $large = '/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf'; my $narrow = '/usr/share/fonts/truetype/liberation/LiberationSansNarrow-Regular.ttf'; my ($img, $w, $h); sub text { my $font = shift; if ($img) {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

QR codes

Thebys' Brother printer can print monochrome PNG files of height 128px.

Creating the PNG files

One way to do it is with this simple Perl script:

use GD::Barcode::QRcode;
use GD;

use strict;
use warnings;

my $large = '/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf';
my $narrow = '/usr/share/fonts/truetype/liberation/LiberationSansNarrow-Regular.ttf';

my ($img, $w, $h);

sub text
{
	my $font = shift;
	if ($img) {
		$img->stringFT(-1,$font,@_) or die "$font: $@: $!";
	} else {
		my @bounds = GD::Image->stringFT(-1,$font,@_) or die "$font: $@: $!";
		my $nw = $bounds[2] + 16;
		$w = $nw if $nw > $w;
	}
}

sub render
{
	my $title = shift;
	my $url = shift;

	$img = undef;
	$h = 128;
	$w = $h;

	# Sizing first
	text($large,48,0,$h,0, $title);
	text($narrow,24,0,$h,0, $url);

	# Actual rendering
	$img = GD::Image->new($w,$h);
	my $qr = GD::Barcode::QRcode->new($url)->plot(Height => $h);
	$img->copyResized($qr, 0, 0, 0, 0, $img->height, $img->height, $qr->width, $qr->height);
	text($large,48,0,$img->height, 64, $title);
	text($narrow,24,0,$img->height, $img->height-16, $url);

	return $img;
}

sub do_one
{
	my $title = shift;
	my $str = shift // $title;
	my $url = "https://wiki.base48.cz/wiki/$str";

	open my $file, ">$str.png" or die "$str.png: $!";
	print $file render ($title, $url)->png;
}

do_one('Electro Lab', 'Electro_lab');
do_one('RGB LED Panel', 'Buse_RGB_LED_Panel');
do_one('3D Printers', '3D_printing_lab');
do_one('C64', 'C64');
do_one('Color Jet Printer', 'Color_Jet_Printer');
do_one('CNC', 'CNC');
do_one('Metal Workshop', 'Metal_workshop');
do_one('Woodworking', 'Woodworking');
do_one('Turtle Drawing Plotter', 'PlotBot');
do_one('Bike Repair Corner', 'Bike_corner');
do_one('Library', 'Library');
do_one('Output Buffer', 'OutputBuffer');

Printing them out:

Use this tool: https://git.familie-radermacher.ch/linux/ptouch-print.git

# perl makeqr.pl
# ./ptouch-print --image=Library.png

Minimaze waste by chaining multiple labels:

# ./ptouch-print --image=Library.png --precut --chain
# ./ptouch-print --image=OutputBuffer.png --precut