aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-07 17:16:54 +0100
committerChocobozzz <me@florianbigard.com>2022-03-07 17:23:12 +0100
commit0c058f256a195b92f124be10109c95d1fbe93ad8 (patch)
tree259ec36671b5b5b46e9bd7f4f5eb308ea65e93ff /server/helpers
parent2c7d736bd3089503117edb101d5a7d0f8fa3ee7e (diff)
downloadPeerTube-0c058f256a195b92f124be10109c95d1fbe93ad8.tar.gz
PeerTube-0c058f256a195b92f124be10109c95d1fbe93ad8.tar.zst
PeerTube-0c058f256a195b92f124be10109c95d1fbe93ad8.zip
Remove exif tags when processing images
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/image-utils.ts11
1 files changed, 11 insertions, 0 deletions
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: {
80 const sourceIsPortrait = sourceImage.getWidth() < sourceImage.getHeight() 80 const sourceIsPortrait = sourceImage.getWidth() < sourceImage.getHeight()
81 const destIsPortraitOrSquare = newSize.width <= newSize.height 81 const destIsPortraitOrSquare = newSize.width <= newSize.height
82 82
83 removeExif(sourceImage)
84
83 if (sourceIsPortrait && !destIsPortraitOrSquare) { 85 if (sourceIsPortrait && !destIsPortraitOrSquare) {
84 const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height) 86 const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height)
85 .color([ { apply: 'shade', params: [ 50 ] } ]) 87 .color([ { apply: 'shade', params: [ 50 ] } ])
@@ -106,6 +108,7 @@ function skipProcessing (options: {
106 const { sourceImage, newSize, imageBytes, inputExt, outputExt } = options 108 const { sourceImage, newSize, imageBytes, inputExt, outputExt } = options
107 const { width, height } = newSize 109 const { width, height } = newSize
108 110
111 if (hasExif(sourceImage)) return false
109 if (sourceImage.getWidth() > width || sourceImage.getHeight() > height) return false 112 if (sourceImage.getWidth() > width || sourceImage.getHeight() > height) return false
110 if (inputExt !== outputExt) return false 113 if (inputExt !== outputExt) return false
111 114
@@ -116,3 +119,11 @@ function skipProcessing (options: {
116 119
117 return imageBytes <= 15 * kB 120 return imageBytes <= 15 * kB
118} 121}
122
123function hasExif (image: Jimp) {
124 return !!(image.bitmap as any).exifBuffer
125}
126
127function removeExif (image: Jimp) {
128 (image.bitmap as any).exifBuffer = null
129}