src/transform.js
function flipPixels(buffer, width, height) {
  const newBuffer = Buffer.alloc(buffer.length)
  for (let x = 0; x < width; x += 1) {
    for (let y = 0; y < height; y += 1) {
      const offset = (width * y + x) << 2
      const newOffset = (width * y + width - 1 - x) << 2
      const pixel = buffer.readUInt32BE(offset, true)
      newBuffer.writeUInt32BE(pixel, newOffset, true)
    }
  }
  return newBuffer
}
function flipPixels(buffer, width, height) {
  const newBuffer = Buffer.alloc(buffer.length)
  for (let x = 0; x < width; x += 1) {
    for (let y = 0; y < height; y += 1) {
      const offset = (width * y + x) << 2
      const newOffset = (width * y + width - 1 - x) << 2
      const pixel = buffer.readUInt32BE(offset, true)
      newBuffer.writeUInt32BE(pixel, newOffset, true)
    }
  }
  return newBuffer
}
function flipPixels ( buffer , width , height ) { const newBuffer = Buffer . alloc ( buffer . length ) for ( let x = 0 ; x < width ; x += 1 ) { for ( let y = 0 ; y < height ; y += 1 ) { const offset = ( width * y + x ) << 2 const newOffset = ( width * y + width - 1 - x ) << 2 const pixel = buffer . readUInt32BE ( offset , true ) newBuffer . writeUInt32BE ( pixel , newOffset , true ) } } return newBuffer }
Flip a buffer horizontally
Flip a buffer horizontally