src/main.js
function computeFinalBuffer(image, thumbnail, exifData, orientation) {
  exifData['0th'][piexif.ImageIFD.Orientation] = 1
  if (typeof exifData['Exif'][piexif.ExifIFD.PixelXDimension] !== 'undefined') {
    exifData['Exif'][piexif.ExifIFD.PixelXDimension] = image.width
  }
  if (typeof exifData['Exif'][piexif.ExifIFD.PixelYDimension] !== 'undefined') {
    exifData['Exif'][piexif.ExifIFD.PixelYDimension] = image.height
  }
  if (thumbnail.buffer) {
    exifData['thumbnail'] = thumbnail.buffer.toString('binary')
  }
  const exifBytes = piexif.dump(exifData)
  const updatedBuffer = Buffer.from(piexif.insert(exifBytes, image.buffer.toString('binary')), 'binary')
  const updatedDimensions = {
    height: image.height,
    width: image.width,
  }
  return Promise.resolve({updatedBuffer, orientation, updatedDimensions})
}
function computeFinalBuffer(image, thumbnail, exifData, orientation) {
  exifData['0th'][piexif.ImageIFD.Orientation] = 1
  if (typeof exifData['Exif'][piexif.ExifIFD.PixelXDimension] !== 'undefined') {
    exifData['Exif'][piexif.ExifIFD.PixelXDimension] = image.width
  }
  if (typeof exifData['Exif'][piexif.ExifIFD.PixelYDimension] !== 'undefined') {
    exifData['Exif'][piexif.ExifIFD.PixelYDimension] = image.height
  }
  if (thumbnail.buffer) {
    exifData['thumbnail'] = thumbnail.buffer.toString('binary')
  }
  const exifBytes = piexif.dump(exifData)
  const updatedBuffer = Buffer.from(piexif.insert(exifBytes, image.buffer.toString('binary')), 'binary')
  const updatedDimensions = {
    height: image.height,
    width: image.width,
  }
  return Promise.resolve({updatedBuffer, orientation, updatedDimensions})
}
function computeFinalBuffer ( image , thumbnail , exifData , orientation ) { exifData [ '0th' ] [ piexif . ImageIFD . Orientation ] = 1 if ( typeof exifData [ 'Exif' ] [ piexif . ExifIFD . PixelXDimension ] !== 'undefined' ) { exifData [ 'Exif' ] [ piexif . ExifIFD . PixelXDimension ] = image . width } if ( typeof exifData [ 'Exif' ] [ piexif . ExifIFD . PixelYDimension ] !== 'undefined' ) { exifData [ 'Exif' ] [ piexif . ExifIFD . PixelYDimension ] = image . height } if ( thumbnail . buffer ) { exifData [ 'thumbnail' ] = thumbnail . buffer . toString ( 'binary' ) } const exifBytes = piexif . dump ( exifData ) const updatedBuffer = Buffer . from ( piexif . insert ( exifBytes , image . buffer . toString ( 'binary' ) ) , 'binary' ) const updatedDimensions = { height : image . height , width : image . width , } return Promise . resolve ( { updatedBuffer , orientation , updatedDimensions } ) }
Compute the final buffer by updating the original EXIF data and linking it to the rotated buffer
Compute the final buffer by updating the original EXIF data and linking it to the rotated buffer