Question

I'm trying to create the round profile pictures via imagemagick. I have the following code:

convert source.png  \
\( -gravity Center -resize 101x101^ -extent 101x101 \) \
\( +clone -threshold -1 -negate -fill white -draw "circle 50,50 50,0.0" \) \
-alpha off -compose copy_opacity -composite dest.png 

but it ignores the first line where the picture is cropped and resized to 101x101 it only creates the circle in the centre of the original image.

convert source.png  \
\( -gravity Center -resize 101x101^ -extent 101x101 \) dest_100.png

convert source.png  \
\( +clone -threshold -1 -negate -fill white -draw "circle 50,50 50,0.0" \) \
-alpha off -compose copy_opacity -composite dest.png

both of these parts work nicely I just would like to chain it into one command.

Was it helpful?

Solution

The first resize line get's lost by the sub-process \(...\). Just remove the surrounding parenthesis in the first line, or move the source image into the same parenthesis.

convert source.png  \
        -gravity Center -resize 101x101^ -extent 101x101 \
        \( +clone -threshold -1 -negate -fill white -draw "circle 50,50 50,0.0" \) \
        -alpha off -compose copy_opacity -composite dest.png 

or

convert \( source.png  -gravity Center -resize 101x101^ -extent 101x101 \) \
        \( +clone -threshold -1 -negate -fill white -draw "circle 50,50 50,0.0" \) \
        -alpha off -compose copy_opacity -composite dest.png 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top