How to create a sketch that fills a specific area in a meteor using CollectionFS and graphicsmagick

Right now I'm using the code here: https://github.com/CollectionFS/Meteor-CollectionFS#basic-example Suppose I want a thumbnail of 100x100.

But say that my image is 400x200, the code above will give a thumbnail of 100x50.

In this example, I want the image to be resized to 200x100 and then cropped to 100x100. How should I do it? How to get height and width? I know that I can use the gm size function, but I cannot wrap all callbacks.

+4
source share
1 answer

Try:

gm(readStream, fileObj.name()).autoOrient().resize('100', '100', "^").gravity('Center').extent('100', '100').stream().pipe(writeStream);

autoOrient() ( ). ^, resize, , " " 100. , "" "" . , . extant , . gravity('Center') extant .

, , - , . , gravity('Center') , . . , , .

EDIT: gravity 'Center', 'Center'. . autoOrient().

gm doc . gm node.js , .

+6

Source: https://habr.com/ru/post/1548070/


All Articles