Merge e2c72993dfd5dbb3eeb297da46b6ff7c9cb478f9 into f077a800f9ae89ee21d2421872344c5723fabd02

This commit is contained in:
Asger Hautop Drewsen 2021-04-13 10:01:51 +02:00 committed by GitHub
commit e053bde83e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

7
app.js
View File

@ -97,8 +97,11 @@ conversionRouter.post('/convert', async (req, res) => {
// Convert to PNG
} else if (fileFormat === 'png') {
await sharp(inputSvgFileName, { density: 96 })
.toFile(outputFileName); // Sharp's PNG type is implicitly determined via the output file extension
let s = sharp(inputSvgFileName, { density: 96 });
if (req.body.transparentBackground === 'false') {
s = s.flatten({ background: { r: 255, g: 255, b: 255 } });
}
await s.toFile(outputFileName); // Sharp's PNG type is implicitly determined via the output file extension
// Convert to JPG
} else {

View File

@ -68,6 +68,14 @@
</label>
</div>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="transparentBackgroundCheckbox" checked>
<label class="form-check-label" for="transparentBackgroundCheckbox">
Transparent background (for PNG)
</label>
</div>
</div>
<button class="btn btn-primary" type="button" id="convertButton">
<span class="spinner-grow spinner-grow-sm d-none" role="status" aria-hidden="true" id="convertSpinner"></span>
<span id="convertButtonText">Convert</span>

View File

@ -57,7 +57,8 @@ $(document).ready(function() {
data: {
latexInput: latexInput,
outputFormat: $('#outputFormatSelect').val(),
outputScale: $('#outputScaleSelect').val()
outputScale: $('#outputScaleSelect').val(),
transparentBackground: $('#transparentBackgroundCheckbox').prop('checked'),
},
success: function(data) {
$('#convertButton').prop('disabled', false);