2013-10-14 02:36:58 +00:00
|
|
|
---
|
|
|
|
title: Imagemagick
|
2020-07-03 12:47:47 +00:00
|
|
|
intro: |
|
|
|
|
A quick reference for common [Imagemagick](https://www.imagemagick.org) commands and switches.
|
2013-10-14 02:36:58 +00:00
|
|
|
---
|
2013-01-24 21:04:38 +00:00
|
|
|
|
2020-07-03 12:47:47 +00:00
|
|
|
### Common options
|
2014-02-25 10:32:14 +00:00
|
|
|
|
2020-07-03 12:47:47 +00:00
|
|
|
| Option | Description |
|
|
|
|
| ------------------- | ------------------------------- |
|
|
|
|
| `-resize 100x40` | Resize to a dimension |
|
|
|
|
| `-crop 40x30+10+10` | (width)x(height)+(x)+y |
|
|
|
|
| `-crop 40x30-10-10` | (width)x(height)+(x)+y |
|
|
|
|
| `-flip` | Vertical |
|
|
|
|
| `-flop` | Horizontal |
|
|
|
|
| `-transpose` | Flip vertical + rotate 90deg |
|
|
|
|
| `-transverse` | Flip horizontal + rotate 270deg |
|
|
|
|
| `-trim` | Trim image edges |
|
|
|
|
| `-rotate 90` | Rotate 90 degrees |
|
2014-02-25 10:32:14 +00:00
|
|
|
|
2013-01-24 21:04:38 +00:00
|
|
|
### Resize to fit
|
|
|
|
|
2020-07-03 12:47:47 +00:00
|
|
|
```sh
|
|
|
|
convert input.jpg -resize 80x80^ -gravity center -extent 80x80 icon.png
|
|
|
|
```
|
2013-01-24 21:04:38 +00:00
|
|
|
|
|
|
|
### Convert all images to another format
|
|
|
|
|
2020-07-03 12:47:47 +00:00
|
|
|
```sh
|
|
|
|
mogrify -format jpg -quality 85 *.png
|
|
|
|
```
|
2013-01-24 21:04:38 +00:00
|
|
|
|
|
|
|
### Make a pdf
|
|
|
|
|
2020-07-03 12:47:47 +00:00
|
|
|
```sh
|
|
|
|
convert *.jpg hello.pdf
|
|
|
|
```
|
2013-01-24 21:04:38 +00:00
|
|
|
|
|
|
|
### References
|
|
|
|
|
2020-07-03 12:47:47 +00:00
|
|
|
- <http://www.noah.org/wiki/ImageMagick>
|
|
|
|
- <https://www.imagemagick.org/>
|