imagemagick从切片生成图像

imagemagick从切片生成图像,imagemagick,Imagemagick,请帮助我为ImageMagick编写命令。我需要生成一个边框,而只有这个边框的顶部。以下是算法: 取工件高度,生成画布宽度=高度*3和高度=高度*3 将顶部部件置于顶部中心位置 将工件旋转90度三次,并将其置于右中、底部和左中位置 从每一片上画一个角。我想它必须把每一片都拉长,然后计算一个三角形遮罩来切割不必要的边缘,但是我担心它会互相覆盖。所以,我知道,该怎么办。你有什么想法吗 我觉得你的问题很难理解,但我想你基本上是想用一面的图片制作一个完整的画框,也就是说,画框的图片 我意识到这有点晚了,

请帮助我为ImageMagick编写命令。我需要生成一个边框,而只有这个边框的顶部。以下是算法:

  • 取工件高度,生成画布宽度=高度*3和高度=高度*3
  • 将顶部部件置于顶部中心位置
  • 将工件旋转90度三次,并将其置于右中、底部和左中位置
  • 从每一片上画一个角。我想它必须把每一片都拉长,然后计算一个三角形遮罩来切割不必要的边缘,但是我担心它会互相覆盖。所以,我知道,该怎么办。你有什么想法吗

  • 我觉得你的问题很难理解,但我想你基本上是想用一面的图片制作一个完整的画框,也就是说,画框的图片

    我意识到这有点晚了,但我觉得有点挑战,所以这里有一个bash脚本,它将顶部的造型图片作为参数,并从中生成一个框架

    #!/bin/bash
    ################################################################################
    # pictureframe
    # Mark Setchell
    #
    # Make a picture frame from a single horizontal moulding picture - with mitred
    # corners and a transparent middle for a photo!
    ################################################################################
    # Set DEBUG=1 for debugging info
    DEBUG=1
    
    # Image of the moulding is the 1st parameter, use "moulding.jpg" if none given
    moulding=${1:-moulding.jpg}
    [ $DEBUG -gt 0 ] && echo "DEBUG: Using file: $moulding"
    
    # Get width and height of image
    read w h < <(convert "$moulding" -format "%w %h" info: )
    [ $DEBUG -gt 0 ] && echo "DEBUG: Dimensions: ${w}x${h}"
    
    # Determine corner points of mitring mask - it looks like this
    #
    #     ----------------------------
    #      \                        /
    #        ----------------------
    #
    polyline=$(convert "$moulding" -format "0,0 %w,0 %[fx:w-h],%h %h,%h" info:)
    [ $DEBUG -gt 0 ] && echo "DEBUG: Mitring mask: $polyline"
    
    # Mitre corners
    dbg=""
    [ $DEBUG -gt 0 ] && dbg="-write mask.png" && echo "DEBUG: Mask is in file mask.png"
    convert "$moulding" \( +clone -evaluate set 0 -fill white -draw "polyline $polyline" -alpha off $dbg \) -compose copyopacity -composite top.png
    
    # Build whole frame by rotating top through the angles and compositing onto extended blank canvas
    convert top.png -background none -extent x${w}            \
        \( top.png -rotate 90  \) -gravity east  -composite   \
        \( top.png -rotate 180 \) -gravity south -composite   \
        \( top.png -rotate 270 \) -gravity west  -composite -flatten result.png
    
    [ $DEBUG -gt 0 ] && echo "DEBUG: Output file is: result.png"
    
    #/bin/bash
    ################################################################################
    #图片名称
    #马克·塞切尔
    #
    #从单个水平模塑图片制作相框-斜接
    #角落和透明中间的照片!
    ################################################################################
    #为调试信息设置DEBUG=1
    调试=1
    #模塑图像是第一个参数,如果没有给出,请使用“molding.jpg”
    Molding=${1:-molding.jpg}
    [$DEBUG-gt 0]&&echo“调试:使用文件:$DEBUG”
    #获取图像的宽度和高度
    
    我发现你的问题很难理解,但我想你基本上是想用一面的图片制作一个完整的画框,即画框的图片

    我意识到这有点晚了,但我觉得有点挑战,所以这里有一个bash脚本,它将顶部的造型图片作为参数,并从中生成一个框架

    #!/bin/bash
    ################################################################################
    # pictureframe
    # Mark Setchell
    #
    # Make a picture frame from a single horizontal moulding picture - with mitred
    # corners and a transparent middle for a photo!
    ################################################################################
    # Set DEBUG=1 for debugging info
    DEBUG=1
    
    # Image of the moulding is the 1st parameter, use "moulding.jpg" if none given
    moulding=${1:-moulding.jpg}
    [ $DEBUG -gt 0 ] && echo "DEBUG: Using file: $moulding"
    
    # Get width and height of image
    read w h < <(convert "$moulding" -format "%w %h" info: )
    [ $DEBUG -gt 0 ] && echo "DEBUG: Dimensions: ${w}x${h}"
    
    # Determine corner points of mitring mask - it looks like this
    #
    #     ----------------------------
    #      \                        /
    #        ----------------------
    #
    polyline=$(convert "$moulding" -format "0,0 %w,0 %[fx:w-h],%h %h,%h" info:)
    [ $DEBUG -gt 0 ] && echo "DEBUG: Mitring mask: $polyline"
    
    # Mitre corners
    dbg=""
    [ $DEBUG -gt 0 ] && dbg="-write mask.png" && echo "DEBUG: Mask is in file mask.png"
    convert "$moulding" \( +clone -evaluate set 0 -fill white -draw "polyline $polyline" -alpha off $dbg \) -compose copyopacity -composite top.png
    
    # Build whole frame by rotating top through the angles and compositing onto extended blank canvas
    convert top.png -background none -extent x${w}            \
        \( top.png -rotate 90  \) -gravity east  -composite   \
        \( top.png -rotate 180 \) -gravity south -composite   \
        \( top.png -rotate 270 \) -gravity west  -composite -flatten result.png
    
    [ $DEBUG -gt 0 ] && echo "DEBUG: Output file is: result.png"
    
    #/bin/bash
    ################################################################################
    #图片名称
    #马克·塞切尔
    #
    #从单个水平模塑图片制作相框-斜接
    #角落和透明中间的照片!
    ################################################################################
    #为调试信息设置DEBUG=1
    调试=1
    #模塑图像是第一个参数,如果没有给出,请使用“molding.jpg”
    Molding=${1:-molding.jpg}
    [$DEBUG-gt 0]&&echo“调试:使用文件:$DEBUG”
    #获取图像的宽度和高度
    
    这是你的算法还是一个测验题?听起来你不确定最后一步。对于角,你的意思是边界图像应该沿着对角线在两条边之间分割,看起来像图像的两个三角形部分吗?另外:这正是我的意思,在这种情况下,第二个问题。这是你的算法还是一个测验问题?听起来你不确定最后一步。对于角,你的意思是边界图像应该沿着对角线在两条边之间分割,看起来像图像的两个三角形部分吗?另外:这正是我的意思,在这种情况下,第二个问题。