Created
October 11, 2019 02:38
-
-
Save trigun0x2/26c79ceda423b945c3291ee7b71e1085 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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