diff --git a/api/print.php b/api/print.php index e57f60271..d2763f4c0 100644 --- a/api/print.php +++ b/api/print.php @@ -8,6 +8,12 @@ require_once '../lib/applyText.php'; require_once '../lib/log.php'; +function applyQR($sourceResource, $qrPath, $x, $y) { + $qr = imagecreatefrompng($qrPath); + imagecopy($sourceResource, $qr, $x, $y, 0, 0, imagesx($qr), imagesy($qr)); + return $sourceResource; +} + if (empty($_GET['filename'])) { $errormsg = basename($_SERVER['PHP_SELF']) . ': No file provided!'; logErrorAndDie($errormsg); @@ -54,11 +60,13 @@ $image = imagecreatefromjpeg($filename_source); imagejpeg($image, $filename_print, $quality); imagedestroy($image); // Destroy the created collage in memory + $rotateQr = false; } else { $image = imagecreatefromjpeg($filename_source); $resultRotated = imagerotate($image, 90, 0); // Rotate image imagejpeg($resultRotated, $filename_print, $quality); imagedestroy($image); // Destroy the created collage in memory + $rotateQr = true; // re-define width & height after rotation list($width, $height) = getimagesize($filename_print); } @@ -74,27 +82,67 @@ $url = $config['qr']['url']; } include '../vendor/phpqrcode/lib/full/qrlib.php'; - QRcode::png($url, $filename_codes, QR_ECLEVEL_H, 10); + switch ($config['qr']['ecLevel']) { + case 'QR_ECLEVEL_L': + $ecLevel = QR_ECLEVEL_L; + break; + case 'QR_ECLEVEL_M': + $ecLevel = QR_ECLEVEL_M; + break; + case 'QR_ECLEVEL_Q': + $ecLevel = QR_ECLEVEL_Q; + break; + case 'QR_ECLEVEL_H': + $ecLevel = QR_ECLEVEL_H; + break; + default: + $ecLevel = QR_ECLEVEL_M; + break; + } + QRcode::png($url, $filename_codes, $ecLevel, $config['print']['qrSize']); + if ($rotateQr) { + $image = imagecreatefrompng($filename_codes); + $resultRotated = imagerotate($image, 90, 0); + imagepng($resultRotated, $filename_codes, 0); + imagedestroy($image); + } } - // merge source and code - $newwidth = $width + $height / 2; - $newheight = $height; - if ($config['print']['print_frame'] && testFile($config['print']['frame'])) { $source = applyFrame($source, $print_frame); } - $code = imagecreatefrompng($filename_codes); - $print = imagecreatetruecolor($newwidth, $newheight); + list($qrWidth, $qrHeight) = getimagesize($filename_codes); + + if (is_numeric($config['print']['qrOffset'])) { + $offset = $config['print']['qrOffset']; + } else { + $offset = 10; + } - 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, $quality); - imagedestroy($code); - imagedestroy($print); - $source = imagecreatefromjpeg($filename_print); + switch ($config['print']['qrPosition']) { + case 'topLeft': + $x = $offset; + $y = $offset; + break; + case 'topRight': + $x = $width - ($qrWidth + $offset); + $y = $offset; + break; + case 'bottomRight': + $x = $width - ($qrWidth + $offset); + $y = $height - ($qrHeight + $offset); + break; + case 'bottomLeft': + $x = $offset; + $y = $height - ($qrHeight + $offset); + break; + default: + $x = $width - ($qrWidth + $offset); + $y = $height - ($qrHeight + $offset); + break; + } + $source = applyQR($source, $filename_codes, $x, $y); } else { if ($config['print']['print_frame'] && testFile($config['print']['frame'])) { $source = applyFrame($source, $print_frame); diff --git a/api/qrcode.php b/api/qrcode.php index e91d2233c..f367a1e83 100644 --- a/api/qrcode.php +++ b/api/qrcode.php @@ -11,4 +11,22 @@ } include '../vendor/phpqrcode/lib/full/qrlib.php'; -QRcode::png($url, false, QR_ECLEVEL_H, 10); +switch ($config['qr']['ecLevel']) { + case 'QR_ECLEVEL_L': + $ecLevel = QR_ECLEVEL_L; + break; + case 'QR_ECLEVEL_M': + $ecLevel = QR_ECLEVEL_M; + break; + case 'QR_ECLEVEL_Q': + $ecLevel = QR_ECLEVEL_Q; + break; + case 'QR_ECLEVEL_H': + $ecLevel = QR_ECLEVEL_H; + break; + default: + $ecLevel = QR_ECLEVEL_M; + break; +} + +QRcode::png($url, false, $ecLevel, 8); diff --git a/config/config.inc.php b/config/config.inc.php index d9d17228f..e71dd2770 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -188,6 +188,9 @@ $config['print']['time'] = '5000'; $config['print']['key'] = null; $config['print']['qrcode'] = false; +$config['print']['qrSize'] = '4'; +$config['print']['qrPosition'] = 'bottomRight'; +$config['print']['qrOffset'] = 10; $config['print']['print_frame'] = false; $config['print']['frame'] = 'resources/img/frames/frame.png'; $config['print']['crop'] = false; @@ -208,6 +211,7 @@ // Q R - C O D E $config['qr']['enabled'] = true; +$config['qr']['ecLevel'] = 'QR_ECLEVEL_M'; $config['qr']['url'] = NULL; $config['qr']['append_filename'] = true; $config['qr']['custom_text'] = false; diff --git a/lib/configsetup.inc.php b/lib/configsetup.inc.php index 7f838b2ec..f4856684d 100644 --- a/lib/configsetup.inc.php +++ b/lib/configsetup.inc.php @@ -1156,6 +1156,37 @@ 'name' => 'print[qrcode]', 'value' => $config['print']['qrcode'], ], + 'print_qrSize' => [ + 'view' => 'advanced', + 'type' => 'range', + 'placeholder' => $defaultConfig['print']['qrSize'], + 'name' => 'print[qrSize]', + 'value' => $config['print']['qrSize'], + 'range_min' => 4, + 'range_max' => 10, + 'range_step' => 2, + 'unit' => 'empty', + ], + 'print_qrPosition' => [ + 'view' => 'advanced', + 'type' => 'select', + 'name' => 'print[qrPosition]', + 'placeholder' => $defaultConfig['print']['qrPosition'], + 'options' => [ + 'topLeft' => 'top left', + 'topRight' => 'top right', + 'bottomLeft' => 'bottom left', + 'bottomRight' => 'bottom right', + ], + 'value' => $config['print']['qrPosition'], + ], + 'print_qrOffset' => [ + 'view' => 'expert', + 'type' => 'input', + 'placeholder' => $defaultConfig['print']['qrOffset'], + 'name' => 'print[qrOffset]', + 'value' => $config['print']['qrOffset'], + ], 'print_print_frame' => [ 'view' => 'expert', 'type' => 'checkbox', @@ -1278,6 +1309,18 @@ 'name' => 'qr[enabled]', 'value' => $config['qr']['enabled'], ], + 'qr_ecLevel' => [ + 'type' => 'select', + 'name' => 'qr[ecLevel]', + 'placeholder' => $defaultConfig['qr']['ecLevel'], + 'options' => [ + 'QR_ECLEVEL_L' => 'L - smallest', + 'QR_ECLEVEL_M' => 'M', + 'QR_ECLEVEL_Q' => 'Q', + 'QR_ECLEVEL_H' => 'H - best', + ], + 'value' => $config['qr']['ecLevel'], + ], 'qr_url' => [ 'view' => 'expert', 'type' => 'input', diff --git a/resources/lang/en.json b/resources/lang/en.json index 02d84671d..00b19d519 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -89,7 +89,7 @@ "folders:folders_images": "Image Folder", "folders:folders_keying": "Keying Folder", "folders:folders_print": "Print Folder", - "folders:folders_qrcodes": "QR-Code Folder", + "folders:folders_qrcodes": "QR Code Folder", "folders:folders_thumbs": "Thumbnail Folder", "folders:folders_tmp": "tmp Folder", "foldersize": "Foldersize:", @@ -398,7 +398,10 @@ "manual:print:print_from_result": "If enabled, a print button is visible on result screen.", "manual:print:print_key": "Specify the key id to use that key to print a picture (e.g. 13 is the enter key). For example use https://keycode.info to find out the key id.", "manual:print:print_print_frame": "If enabled, a frame is applied on your picture at print.", - "manual:print:print_qrcode": "If enabled, a QR-Code is printed onto the right side of the picture while printing.", + "manual:print:print_qrOffset": "Define an offset value the QR Code is placed away from the edges of the picture.", + "manual:print:print_qrPosition": "QR Code position", + "manual:print:print_qrSize": "Define the size of the QR Code. 4 = small, 10 = extra large.", + "manual:print:print_qrcode": "If enabled, a QR Code is printed onto the right side of the picture while printing.", "manual:print:print_time": "Enter in milliseconds, how long \"Started printing! Please wait....\" is displayed after a print job has started.", "manual:print:textonprint_enabled": "If enabled, you can print some text onto your pictures.", "manual:print:textonprint_font": "Enter the path to the font used to print text onto your image.", @@ -413,7 +416,8 @@ "manual:print:textonprint_rotation": "Enter a value which is used as degrees the text gets rotated at print.", "manual:qr:qr_append_filename": "If enabled, the image name will be added to the QR URL.", "manual:qr:qr_custom_text": "If enabled, own defined help text will be visible below the QR Code.", - "manual:qr:qr_enabled": "If enabled, a QR-Button is visible on the result screen and inside gallery. User can download a picture while scanning the QR-Code. If you're accessing Photobooth via \"localhost\", \"127.0.0.1\" or if you have Photobooth installed inside a subfolder, please define IP address of the Photobooth web server to make the QR-Code working.
Example if Photobooth can be accessed directly: 192.168.0.50
.
Example if Photobooth is installed inside a subfolder: 192.168.0.50/photobooth
.
Example if Photobooth can be accessed directly: 192.168.0.50
.
Example if Photobooth is installed inside a subfolder: 192.168.0.50/photobooth
.