diff options
author | Chocobozzz <me@florianbigard.com> | 2022-03-08 11:28:32 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-03-08 11:28:32 +0100 |
commit | 7b51ede977c299a74728171d8c124bcc4cbba6ea (patch) | |
tree | ad189d2ed1f987e2053201166af4e953c46529f5 /server/helpers/image-utils.ts | |
parent | ab4b8974997777373a6032073f9c1aaf33ba9931 (diff) | |
parent | 70f3012acd239be4567d9d9fa0364be75485ad1c (diff) | |
download | PeerTube-7b51ede977c299a74728171d8c124bcc4cbba6ea.tar.gz PeerTube-7b51ede977c299a74728171d8c124bcc4cbba6ea.tar.zst PeerTube-7b51ede977c299a74728171d8c124bcc4cbba6ea.zip |
Merge branch 'release/4.1.0' into develop
Diffstat (limited to 'server/helpers/image-utils.ts')
-rw-r--r-- | server/helpers/image-utils.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts index 9d0c09051..7d6451db9 100644 --- a/server/helpers/image-utils.ts +++ b/server/helpers/image-utils.ts | |||
@@ -118,6 +118,8 @@ async function autoResize (options: { | |||
118 | const sourceIsPortrait = sourceImage.getWidth() < sourceImage.getHeight() | 118 | const sourceIsPortrait = sourceImage.getWidth() < sourceImage.getHeight() |
119 | const destIsPortraitOrSquare = newSize.width <= newSize.height | 119 | const destIsPortraitOrSquare = newSize.width <= newSize.height |
120 | 120 | ||
121 | removeExif(sourceImage) | ||
122 | |||
121 | if (sourceIsPortrait && !destIsPortraitOrSquare) { | 123 | if (sourceIsPortrait && !destIsPortraitOrSquare) { |
122 | const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height) | 124 | const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height) |
123 | .color([ { apply: 'shade', params: [ 50 ] } ]) | 125 | .color([ { apply: 'shade', params: [ 50 ] } ]) |
@@ -144,6 +146,7 @@ function skipProcessing (options: { | |||
144 | const { sourceImage, newSize, imageBytes, inputExt, outputExt } = options | 146 | const { sourceImage, newSize, imageBytes, inputExt, outputExt } = options |
145 | const { width, height } = newSize | 147 | const { width, height } = newSize |
146 | 148 | ||
149 | if (hasExif(sourceImage)) return false | ||
147 | if (sourceImage.getWidth() > width || sourceImage.getHeight() > height) return false | 150 | if (sourceImage.getWidth() > width || sourceImage.getHeight() > height) return false |
148 | if (inputExt !== outputExt) return false | 151 | if (inputExt !== outputExt) return false |
149 | 152 | ||
@@ -154,3 +157,11 @@ function skipProcessing (options: { | |||
154 | 157 | ||
155 | return imageBytes <= 15 * kB | 158 | return imageBytes <= 15 * kB |
156 | } | 159 | } |
160 | |||
161 | function hasExif (image: Jimp) { | ||
162 | return !!(image.bitmap as any).exifBuffer | ||
163 | } | ||
164 | |||
165 | function removeExif (image: Jimp) { | ||
166 | (image.bitmap as any).exifBuffer = null | ||
167 | } | ||