Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create PNG/JPG file with commandline on Mac

is there a command to create a simple PNG/JPG picture file, can be run in terminal/script command on Mac?

For now, I'm going to create a simple one color PNG picture file, with parameter to specify wide and length. if it can put text on it, is much better.

like image 899
user1683774 Avatar asked Sep 19 '12 17:09

user1683774


1 Answers

The command-line convert utility in the ImageMagick suite can easily create an image of specified dimensions:

convert -size 200x200 xc:white canvas.png

To create an image with text, use additional options:

convert -size 200x200 -gravity center -background white -fill black \
        label:"text goes here" canvas.png

The ImageMagick site has many more examples of usage.

To get ImageMagick on OSX, you can either use an automated build system such as MacPorts or run a pre-made installer package.

like image 100
user4815162342 Avatar answered Sep 23 '22 04:09

user4815162342