|
|
@ -176,7 +176,7 @@ module.exports = async (req, res, next) => { |
|
|
|
} |
|
|
|
} |
|
|
|
let imageData; |
|
|
|
let imageData; |
|
|
|
if (type === 'image') { |
|
|
|
if (type === 'image') { |
|
|
|
///detect images with opacity for PNG thumbnails, settumh thumbextension before increment
|
|
|
|
///detect images with opacity for PNG thumbnails, set thumbextension before increment
|
|
|
|
imageData = await imageIdentify(req.files.file[i].tempFilePath, null, true); |
|
|
|
imageData = await imageIdentify(req.files.file[i].tempFilePath, null, true); |
|
|
|
if (imageData['Channel Statistics'] && imageData['Channel Statistics']['Opacity']) { //does this change depending on GM version or anything?
|
|
|
|
if (imageData['Channel Statistics'] && imageData['Channel Statistics']['Opacity']) { //does this change depending on GM version or anything?
|
|
|
|
const opacityMaximum = imageData['Channel Statistics']['Opacity']['Maximum']; |
|
|
|
const opacityMaximum = imageData['Channel Statistics']['Opacity']['Maximum']; |
|
|
@ -191,12 +191,13 @@ module.exports = async (req, res, next) => { |
|
|
|
|
|
|
|
|
|
|
|
//check if already exists
|
|
|
|
//check if already exists
|
|
|
|
const existsFull = await pathExists(`${uploadDirectory}/img/${processedFile.filename}`); |
|
|
|
const existsFull = await pathExists(`${uploadDirectory}/img/${processedFile.filename}`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processedFile.sizeString = formatSize(processedFile.size) |
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
|
case 'image': { |
|
|
|
case 'image': { |
|
|
|
const existsThumb = await pathExists(`${uploadDirectory}/img/thumb-${processedFile.hash}${processedFile.thumbextension}`); |
|
|
|
const existsThumb = await pathExists(`${uploadDirectory}/img/thumb-${processedFile.hash}${processedFile.thumbextension}`); |
|
|
|
processedFile.geometry = imageData.size // object with width and height pixels
|
|
|
|
processedFile.geometry = imageData.size ; |
|
|
|
processedFile.sizeString = formatSize(processedFile.size) // 123 Ki string
|
|
|
|
processedFile.geometryString = imageData.Geometry; |
|
|
|
processedFile.geometryString = imageData.Geometry // 123 x 123 string
|
|
|
|
|
|
|
|
processedFile.hasThumb = !(fileCheckMimeType(file.mimetype, {image: true}) |
|
|
|
processedFile.hasThumb = !(fileCheckMimeType(file.mimetype, {image: true}) |
|
|
|
&& processedFile.geometry.height <= thumbSize |
|
|
|
&& processedFile.geometry.height <= thumbSize |
|
|
|
&& processedFile.geometry.width <= thumbSize); |
|
|
|
&& processedFile.geometry.width <= thumbSize); |
|
|
@ -223,10 +224,9 @@ module.exports = async (req, res, next) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
processedFile.duration = videoData.format.duration; |
|
|
|
processedFile.duration = videoData.format.duration; |
|
|
|
processedFile.durationString = new Date(videoData.format.duration*1000).toISOString().substr(11,8).replace(/^00:/, '');//breaks for over 24h video
|
|
|
|
processedFile.durationString = timeUtils.durationString(videoData.format.duration*1000); |
|
|
|
processedFile.geometry = {width: videoData.streams[0].coded_width, height: videoData.streams[0].coded_height} // object with width and height pixels
|
|
|
|
processedFile.geometry = {width: videoData.streams[0].coded_width, height: videoData.streams[0].coded_height}; |
|
|
|
processedFile.sizeString = formatSize(processedFile.size) // 123 Ki string
|
|
|
|
processedFile.geometryString = `${processedFile.geometry.width}x${processedFile.geometry.height}` |
|
|
|
processedFile.geometryString = `${processedFile.geometry.width}x${processedFile.geometry.height}` // 123 x 123 string
|
|
|
|
|
|
|
|
processedFile.hasThumb = true; |
|
|
|
processedFile.hasThumb = true; |
|
|
|
if (!existsFull) { |
|
|
|
if (!existsFull) { |
|
|
|
await moveUpload(file, processedFile.filename, 'img'); |
|
|
|
await moveUpload(file, processedFile.filename, 'img'); |
|
|
@ -239,8 +239,7 @@ module.exports = async (req, res, next) => { |
|
|
|
case 'audio': { |
|
|
|
case 'audio': { |
|
|
|
const audioData = await ffprobe(req.files.file[i].tempFilePath, null, true); |
|
|
|
const audioData = await ffprobe(req.files.file[i].tempFilePath, null, true); |
|
|
|
processedFile.duration = audioData.format.duration; |
|
|
|
processedFile.duration = audioData.format.duration; |
|
|
|
processedFile.durationString = new Date(audioData.format.duration*1000).toISOString().substr(11,8).replace(/^00:/, '');//breaks for over 24h video
|
|
|
|
processedFile.durationString = timeUtils.durationString(audioData.format.duration*1000); |
|
|
|
processedFile.sizeString = formatSize(processedFile.size) // 123 Ki string
|
|
|
|
|
|
|
|
processedFile.hasThumb = false; |
|
|
|
processedFile.hasThumb = false; |
|
|
|
if (!existsFull) { |
|
|
|
if (!existsFull) { |
|
|
|
await moveUpload(file, processedFile.filename, 'img'); |
|
|
|
await moveUpload(file, processedFile.filename, 'img'); |
|
|
|