From 0c058f256a195b92f124be10109c95d1fbe93ad8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 7 Mar 2022 17:16:54 +0100 Subject: Remove exif tags when processing images --- server/helpers/image-utils.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'server/helpers/image-utils.ts') diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts index b174ae436..28d8fff4c 100644 --- a/server/helpers/image-utils.ts +++ b/server/helpers/image-utils.ts @@ -80,6 +80,8 @@ async function autoResize (options: { const sourceIsPortrait = sourceImage.getWidth() < sourceImage.getHeight() const destIsPortraitOrSquare = newSize.width <= newSize.height + removeExif(sourceImage) + if (sourceIsPortrait && !destIsPortraitOrSquare) { const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height) .color([ { apply: 'shade', params: [ 50 ] } ]) @@ -106,6 +108,7 @@ function skipProcessing (options: { const { sourceImage, newSize, imageBytes, inputExt, outputExt } = options const { width, height } = newSize + if (hasExif(sourceImage)) return false if (sourceImage.getWidth() > width || sourceImage.getHeight() > height) return false if (inputExt !== outputExt) return false @@ -116,3 +119,11 @@ function skipProcessing (options: { return imageBytes <= 15 * kB } + +function hasExif (image: Jimp) { + return !!(image.bitmap as any).exifBuffer +} + +function removeExif (image: Jimp) { + (image.bitmap as any).exifBuffer = null +} -- cgit v1.2.3