add default JPG quality if value not in range

This commit is contained in:
zadam 2021-12-16 22:10:51 +01:00
parent 074eb1c02f
commit a098630e09
2 changed files with 7 additions and 3 deletions

View file

@ -34,8 +34,8 @@ const TPL = `
</div>
<div class="form-group">
<label for="image-jpeg-quality">JPEG quality (0 - worst quality, 100 best quality, 50 - 85 is recommended)</label>
<input class="form-control" id="image-jpeg-quality" min="0" max="100" type="number">
<label for="image-jpeg-quality">JPEG quality (10 - worst quality, 100 best quality, 50 - 85 is recommended)</label>
<input class="form-control" id="image-jpeg-quality" min="10" max="100" type="number">
</div>
</div>

View file

@ -122,7 +122,11 @@ function saveImage(parentNoteId, uploadBuffer, originalName, shrinkImageSwitch,
}
async function shrinkImage(buffer, originalName) {
const jpegQuality = optionService.getOptionInt('imageJpegQuality');
let jpegQuality = optionService.getOptionInt('imageJpegQuality');
if (jpegQuality < 10 || jpegQuality > 100) {
jpegQuality = 75;
}
let finalImageBuffer;
try {