ImageMagick

From HalfgeekKB
Revision as of 07:50, 2 January 2015 by Psmay (talk | contribs)
Jump to navigation Jump to search

ImageMagick is a common image processing program (convert) and library (e.g. PerlMagick, aka Image::Magick).

Snippets

Composite

composite -compose dst_over bg.png fg.png fg_on_bg.png
my $fg_on_bg = $fg->Clone; # or just $fg, if destructive
$fg_on_bg->Composite(compose => 'dst_over', image => $bg);

New image filled with color

export COLOR=white
export WIDTH=800
export HEIGHT=600
convert -size ${WIDTH}x${HEIGHT} xc:${COLOR} filled.png
my $color = 'white';
my $width = 800;
my $height = 600;
my $filled = new Image::Magick size => "${width}x${height}";
$filled->Read("xc:$color");