Check to ensure image format conversion was successful
This commit is contained in:
parent
0cce3abc24
commit
05d3f49621
5
app.js
5
app.js
@ -110,6 +110,8 @@ app.post('/convert', function (req, res) {
|
||||
}
|
||||
shell.exec(finalSvgToImageCMD);
|
||||
|
||||
// Ensure conversion was successful; eg. fails if `svgexport` or `imagemin` is not installed
|
||||
if (fs.existsSync(`${tempDirRoot}${id}/equation.${fileFormat}`)) {
|
||||
// Compress the resultant image
|
||||
var finalImageMinCMD = imageMinCMD.replace('IN_FILE_NAME', `${tempDirRoot}${id}/equation.${fileFormat}`);
|
||||
finalImageMinCMD = finalImageMinCMD.replace('OUT_FILE_NAME', `${tempDirRoot}${id}/equation_compressed.${fileFormat}`);
|
||||
@ -119,6 +121,9 @@ app.post('/convert', function (req, res) {
|
||||
shell.cp(`${tempDirRoot}${id}/equation_compressed.${fileFormat}`, `${outputDir}img-${id}.${fileFormat}`);
|
||||
|
||||
result.imageURL = `${httpOutputURL}img-${id}.${fileFormat}`;
|
||||
} else {
|
||||
result.error = `Error converting SVG file to ${fileFormat.toUpperCase()} image.`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.error = 'Error converting LaTeX to image. Please ensure the input is valid.';
|
||||
|
Loading…
x
Reference in New Issue
Block a user