Let me describe my problem:
I have a site where I post sponsors company logos. Once I'm sent the logo (or I've googled) they are usually in rectangle size - width and height are not equal.
On my site, once you upload the logo image, you then crop it to a square.
For logos that are rectangular, I usually open them up in GIMP, increase the canvas size to a square, create a new layer of the background color and finally export it as jpg or png for the site. Quite time consuming.
I'm looking for a way to do that hopefully with just a terminal command.
EXAMPLE:
Consider this Safaricom (Kenyan Telecommunication company) logo below. It's of 650px by 380px - how can I make it 650px by 650px and then center it horizontally from the command line?
You can use the following command which requires
imagemagick
(sudo apt-get install imagemagick
):convert
command trims your picture to remove bordersidentify
to find the max dimension (width or height)convert
command use-gravity
to center the logo in a square canvas.You can even paste this command into a bash function in your
$HOME/.bashrc
: