Skip to content

Commit

Permalink
Merge pull request #175 from rawbertp/rp-image-quality-config
Browse files Browse the repository at this point in the history
Make JPEG quality configurable
  • Loading branch information
sualko authored Nov 5, 2019
2 parents 9222eb8 + 1e00909 commit 31eb98d
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 12 deletions.
8 changes: 4 additions & 4 deletions api/applyEffects.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@
if ($config['chroma_keying']) {
$chromaCopyResource = resizeImage($imageResource, 1500, 1000);

imagejpeg($chromaCopyResource, $filename_keying, 70);
imagejpeg($chromaCopyResource, $filename_keying, $config['jpeg_quality_chroma']);
imagedestroy($chromaCopyResource);
}

// image scale, create thumbnail
$thumbResource = resizeImage($imageResource, 500, 500);

imagejpeg($thumbResource, $filename_thumb, 60);
imagejpeg($thumbResource, $filename_thumb, $config['jpeg_quality_thumb']);
imagedestroy($thumbResource);

imagejpeg($imageResource, $filename_photo, 80);
imagejpeg($imageResource, $filename_photo, $config['jpeg_quality_image']);
imagedestroy($imageResource);

// insert into database
appendImageToDB($file);

echo json_encode([
'file' => $file,
]);
]);
4 changes: 2 additions & 2 deletions api/chromakeying/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$image = imagecreatefromstring($data);
imagejpeg($image, $filename_photo, 100);
imagejpeg($image, $filename_photo, $config['jpeg_quality_image']);

$image = ResizeJpgImage($image, 500, 500);
imagejpeg($image, $filename_thumb, 100);
imagejpeg($image, $filename_thumb, $config['jpeg_quality_thumb']);

imagedestroy($image);

Expand Down
5 changes: 5 additions & 0 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@
$config['take_picture']['msg'] = null;
$config['print']['cmd'] = null;
$config['print']['msg'] = null;

$config['jpeg_quality_thumb'] = 60;
$config['jpeg_quality_chroma'] = 70;
$config['jpeg_quality_image'] = 80;

19 changes: 18 additions & 1 deletion lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,23 @@
'value' => $config['previewFromCam']
]
],
'jpeg_quality' => [
'jpeg_quality_image' => [
'type' => 'input',
'name' => 'jpeg_quality_image',
'value' => $config['jpeg_quality_image']
],
'jpeg_quality_chroma' => [
'type' => 'input',
'name' => 'jpeg_quality_chroma',
'value' => $config['jpeg_quality_chroma']
],
'jpeg_quality_thumb' => [
'type' => 'input',
'name' => 'jpeg_quality_thumb',
'value' => $config['jpeg_quality_thumb']
]
],
'user_interface' => [
'color_theme' => [
'type' => 'select',
Expand Down Expand Up @@ -441,4 +458,4 @@
'value' => $config['print']['msg']
]
]
];
];
6 changes: 5 additions & 1 deletion resources/lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,9 @@ const L10N = {
'color_theme': 'Theme auswählen',
'crop_onprint': 'Bild bei Ausdruck zurechtschneiden',
'print_crop_width': 'Neue Bildbreite bei Ausdruck',
'print_crop_height': 'Neue Bildhöhe bei Ausdruck'
'print_crop_height': 'Neue Bildhöhe bei Ausdruck',
'jpeg_quality': 'JPEG Qualität',
'jpeg_quality_jpeg_quality_image': 'JPEG Qualität für Bilder (-1 ... 100)',
'jpeg_quality_jpeg_quality_chroma': 'JPEG Qualität für Chroma-Keying (-1 ... 100)',
'jpeg_quality_jpeg_quality_thumb': 'JPEG Qualität für Thumbnails (-1 ... 100)'
}
6 changes: 5 additions & 1 deletion resources/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,9 @@ const L10N = {
'color_theme': 'Choose a theme',
'crop_onprint': 'Crop picture at print',
'print_crop_width': 'New width at print',
'print_crop_height': 'New height at print'
'print_crop_height': 'New height at print',
'jpeg_quality': 'JPEG quality',
'jpeg_quality_jpeg_quality_image': 'JPEG quality for images (-1 ... 100)',
'jpeg_quality_jpeg_quality_chroma': 'JPEG quality for chroma-keying (-1 ... 100)',
'jpeg_quality_jpeg_quality_thumb': 'JPEG quality for thumbnails (-1 ... 100)'
}
6 changes: 5 additions & 1 deletion resources/lang/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,9 @@ const L10N = {
'color_theme': 'Elige un tema',
'crop_onprint': 'Recortar imagen en la impresión',
'print_crop_width': 'Nuevo ancho en la impresión',
'print_crop_height': 'Nueva altura en la impresión'
'print_crop_height': 'Nueva altura en la impresión',
'jpeg_quality': 'Calidad de JPEG',
'jpeg_quality_jpeg_quality_image': 'Calidad de JPEG para fotos (-1 ... 100)',
'jpeg_quality_jpeg_quality_chroma': 'Calidad de JPEG para chroma-keying (-1 ... 100)',
'jpeg_quality_jpeg_quality_thumb': 'Calidad de JPEG para thumbnails (-1 ... 100)'
}
6 changes: 5 additions & 1 deletion resources/lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,9 @@ const L10N = {
'color_theme': 'Choisissez un thème',
'crop_onprint': 'Recadrer la photo à imprimer',
'print_crop_width': 'Nouvelle largeur à l\'impression',
'print_crop_height': 'Nouvelle hauteur à l\'impression'
'print_crop_height': 'Nouvelle hauteur à l\'impression',
'jpeg_quality': 'JPEG qualité',
'jpeg_quality_jpeg_quality_image': 'JPEG qualité des images (-1 ... 100)',
'jpeg_quality_jpeg_quality_chroma': 'JPEG qualité pour chroma-keying (-1 ... 100)',
'jpeg_quality_jpeg_quality_thumb': 'JPEG qualité des thumbnails (-1 ... 100)'
}
6 changes: 5 additions & 1 deletion resources/lang/gr.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,9 @@ const L10N = {
'color_theme': 'Επιλέξτε θέμα',
'crop_onprint': 'Τραβήξτε την εικόνα όταν εκτυπώνετε',
'print_crop_width': 'Νέο πλάτος εικόνας στην εκτύπωση',
'print_crop_height': 'Νέο ύψος εικόνας στην εκτύπωση'
'print_crop_height': 'Νέο ύψος εικόνας στην εκτύπωση',
'jpeg_quality': 'Ποιότητα JPEG',
'jpeg_quality_jpeg_quality_image': 'Ποιότητα JPEG για φωτογραφίες (-1 ... 100)',
'jpeg_quality_jpeg_quality_chroma': 'Ποιότητα JPEG για chroma-keying (-1 ... 100)',
'jpeg_quality_jpeg_quality_thumb': 'Ποιότητα JPEG για μικρογραφίες (-1 ... 100)'
}

0 comments on commit 31eb98d

Please sign in to comment.