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:
parent
2c7d736bd3
commit
0c058f256a
6 changed files with 67 additions and 12 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue