|
@@ -119,7 +119,7 @@ module.exports.parse = async (fileObj, data) => {
|
|
|
return { value: result };
|
|
return { value: result };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-module.exports.createThumbnail = async (fileObj, width, height, quality) => {
|
|
|
|
|
|
|
+module.exports.createThumbnail = async (fileObj, width, height, quality, keepMeta) => {
|
|
|
if (!fileObj?.meta?.width || !fileObj?.meta?.height)
|
|
if (!fileObj?.meta?.width || !fileObj?.meta?.height)
|
|
|
return null;
|
|
return null;
|
|
|
if (!width && !height)
|
|
if (!width && !height)
|
|
@@ -127,10 +127,12 @@ module.exports.createThumbnail = async (fileObj, width, height, quality) => {
|
|
|
let ratio = Math.min((width / fileObj.meta.width) || 1, (height / fileObj.meta.height) || 1, 1);
|
|
let ratio = Math.min((width / fileObj.meta.width) || 1, (height / fileObj.meta.height) || 1, 1);
|
|
|
const output = tmp.fileSync({ discardDescriptor: true });
|
|
const output = tmp.fileSync({ discardDescriptor: true });
|
|
|
try {
|
|
try {
|
|
|
- await im.convert([
|
|
|
|
|
- fileObj.path,
|
|
|
|
|
- '-strip',
|
|
|
|
|
|
|
+ let args = [ fileObj.path ];
|
|
|
|
|
+ if (keepMeta !== true)
|
|
|
|
|
+ args.push('-strip');
|
|
|
|
|
+ await im.convert([...args,
|
|
|
'-interlace', 'Plane',
|
|
'-interlace', 'Plane',
|
|
|
|
|
+ '-auto-orient',
|
|
|
'-resize', (Math.floor(fileObj.meta.width * ratio)),
|
|
'-resize', (Math.floor(fileObj.meta.width * ratio)),
|
|
|
'-quality', '' + (Math.floor(Math.max(0, Math.min(100, (quality *10))))) + '%',
|
|
'-quality', '' + (Math.floor(Math.max(0, Math.min(100, (quality *10))))) + '%',
|
|
|
'-sampling-factor', '4:2:0',
|
|
'-sampling-factor', '4:2:0',
|