simple rescale:
convert rose: -resize 50% rose.png
rescale with proper value interpolation (convert sRGB to RGB):
convert rose: -colorspace RGB -resize 50% -colorspace sRGB rose.png
convert rose: -gravity center -crop 10x10+0+0 output_file.png
-gravity center
prevent to make tiles.
To specify the amount to be removed, use -shave instead:
convert rose: -shave 10% rose.png
Remove 10% pixels from the image edges.
Remove pixels from the interior of an image.
convert rose: -chop 20x0+10+0 rose.png
remove a vertical band of 20 pixels wide at 10 pixels from the left border.
see full documentation : imagemagick
|
|
|
montage -label '%f' *.jpg -geometry 300x200+0+0 -background grey mosaic.jpg |
-
-background chartreuse
set background to Chartreuse color (the only liqueur so good they named a color after it.) -
-set label
associate a label to an image. Must appear before input files. -
-geometry +0+0
has the extra effect of putting montage in a 'concatenation' mode (no rescale).
used by crop
, extend
, ….
Format | Comment |
---|---|
|
Height and width both scaled by specified percentage. |
|
Height and width individually scaled by specified percentages. (Only one % symbol needed.) |
|
Width given, height automagically selected to preserve aspect ratio. |
|
Height given, width automagically selected to preserve aspect ratio. |
|
Maximum values of height and width given, aspect ratio preserved. |
|
Minimum values of width and height given, aspect ratio preserved. |
|
Width and height emphatically given, original aspect ratio ignored. |
|
Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s). |
|
Enlarges an image with dimension(s) smaller than the corresponding width and/or height argument(s). > |
|
Resize image to have specified area in pixels. Aspect ratio is preserved. |
|
Specifying the offset (default is +0+0). Below, {size} refers to any of the forms above. |
|
Horizontal and vertical offsets x and y, specified in pixels. Signs are required for both. Offsets are affected by ‑gravity setting. Offsets are not affected by % or other size operators. |
extract alpha
convert image.png -alpha extract alpha.png
extract RGB
convert image.png -flatten rgb.png
extract RGB with default RGB value
convert image.png -background black -alpha remove rgb.png
merge RGB and alpha
convert rgb.png alpha.png -alpha off -compose CopyOpacity -composite result.png
convert gamma_dalai_lama_gray.jpg -set colorspace sRGB -depth 16 -colorspace RGB -resize 50% -colorspace sRGB -depth 8 gamma_dalai_lama_gray.50pc.png
with steps:
-
set colorspace sRGB
: Set metadata only, do not touch pixels. -
depth 16
: Increase image precision. -
colorspace RGB
: Transform pixels from existing colourspace (sRGB) to new colourspace (RGB), and update metadata to be RGB. -
resize 50%
: Now that pixels are in a linear space, resize should be safe. -
colorspace sRGB
: Transform pixels from existing colourspace (RGB) to new colourspace (sRGB), and update colourspace metadata to be sRGB -
depth 8
: Go back to original precision.
convert -delay 10 frame1 frame2 out.gif
Patrol cycle (back and forth) just add -----coalesce -duplicate 1,-2-1----
convert -delay 10 frame frame2 -coalesce -duplicate 1,-2-1 -loop 0 out.gif
-
Allow magick to convert from/to PDF:
# Open the file
sudo nano /etc/ImageMagick-6/policy.xml
# find and edit the line
<policy domain="coder" rights="none" pattern="PDF" />
# to :
<policy domain="coder" rights="read|write" pattern="PDF" />
-
convert full resolution
convert -density 250 doc.pdf -quality 100 -flatten doc.png # single page
convert -density 250 doc.pdf -quality 100 page%02d.png # multi pages