Last active
December 24, 2015 14:09
-
-
Save mildfuzz/6810422 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| exports.trimSouthEast = function(files){ | |
| /* | |
| * Trims the bottom and right edges | |
| */ | |
| files.forEach(function(file, i){ | |
| var origFile = __dirname + file; | |
| var tempFile1 = os.tmpDir() + 'image1_' +i+'.png'; | |
| var tempFile2 = os.tmpDir() + 'image2_' +i+'.png'; | |
| exec("convert "+file+" -gravity North -background white -splice 0x1 -background black -splice 0x1 -trim +repage -chop 0x1 "+tempFile1,function(){ | |
| exec("convert "+tempFile1+" -gravity West -background white -splice 1x0 -background black -splice 1x0 -trim +repage -chop 1x0 "+tempFile2,function(){ | |
| fs.readFile(tempFile2, function(newFile){ | |
| fs.writeFile(origFile, newFile); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment