Open pociej opened 10 years ago
ooh I want to know if this is possible too! limit all those expensive io operations to a minimum :+1:
I'd love to know if this was possible as well.
I haven't figured out how to do it with both an image
and the watermark
as buffers, but I have figured out how to keep the image as a buffer:
gm(imageBuffer)
.composite('./logo_path.png')
.geometry(geometry)
.gravity('SouthEast')
.dissolve(this.options.opacity)
.toBuffer(function (err, buffer) {
next(err, buffer, 'image/jpeg');
});
};
Check out the code in this great library for more info.
PLEASE !!! I want it too. It's gonna be very useful when work with complex or multiple composite like Displacement technique.
The reason is I use serverless (Lambda) which is cannot write file into directory (can but not a long term solution) and I have to stream buffer output to S3 first then return as URL for use with composite function and Displacement technique need at lease 5 compose for the end-result.
So it's work but it consume many resource especially run time of the service.
hi im tring to watermark image using gm .
var imageGM = gm.subClass({ imageMagick: true }); imageGM() .subCommand('composite') . in ('-compose', 'Over', ./path_to_Watermark, './path_to_jpg) .write('./path_to_result', function(err){ console.log('done', err); });
using paths everything working ok. but : var imageGM = gm.subClass({ imageMagick: true }); var watermark = fs.readFileSync('/path_to_watermark); imageGM() .subCommand('composite') . in ('-compose', 'Over', watermark, './path_to_jpg) .write('./path_to_result', function(err){ console.log('done', err); });
i have :
done { [Error: Command failed: composite: unable to open image
�PNG I20140801-16:08:15.026(2)? I20140801-16:08:15.027(2)? ': @ error/blob.c/OpenBlob/2587. I20140801-16:08:15.030(2)? composite: no decode delegate for this image format
�PNG I20140801-16:08:15.030(2)? I20140801-16:08:15.030(2)? ' @ error/constitute.c/ReadImage/532. I20140801-16:08:15.030(2)? composite: missing an image filename `./path_to_watermark' @ error/composite.c/CompositeImageCommand/1616.any ideas how to solve it? same issue when im trying to pass buffer for image which i want watermark. Also question, is it possible to write to buffer not to the path ?
regards and thanks for response. G.P.