ImageMagick is an amazing CLI image manipulation utility I have been using for 20 years. Here are some of the common PNG/JPG/etc commands I use.
Add solid background to the image
While keeping the original contents in the center. You need to know the output width / height. For example to make the output image width 600 pixels with white border on both sides use the command
1 | convert input.png -background white -gravity center -extent 600 output.png |
Combine several images into one row
Use +append
to create a single row. Use -append
to create a column.
1 | convert image1.png image2.png image3.png ... +append output.png |
Compute average image color
See Give browser a chance blog post.
Generate an image with solid color
1 | # hex format |
Extend the image
Let's add transparent margins to an image and resize it while preserving the aspect ratio
1 | convert in.png \ |