I'm learning ImageMagick. I want to create (with ImageMagick) a series of images that after using the command
convert -delay 0 -loop 0 frame*.gif final.gif
gives the result like the attached animated gif.
I want to program the series of commands myself, but I need a hint for which effects and drawing instructions will give me the most similar result, so I'm looking for something like:
but, probably the above is not enough.
Is this question very vague or can somebody give me a hint?
If you are in a shell environment (OSX or Linux) you could do something like this, which creates a series of blurred circles in ever-increasing radii and saves the image in appropriately named files...
for RAD in {10,20,30,40,50,60,70,80,90}; do convert -size 400x300 xc:black -fill cyan -stroke cyan -draw "translate 200,150 circle 0,0 $RAD,0" -blur 0x8 blur_circle$RAD.gif; done
To get fancier, you could add repeated blur operations, or more blur for the larger radii.
Then, as you suggest convert those to an animated gif:
convert -delay 0 -loop 0 blur_circle*.gif final.gif
EDIT
Here is a version that uses python to generate two circles, whose transparency varies on different time scales. With the current settings, transparency over time looks like this graph, but you can generate any lists of integer values to get different effects:
Here is the image produced by the program:
And here is the program itself:
#! /usr/bin/env python
""" Using imagemagick, generate a series of .gifs with fuzzy circles in them...
When the program is done, create an animated gif with:
convert -delay 0 -loop 0 blur_circle*.gif final.gif
(P.S. I know it is not 'convention' to capitalize variable names, but it makes
it easier to distinguish my definitions from built-ins)"""
import subprocess
import sys
CanvasW = 400
CanvasH = 400
CenterX = int(CanvasW/2)
CenterY = int(CanvasH/2)
InnerDia = 75
OuterDia = 155
BaseNameString = "blur_circles"
# play with overall blur level - 2 to 8
# this is in addition to the distance fuzzing
BlurLevel = '8'
# The following three lists must be the same length
# Transparency levels of the inner circle, ramping up and down
InnerAlphaList = range(0,101,10) + range(90,9,-20) + [5,0,0,0]
print "Inner:",len(InnerAlphaList),InnerAlphaList
# Transparency of the outer circle
OuterAlphaList = range(0,51,8) + range(40,9,-12) + range(8,0,-2) + [0,0,0,0,0,0]
print "Outer:",len(OuterAlphaList), OuterAlphaList
# Add 100 so the file names get sorted properly?
NameNumberList = range(101, 101+len(InnerAlphaList))
# Changing the Euclidaan distance parameters affects how fuzzy the objects are
BaseCommand = '''convert -size {w}x{h} xc:black \
-fill "rgba( 0, 255,255 , {outal:0.1f} )" -stroke none -draw "translate {cenx},{ceny} circle 0,0 {outdia},0" -morphology Distance Euclidean:4,1000\
-fill "rgba( 0, 255,255 , {inal:0.1f} )" -stroke none -draw "translate {cenx},{ceny} circle 0,0 {india},0" -morphology Distance Euclidean:4,500 \
-blur 0x{blur} {basename}_{namenum}.gif'''
sys.stderr.write("Starting imagegen .")
for InAlpha,OutAlpha,NameNumber in zip(InnerAlphaList,OuterAlphaList,NameNumberList):
FormattedCommand = BaseCommand.format(
w = CanvasW, h = CanvasH,
cenx = CenterX, ceny = CenterY,
india = InnerDia, outdia = OuterDia,
blur = BlurLevel,
inal = InAlpha/100.0, outal = OutAlpha/100.0,
basename = BaseNameString,
namenum = NameNumber
)
sys.stderr.write(".")
# sys.stderr.write("{}\n".format(FormattedCommand))
ProcString = subprocess.check_output(FormattedCommand, stderr=subprocess.STDOUT,shell=True)
if ProcString:
sys.stderr.write(ProcString)
sys.stderr.write(" Done.\n")
""" BASE COMMANDS:
# inner circle:
convert -size 400x300 xc:black -fill "rgba( 0, 255,255 , 1 )" -stroke none -draw "translate 200,150 circle 0,0 75,0" -blur 0x8 -morphology Distance Euclidean:4,1000 blur_circle100.gif
#outer circle
convert -size 400x300 xc:black -fill "rgba( 0, 255,255 , .5 )" -stroke none -draw "translate 200,150 circle 0,0 150,0" -morphology Distance Euclidean:4,500 -blur 0x6 blur_circle100.gif
#both circles
convert -size 400x300 xc:black -fill "rgba( 0, 255,255 , .5 )" -stroke none -draw "translate 200,150 circle 0,0 150,0" -morphology Distance Euclidean:4,500 \
-fill "rgba( 0, 255,255 , 1 )" -stroke none -draw "translate 200,150 circle 0,0 75,0" -morphology Distance Euclidean:4,1000\
-blur 0x8 blur_circle100.gif
"""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With