ImageMagick / Caption / Two files
I'm trying to use the caption command from ImageMagick as I need the word wrap.
Here is what I'm trying now:
var
gm = require('gm'),
im = gm.subClass({ imageMagick: true });
im(200, 400, "#666666")
.font("OpenSans-Light.ttf", 12)
.stroke("#ffffff")
.drawCircle(10, 10, 20, 10)
.drawText(50,50,'drawn text')
.out("caption: \"ImageMagick Text\"")
.write("./brandNewImg.png", function (err) {
console.log('error',err);
console.log('done');
});
The script is producing two files brandNewImg-0.png and brandNewImg-1.png. The 0 file has all the comands up to the drawText and the 1 file contains only the ImageMagick Text output (none of the other graphic elements and oddly on a white background). What's going on here?
Oh boy. Half a day lost on this.
im(200, 400)
.background("#666666")
.font("OpenSans-Light.ttf", 12)
.stroke("#ffffff")
.drawCircle(10, 10, 20, 10)
.drawText(50,50,'drawn text')
.out("caption: \"ImageMagick Text\"")
.write("./brandNewImg.png", function (err) {
console.log('error',err);
console.log('done');
});
It appears that indicating the background color when initially calling was throwing a spanner in the works - I saw that placing the background color in the initial call was putting xc:#666666 on the command line which IM didn't like. Still a very unexpected problem/bug.
Just wanted to add that I ran into the exact same problem where 2 image files were created instead of just 1. Also, it seems like the .out() function is undocumented.
I ran into the same problem and what worked for me was adding .out('-composite') right after .out('-caption: "text to be wrapped"'). From what I understood the composite commande merges the 2 images.