Skip to content

Commit

Permalink
Make QR Code optional on print
Browse files Browse the repository at this point in the history
  • Loading branch information
andi34 committed Sep 8, 2019
1 parent 816e7d9 commit 683d9fb
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
5 changes: 5 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
'name' => 'use_qr',
'value' => $config['use_qr']
],
'print_qrcode' => [
'type' => 'checkbox',
'name' => 'print_qrcode',
'value' => $config['print_qrcode']
],
'use_mail' => [
'type' => 'checkbox',
'name' => 'use_mail',
Expand Down
1 change: 1 addition & 0 deletions config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
$config['dev'] = false;
$config['use_print'] = false;
$config['use_qr'] = true;
$config['print_qrcode'] = true;
$config['use_mail'] = false; // mail data needs to be configured
$config['use_mobile_view'] = false;
$config['use_gpio_button'] = false; // Use alt+p to take a new picture, can be triggered via GPIO24
Expand Down
1 change: 1 addition & 0 deletions lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ L10N = {
"keyingerror" : "Chroma-Keying nicht möglich!",
"use_print": "Drucken aktivieren",
"use_qr": "QR-Code aktivieren",
"print_qrcode" : "QR-Code auf dem Bild beim Drucken",
"show_gallery": "Galerie aktivieren",
"scrollbar": "Scrollbar in Galerie aktivieren",
"show_date": "Datum in Galerie unter dem Foto anzeigen (funktioniert nur wenn Bilder mit Datum benannt werden)",
Expand Down
1 change: 1 addition & 0 deletions lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ L10N = {
"keyingerror" : "Chroma keying not possible!",
"use_print": "Use Print",
"use_qr": "Use QR Codes",
"print_qrcode" : "QR-Code on the picture while printing",
"show_gallery": "Show Gallery",
"scrollbar": "Show scrollbar in Gallery",
"show_date": "Show date below images in Gallery (only works if dateformat images is used)",
Expand Down
1 change: 1 addition & 0 deletions lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ L10N = {
"keyingerror" : "L'incrustation chroma n'est pas possible!",
"use_print": "Utiliser l'impression",
"use_qr": "Utiliser les codes QR",
"print_qrcode" : "QR-Code sur l'image en cours d'impression",
"show_gallery": "Montrer la galerie",
"scrollbar": "Afficher la barre de défilement dans la galerie",
"show_date": "Montrez la date sous les images (fonctionne uniquement avec images au format de date)",
Expand Down
43 changes: 24 additions & 19 deletions print.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,35 @@
// print
// copy and merge
if(!file_exists($filename_print)) {
// create qr code
if(!file_exists($filename_codes)) {
include('resources/lib/phpqrcode/qrlib.php');
$url = 'http://'.$_SERVER['HTTP_HOST'].'/download.php?image=';
QRcode::png($url.$filename, $filename_codes, QR_ECLEVEL_H, 10);
}
if($config['print_qrcode'] == true) {
// create qr code
if(!file_exists($filename_codes)) {
include('resources/lib/phpqrcode/qrlib.php');
$url = 'http://'.$_SERVER['HTTP_HOST'].'/download.php?image=';
QRcode::png($url.$filename, $filename_codes, QR_ECLEVEL_H, 10);
}

// merge source and code
list($width, $height) = getimagesize($filename_source);
$newwidth = $width + ($height / 2);
$newheight = $height;
// merge source and code
list($width, $height) = getimagesize($filename_source);
$newwidth = $width + ($height / 2);
$newheight = $height;

$source = imagecreatefromjpeg($filename_source);
$code = imagecreatefrompng($filename_codes);
$print = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename_source);
$code = imagecreatefrompng($filename_codes);
$print = imagecreatetruecolor($newwidth, $newheight);

imagefill($print, 0, 0, imagecolorallocate($print, 255, 255, 255));
imagecopy($print, $source , 0, 0, 0, 0, $width, $height);
imagecopyresized($print, $code, $width, 0, 0, 0, ($height / 2), ($height / 2), imagesx($code), imagesy($code));
imagefill($print, 0, 0, imagecolorallocate($print, 255, 255, 255));
imagecopy($print, $source , 0, 0, 0, 0, $width, $height);
imagecopyresized($print, $code, $width, 0, 0, 0, ($height / 2), ($height / 2), imagesx($code), imagesy($code));

imagejpeg($print, $filename_print);
imagejpeg($print, $filename_print);
imagedestroy($code);
imagedestroy($source);
} else {
$print = imagecreatefromjpeg($filename_source);
imagejpeg($print, $filename_print);
}
imagedestroy($print);
imagedestroy($code);
imagedestroy($source);
}

// print image
Expand Down

0 comments on commit 683d9fb

Please sign in to comment.