Search

11/15/2008

uesrful imagemagick command

// convert images to png8
convert foo.png png8:foo.png


# Use a simple shell loop, to process each of the images.
mkdir thumbnails
for $f in *.jpg
do convert $f -thumbnail 200x90 thumbnails/$f.gif
done

# Use find to substitute filenames into a 'convert' command
# This also provides the ability to recurse though directories by removing
# the -prune option, as well as doing other file checks (like image type,
# or the disk space used by an image).
find * -prune -name '*.jpg' \
-exec convert '{}' -thumbnail 200x90 thumbnails/'{}'.gif \;

# Use xargs -- with a shell wrapper to put the argument into a variable
# This can be combined with either "find" or "ls" to list filenames.
ls *.jpg | xargs -n1 sh -c 'convert $0 -thumbnail 200x90 thumbnails/$0.gif'

# An alternative method on linux (rather than plain unix)
# This does not need a shell to handle the argument.
ls *.jpg | xargs -I FILE convert FILE -thumbnail 200x90 th_FILE.gif

ImageMagick: One-Second Gradient Images
generate a image named temp.png with gradient from #000 to #fff
convert -size 300x200 gradient:'#000'-'#fff' temp.png
在window下必須改寫為雙引號
convert -size 300x200 gradient:"#000"-"#fff" temp.png
Canvas Creation -- IM v6 Examples
For example you can use a Sigmoidal Contrast function to create a more natural looking gradient.
convert -size 100x100 gradient: -sigmoidal-contrast 6,50% gradient_sigmoidal.jpg
Fundamentals of Image Processing
draw a 100x100 transparent canvas, then draw a red line from 10,10 to 90,90
convert -size 100x100 xc:none -fill red -draw "line 10,10 90,90" output.png
the fill color draws the line, not the stroke color. Note that setting the stroke width doesn't affect the images; however, the linewidth setting will change the width of the line
The arguments to the circle shape are slightly different from the rectangle shape. The first
argument is the center of the circle, and the second argument is how far the circle extends.
create a transparent canvas and a circle
-draw 'circle 50,50 50,80' 圓心在50,50 半徑從50到80
convert -size 200x200 xc:none -fill gray20 -draw "circle 100,100 30,30" output.png
create a transparent canvas and a rect with blue background and 20px red border
convert -size 100x100 xc:none -fill blue -stroke red -strokewidth 20 -draw "rectagnel 10,10 90,90" rect.png

沒有留言: