Skip to content

Instantly share code, notes, and snippets.

@trigun0x2
Created October 11, 2019 02:38
Show Gist options
  • Save trigun0x2/26c79ceda423b945c3291ee7b71e1085 to your computer and use it in GitHub Desktop.
Save trigun0x2/26c79ceda423b945c3291ee7b71e1085 to your computer and use it in GitHub Desktop.
const gm = require('gm')
gm()
.append('a.png', true)
.append('b.png', true)
// .in('-page', '+0+0')
// .in('a.png')
// .in('-page', '+256+0')
// .in('b.png')
// .mosaic()
.write('out.png', (err) => {
if (err) console.log(err)
gm('out.png')
.size((err, size) => {
// target: 360x180
if (!err) {
if (size.width > size.height) {
gm('out.png')
.scale(null, 180)
.gravity('Center')
.crop(360, 180)
.write('out.png', (err) => {
if (err) console.log(err)
})
} else {
gm('out.png')
.scale(360, null)
.gravity('Center')
.crop(360, 180)
.write('out.png', (err) => {
if (err) console.log(err)
})
}
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment