Add option to save PNG without transparency
This commit is contained in:
parent
f077a800f9
commit
e2c72993df
7
app.js
7
app.js
@ -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 {
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user