Home
PHP
Tech Tube
MySQL
Linux
CSS&HTML
JavaScript

Image Magick tricks

List of useful Image Magick commands. A PHP extension of Imagick: https://phpimagick.com/Imagick Some cool scripts: http://www.fmwconcepts.com/imagemagick/index.php Add transparent border:
convert in.png -bordercolor none -border 150 out.png
Add border with hex color:
convert in.png -bordercolor "#3490dc" -border 150 out.png
Resize
convert in.png -resize 1024x1024 out.png
Replace transparent background
convert in.png -background "#3490dc" -alpha remove -alpha off out.png
Convert SVG to PNG and adding a background
convert -background "#3490dc" -size 1024x1024 -fill white -opaque black in.svg out.png
Replace color with transparency:
convert in.png -fuzz 10% -transparent "#969696" out.png
Replace color:
convert in.png -fuzz 10% -fill "#3490DC" -opaque "#969696" out.png
Cut 100px from the bottom:
convert in.png -gravity South -chop 0x100 out.png
Cut 100px from the top:
convert in.png -gravity North -chop 0x100 out.png
rotate with background or transparency:
convert in.png -background "#000000" -rotate 20 out.png
convert in.png -background transparent -rotate 20 out.png