gpt4 book ai didi

ImageMagick 绘制一系列具有发光效果的图像

转载 作者:行者123 更新时间:2023-12-04 11:54:12 25 4
gpt4 key购买 nike

我正在学习 ImageMagick。我想(使用 ImageMagick)创建一系列图像
使用命令后

convert -delay 0 -loop 0 frame*.gif final.gif

给出与附加动画 gif 类似的结果。

enter image description here

我想自己编写一系列命令,但我需要提示哪些效果和绘图指令会给我最相似的结果,所以我正在寻找类似的东西:
  • 画一个圆
  • 模糊它
  • 保存框架
  • 增加圆的半径
  • 重复

  • 但是,可能以上还不够。

    这个问题很模糊还是有人可以给我一个提示?

    最佳答案

    如果您在 shell 环境(OSX 或 Linux)中,您可以执行这样的操作,它会创建一系列半径不断增加的模糊圆圈,并将图像保存在适当命名的文件中...

    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

    为了变得更漂亮,您可以添加重复的模糊操作,或者为更大的半径添加更多的模糊。

    然后,按照您的建议将它们转换为动画 gif:
    convert -delay 0 -loop 0  blur_circle*.gif final.gif

    编辑

    更接近原始“愿景”的工作版本

    这是一个使用python生成两个圆圈的版本,其透明度在不同的时间尺度上有所不同。使用当前设置,随时间变化的透明度类似于此图,但您可以生成任何整数值列表以获得不同的效果:

    alpha-time graph

    这是程序生成的图像:

    glowingcircles

    这是程序本身:
    #! /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
    """

    关于ImageMagick 绘制一系列具有发光效果的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17456256/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com