Domanda

I'm asked to create a 450px by 225px image from a given image(can be any size) with following requirements.

If the image is 450x225, no porblem just save it. If the image is bigger just give the user the ability to crop the image. I'm able to do both of the above but where I'm stuck is when image is smaller than 450x225. When smaller, I want to create an 450x225 image and paste the given image on the center of 450x225.

I'm working with node.js and using the GraphicsMagicks library for node.js.

Any help is greatly appreciated!

È stato utile?

Soluzione

gm convert inputfile -gravity center -extent 450x225 outputfile

If you want to integrate easily with node.js, you can use stdin/stdout as files:

gm convert - -gravity center -extent 450x225 -

Then, you can pipe you image data to and from the gm process.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top