Skip to content

TagSpaces is an offline, open source, document manager with tagging support

feature: added UTIF and TGA.js for thumbnail generation

Ilian Sapundshiev3aa2807fc1a5
diff --git a/app/services/thumbsgenerator.ts b/app/services/thumbsgenerator.ts
index 56fc02f44..b1ffa2c42 100644
--- a/app/services/thumbsgenerator.ts
+++ b/app/services/thumbsgenerator.ts
@@ -44,6 +44,13 @@ export const supportedImgs = [
'svg',
'webp',
'bmp',
+ 'tga',
+ 'tif',
+ 'tiff',
+ 'nef',
+ 'cr2',
+ 'dng',
+ 'psd',
'avif'
];
export const supportedContainers = [
@@ -98,7 +105,7 @@ export const supportedText = [
// 'mhtml'
];
export const supportedVideos = ['ogv', 'mp4', 'webm', 'm4v', 'mkv', 'lrv'];
-const maxFileSize = 30 * 1024 * 1024;
+const maxFileSize = 30 * 1024 * 1024; // 30 MB
function saveThumbnailPromise(filePath, dataURL) {
if (!dataURL || dataURL.length < 7) {
@@ -277,7 +284,17 @@ export function generateThumbnailPromise(fileURL: string, fileSize: number) {
const fileURLEscaped = encodeFileName(fileURL, PlatformIO.getDirSeparator());
if (supportedImgs.indexOf(ext) >= 0) {
- if (fileSize && fileSize < maxFileSize) {
+ if (Pro && ext === 'tga') {
+ return Pro.ThumbsGenerator.generateTGAThumbnail(fileURLEscaped, maxSize);
+ } else if (Pro && ext.startsWith('tif')) {
+ return Pro.ThumbsGenerator.generateUTIFThumbnail(fileURLEscaped, maxSize);
+ } else if (Pro && ext === 'dng') {
+ return Pro.ThumbsGenerator.generateUTIFThumbnail(fileURLEscaped, maxSize);
+ } else if (Pro && ext === 'nef') {
+ return Pro.ThumbsGenerator.generateUTIFThumbnail(fileURLEscaped, maxSize);
+ } else if (Pro && ext === 'cr2') {
+ return Pro.ThumbsGenerator.generateUTIFThumbnail(fileURLEscaped, maxSize);
+ } else if (fileSize && fileSize < maxFileSize) {
return generateImageThumbnail(fileURLEscaped);
}
} else if (Pro && ext === 'pdf') {
@@ -286,8 +303,6 @@ export function generateThumbnailPromise(fileURL: string, fileSize: number) {
return Pro.ThumbsGenerator.generateHtmlThumbnail(fileURLEscaped, maxSize);
} else if (Pro && ext === 'url') {
return Pro.ThumbsGenerator.generateUrlThumbnail(fileURLEscaped, maxSize);
- } else if (Pro && ext === 'tiff') {
- return Pro.ThumbsGenerator.generateTiffThumbnail(fileURLEscaped, maxSize);
} else if (Pro && ext === 'mp3') {
if (fileSize && fileSize < maxFileSize) {
// return Pro.ThumbsGenerator.generateMp3Thumbnail(fileURL, maxSize);
diff --git a/package-lock.json b/package-lock.json
index d561e6934..6debd64a2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -75,8 +75,10 @@
"redux-thunk": "^2.4.1",
"semver": "^7.3.5",
"source-map-support": "^0.5.21",
+ "tga-js": "1.1.1",
"ts-react-splitter": "^3.0.0",
"use-state-with-callback": "^2.0.3",
+ "utif": "github:photopea/UTIF.js",
"uuid": "^9.0.0"
},
"devDependencies": {
@@ -46149,6 +46151,11 @@
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
"dev": true
},
+ "node_modules/tga-js": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/tga-js/-/tga-js-1.1.1.tgz",
+ "integrity": "sha512-2EcbDHfFCggAt0DLjUwZzKaQGaCmcQZBQrYscVnWjxzl+2Q1PFp1ABsO2UVevF1pTi2t9mmWkzPaQqUeJA+mhA=="
+ },
"node_modules/throat": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz",
@@ -47308,6 +47315,19 @@
"integrity": "sha512-4+wkEYLBbWxqTahEsWrhxepcoVOJ+1z5PGIjPZxRkytcdSUaNjIjBM7Xn8E+pdSuV7SzvWovBFA54FO0JSoqhA==",
"dev": true
},
+ "node_modules/utif": {
+ "version": "3.1.0",
+ "resolved": "git+ssh://[email protected]/photopea/UTIF.js.git#9a5f18e36b40e4eb2b9f776adbcf2069e28bf463",
+ "license": "MIT",
+ "dependencies": {
+ "pako": "^1.0.5"
+ }
+ },
+ "node_modules/utif/node_modules/pako": {
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
+ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
+ },
"node_modules/util": {
"version": "0.12.5",
"resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz",
@@ -84434,6 +84454,11 @@
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
"dev": true
},
+ "tga-js": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/tga-js/-/tga-js-1.1.1.tgz",
+ "integrity": "sha512-2EcbDHfFCggAt0DLjUwZzKaQGaCmcQZBQrYscVnWjxzl+2Q1PFp1ABsO2UVevF1pTi2t9mmWkzPaQqUeJA+mhA=="
+ },
"throat": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz",
@@ -85337,6 +85362,20 @@
"integrity": "sha512-4+wkEYLBbWxqTahEsWrhxepcoVOJ+1z5PGIjPZxRkytcdSUaNjIjBM7Xn8E+pdSuV7SzvWovBFA54FO0JSoqhA==",
"dev": true
},
+ "utif": {
+ "version": "git+ssh://[email protected]/photopea/UTIF.js.git#9a5f18e36b40e4eb2b9f776adbcf2069e28bf463",
+ "from": "utif@https://github.com/photopea/UTIF.js",
+ "requires": {
+ "pako": "^1.0.5"
+ },
+ "dependencies": {
+ "pako": {
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
+ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
+ }
+ }
+ },
"util": {
"version": "0.12.5",
"resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz",
diff --git a/package.json b/package.json
index 2bc869d7f..7242d9658 100644
--- a/package.json
+++ b/package.json
@@ -212,8 +212,10 @@
"redux-thunk": "^2.4.1",
"semver": "^7.3.5",
"source-map-support": "^0.5.21",
+ "tga-js": "1.1.1",
"ts-react-splitter": "^3.0.0",
"use-state-with-callback": "^2.0.3",
+ "utif": "github:photopea/UTIF.js",
"uuid": "^9.0.0"
},
"devDependencies": {