1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Remove exif tags when processing images

This commit is contained in:
Chocobozzz 2022-03-07 17:16:54 +01:00
parent 2c7d736bd3
commit 0c058f256a
No known key found for this signature in database
GPG key ID: 583A612D890159BE
6 changed files with 67 additions and 12 deletions

View file

@ -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
}