Search code examples
imagemagickresize

Composing multi function imagemagick command for resize, adding background, changing greyscale, apply image-kernel, get pixel value mean


I want to resize, add a background, change to grayscale, apply an image-kernel for finding edges, and lastly get the mean value of pixels in the image.

What's wrong with my command?:

"imagic\magick.exe" "aaaa.png" -resize 800x800> ^ 
-background "#FFFFFF" -flatten -colorspace Gray ^
-morphologyConvolve "3x3: -1,-1,-1 -1,8,-1 -1,-1,-1" -format "%[fx:mean]" info:""

Solution

  • size of resize and ">" needs to be in double quotes.

    "imagic\magick.exe" "aaaa.png" -resize "800x800>" ^
    -background "#FFFFFF" -flatten -colorspace Gray ^
    -morphologyConvolve "3x3: -1,-1,-1 -1,8,-1 -1,-1,-1" -format "%[fx:mean]" info:""