From 1c478c82986d8340814d5d17c4522704a489e529 Mon Sep 17 00:00:00 2001 From: cos Date: Sat, 10 Jan 2015 20:21:43 +0100 Subject: Add hackish support to print a logo on some labels. --- mat | 12 +++++++++++- sts | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mat b/mat index 48e7efd..45ce51d 100755 --- a/mat +++ b/mat @@ -280,6 +280,11 @@ sub print_label { my $idbarcode = GD::Barcode::QRcode->new(sprintf("%s%d", $Config{'label_id_prefix'}, $id), { Version=>3 }); my $idbarcode_image=$idbarcode->plot(); + my $logo; + if ($ENV{'PRINT_WITH_LOGO'}) { + $logo = GD::Image->newFromPng("layer1.png"); + } + my $idtext = new GD::Image(500, $fontsize * 2); my $white = $idtext->colorAllocate(255,255,255); my $black = $idtext->colorAllocate(0,0,0); @@ -333,10 +338,15 @@ sub print_label { $label->fill(0, 0, $white); $label->copyResized($idbarcode_image, $x_border, $y_border, 0, 0, $idbarcode_image->width() * 5, $idbarcode_image->height() * 5, $idbarcode_image->width(), $idbarcode_image->height()); - $label->copyResized($idtext, $x_border * 2, $y_border + $idbarcode_image->height() * 5, 0, 0, $idtext->width() * 2, $idtext->height() * 2, $idtext->width(), $idtext->height()); + $label->copyResized($idtext, $x_border * 3, $y_border + $idbarcode_image->height() * 5, 0, 0, $idtext->width() * 2, $idtext->height() * 2, $idtext->width(), $idtext->height()); $label->copyResized($text0_image, $label->width() - $x_border - 2 * $fontsize, $y_border, 0, 0, $bounds0[1] * 1, $bounds0[2], $bounds0[1], $bounds0[2]); $label->copyResized($text1_image, $label->width() - $x_border - 4 * $fontsize, $y_border, 0, 0, $bounds1[1] * 1, $bounds1[2], $bounds1[1], $bounds1[2]); $label->copyResized($text2_image, $label->width() - $x_border - 6 * $fontsize, $y_border, 0, 0, $bounds2[1] * 1, $bounds2[2], $bounds2[1], $bounds2[2]); + if ($ENV{'PRINT_WITH_LOGO'}) { + my ($logo_w, $logo_h ) = $logo->getBounds(); + my $vl = $logo->copyRotate90(); + $label->copy($vl, $x_border - 20, $label->height - $y_border + 20 - $logo_w, 0, 0, $logo_h, $logo_w); + } open(PNGFILE, ">label.png"); print PNGFILE $label->png; diff --git a/sts b/sts index 2f910f7..72771bd 100755 --- a/sts +++ b/sts @@ -2,5 +2,9 @@ # scale triggered store cd $HOME/mat/matplan/ -./mat storeportion `cat currently_cooking` "$1" hemfrys +if (grep -q v currently_cooking); then + PRINT_WITH_LOGO=y ./mat storeportion `cat currently_cooking|sed 's/v//'` "$1" hemfrys +else + ./mat storeportion `cat currently_cooking|sed 's/v//'` "$1" hemfrys +fi -- cgit v1.2.3