diff options
author | cos <cos> | 2015-01-10 20:21:43 +0100 |
---|---|---|
committer | cos <cos> | 2015-01-10 20:21:43 +0100 |
commit | 1c478c82986d8340814d5d17c4522704a489e529 (patch) | |
tree | 9036489332ed0311d272922a98eb011679d13846 | |
parent | 135d8c9ef7fe197b0547629e38f9cc73de5dbc98 (diff) | |
download | mat-1c478c82986d8340814d5d17c4522704a489e529.zip |
Add hackish support to print a logo on some labels.
-rwxr-xr-x | mat | 12 | ||||
-rwxr-xr-x | sts | 6 |
2 files changed, 16 insertions, 2 deletions
@@ -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; @@ -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 |