Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
Allow printing frame on the picture
Browse files Browse the repository at this point in the history
- "frame.png" needes to be added in root of photobooth
- only works if $config['print_qrcode'] = false;

#22
andreknieriem#67
  • Loading branch information
andi34 committed Sep 8, 2019
1 parent 2c8ac57 commit 20a9b16
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
'name' => 'print_qrcode',
'value' => $config['print_qrcode']
],
'print_frame' => [
'type' => 'checkbox',
'name' => 'print_frame',
'value' => $config['print_frame']
],
'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 @@ -11,6 +11,7 @@
$config['use_print'] = false;
$config['use_qr'] = true;
$config['print_qrcode'] = true;
$config['print_frame'] == false; // only works if $config['print_qrcode'] = false;
$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
3 changes: 2 additions & 1 deletion lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ L10N = {
"symbol": "Symbol auswählen",
"selectFilter": "Bildfilter",
"use_filter": "Bildfilter erlauben",
"use_collage": "Foto-Collage erlauben"
"use_collage": "Foto-Collage erlauben",
"print_frame": "Rahmen auf Bild drucken"
}
3 changes: 2 additions & 1 deletion lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ L10N = {
"symbol": "Choose a symbol",
"selectFilter": "Image filter",
"use_filter": "Allow image filter",
"use_collage": "Allow collage photo"
"use_collage": "Allow collage photo",
"print_frame": "Print frame on picture"
}
3 changes: 2 additions & 1 deletion lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ L10N = {
"symbol": "Sélectionnez le symbole",
"selectFilter": "Filtre d'image",
"use_filter": "Autoriser le filtre d'image",
"use_collage": "Autoriser la fonction du montage photo"
"use_collage": "Autoriser la fonction du montage photo",
"print_frame": "Imprimer le cadre sur la photo"
}
22 changes: 22 additions & 0 deletions print.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
imagedestroy($source);
} else {
$print = imagecreatefromjpeg($filename_source);
if($config['print_frame'] == true) {
$rahmen = @imagecreatefrompng('frame.png');
$rahmen = ResizePngImage($rahmen, imagesx($print), imagesy($print));
$x = (imagesx($print)/2) - (imagesx($rahmen)/2);
$y = (imagesy($print)/2) - (imagesy($rahmen)/2);
imagecopy($print, $rahmen, $x, $y, 0, 0, imagesx($rahmen), imagesy($rahmen));
}
imagejpeg($print, $filename_print);
}
imagedestroy($print);
Expand All @@ -69,3 +76,18 @@
);
echo json_encode(array('status' => 'ok', 'msg' => $printimage || ''));
}

function ResizePngImage($image, $max_width, $max_height)
{
$old_width = imagesx($image);
$old_height = imagesy($image);
$scale = min($max_width/$old_width, $max_height/$old_height);
$new_width = ceil($scale*$old_width);
$new_height = ceil($scale*$old_height);
$new = imagecreatetruecolor($new_width, $new_height);
imagealphablending( $new, false );
imagesavealpha( $new, true );
imagecopyresized($new, $image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);

return $new;
}

0 comments on commit 20a9b16

Please sign in to comment.