Skip to content

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

make thumb bg color configurable (#945)

Guy Bedford3d68fddc86d3
diff --git a/app/config.js b/app/config.js
index 1074d180d..ac66264e6 100644
--- a/app/config.js
+++ b/app/config.js
@@ -37,6 +37,7 @@ export default {
tagDelimiter: ' ',
prefixTagContainer: '',
maxThumbSize: 400,
+ thumbBgColor: 'black',
indexerLimit: 200000,
// maxSearchResult: 1000,
defaultFileColor: '#808080',
diff --git a/app/services/thumbsgenerator.js b/app/services/thumbsgenerator.js
index 865d2cd3e..202b9ba75 100644
--- a/app/services/thumbsgenerator.js
+++ b/app/services/thumbsgenerator.js
@@ -30,6 +30,7 @@ import PlatformIO from '../services/platform-io';
import { Pro } from '../pro';
const maxSize = AppConfig.maxThumbSize;
+const bgColor = AppConfig.thumbBgColor;
const supportedImgs = ['jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'bmp'];
const supportedContainers = [
@@ -266,6 +267,8 @@ function generateImageThumbnail(fileURL) {
ctx.translate(x, y);
ctx.rotate(angleInRadians);
+ ctx.fillStyle = bgColor;
+ ctx.fillRect(-width / 2, -height / 2, width, height);
ctx.drawImage(img, -width / 2, -height / 2, width, height);
ctx.rotate(-angleInRadians);
ctx.translate(-x, -y);