Imagemagick: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Howto) |
||
Line 1: | Line 1: | ||
== Reference == |
|||
* [http://www.imagemagick.org/script/command-line-options.php Imagemagick command-line options] |
|||
== Howto == |
== Howto == |
||
=== Image resize === |
=== Image resize === |
||
<source lang=bash> |
|||
convert front.jpg -resize 500x500 folder.jpg |
|||
convert front.jpg -filter cubic -resize 500x500 folder.jpg # Set resize filter. 'convert -list-filter' to get a list |
|||
convert front.jpg -filter cubic -resize 500x500^ folder.jpg # Convert to a size of min 500x500, preserving aspect ratio. |
|||
</source> |
|||
=== Get image info === |
=== Get image info === |
||
<source lang=bash> |
<source lang=bash> |
||
convert -format "%f %w %h" sand.jpg info: |
convert -format "%f %w %h" sand.jpg info: |
||
identify -format "%f %w %h" sand.jpg # Same but shorter |
identify -format "%f %w %h" sand.jpg # Same but shorter |
||
identify sand.jpg -format "%f %w %h" # WRONG - format string must come before because params are processed sequentially |
identify sand.jpg -format "%f %w %h" # WRONG - format string must come before because params are processed sequentially |
||
read -r file width height <<< $(identify -format "%f %w %h" sand.jpg) # Set values in variables |
read -r file width height <<< $(identify -format "%f %w %h" sand.jpg) # Set values in variables |
||
</source> |
|||
=== Crop an image === |
|||
<source lang=bash> |
|||
convert IMG_0001.jpg -gravity Center -crop 1000x1000+0+0 +repage IMG_0001-resized.jpg # Crop a 1000x1000 region around center. The '+0+0' are mandatory. |
|||
</source> |
|||
=== Convert to JPG === |
|||
<source lang=bash> |
|||
convert IMG_0001.png IMG_0001.jpg # Convert with default quality |
|||
convert IMG_0001.png -quality 96 IMG_0001.jpg # Specify JPG quality |
|||
</source> |
|||
=== Blur an image === |
|||
<source lang=bash> |
|||
convert IMG_0001.jpg -gaussian-blur 5x2 IMG_0001-blur.jpg # Similar to Gimp gaussian blur 5x5 px |
|||
convert IMG_0001.jpg -gaussian-blur 5x2 -filter cubic -resize 1000x1000^ -gravity Center -crop 1000x1000+0+0 +repage -quality 96 IMG_0001-resized.jpg |
|||
</source> |
</source> |
Revision as of 16:30, 16 December 2015
Reference
Howto
Image resize
convert front.jpg -resize 500x500 folder.jpg
convert front.jpg -filter cubic -resize 500x500 folder.jpg # Set resize filter. 'convert -list-filter' to get a list
convert front.jpg -filter cubic -resize 500x500^ folder.jpg # Convert to a size of min 500x500, preserving aspect ratio.
Get image info
convert -format "%f %w %h" sand.jpg info:
identify -format "%f %w %h" sand.jpg # Same but shorter
identify sand.jpg -format "%f %w %h" # WRONG - format string must come before because params are processed sequentially
read -r file width height <<< $(identify -format "%f %w %h" sand.jpg) # Set values in variables
Crop an image
convert IMG_0001.jpg -gravity Center -crop 1000x1000+0+0 +repage IMG_0001-resized.jpg # Crop a 1000x1000 region around center. The '+0+0' are mandatory.
Convert to JPG
convert IMG_0001.png IMG_0001.jpg # Convert with default quality
convert IMG_0001.png -quality 96 IMG_0001.jpg # Specify JPG quality
Blur an image
convert IMG_0001.jpg -gaussian-blur 5x2 IMG_0001-blur.jpg # Similar to Gimp gaussian blur 5x5 px
convert IMG_0001.jpg -gaussian-blur 5x2 -filter cubic -resize 1000x1000^ -gravity Center -crop 1000x1000+0+0 +repage -quality 96 IMG_0001-resized.jpg