Page 1 of 1

Resizing an image in circle shape

Posted: 2011-10-17T13:56:31-07:00
by byteminister
Hi!

I'm an IM noob, I went though all the docs and just can't find a way how to solve my problem. I have an image like this http://www.hey.si/slika.jpg, which will serve me as a background of another image http://www.hey.si/ura.jpg. I want the end image to look like this Image. What are the steps I should take to achieve this ? Before I only used IM for converting and resizing, but now I have this complicated problem. Please help, thank you !

Re: Resizing an image in circle shape

Posted: 2011-10-17T20:00:01-07:00
by fmw42
try the following

you have to resize the big image to the size of the small image, you have to create as grayscale mask from the small image and invert (-negate) the black and white, and flood fill the outside of the mask with white. Then you delete the big image and composite the others together.



dim=`convert ura.jpg -format "%wx%h" info:`
convert slika.jpg ura.jpg \
\( -clone 0 -resize $dim! \) \
\( -clone 1 -colorspace gray -negate -fuzz 10% -fill white -draw "color 0,0 floodfill" \) \
-delete 0 -swap 0,1 -compose over -composite result.jpg

Actually, the above still needs a little work as the numerals are not outlined. I will try to fix this later, though not sure exactly when. So anyone else is welcome to improve it.


see
http://www.imagemagick.org/script/escape.php
http://www.imagemagick.org/script/comma ... colorspace
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/draw/#color