How to erase everything inside a border?
Re: How to erase everything inside a border?
If I want to customize the width of the output border in pixel, what should I do? I can change the argument in the octagon kernel, but I would like to control exactly how wide it is.
Because this is the border, I would like when it is enlarges, it is aligned it in the middle, not in left or right.
Also, sometimes I would like the output to be a dotted line or a stroked line. Is there any way to manipulate this?
Thank you so much.
Because this is the border, I would like when it is enlarges, it is aligned it in the middle, not in left or right.
Also, sometimes I would like the output to be a dotted line or a stroked line. Is there any way to manipulate this?
Thank you so much.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to erase everything inside a border?
Sorry this is not very clear to me. Can you show examples of what you want to happen and explain what you are trying to do for each example with an example output. You have too many cases. Break this into parts for each case with examples.
Re: How to erase everything inside a border?
Sorry for making you confused. I'll try to explain better.
- These are three images of the output when the argument of octagon is 1, 3 and 5:
The point is, when you enlarge the border, it expand inside. I would like it to expand equally inside and outside, which means the heart of the border is unmoved.
- Sometimes I would like the output to be a dotted line or a dashed line. Is there a way to change the code to achieve that?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to erase everything inside a border?
Yes, there is. Replace edgein with edge and half the octagon:sizeThe point is, when you enlarge the border, it expand inside. I would like it to expand equally inside and outside, which means the heart of the border is unmoved.
Yes there is. See -draw about types of line strokes at http://www.imagemagick.org/Usage/draw/#mvg_settingsSometimes I would like the output to be a dotted line or a dashed line. Is there a way to change the code to achieve that?
I will have to get back to you later with updates on the script. I will be out most of the day.
Re: How to erase everything inside a border?
I have tried to do that myself, and haven't succeeded. I ask you in a seperate thread viewtopic.php?f=1&t=26191&p=114987#p114987 and you say there is no way. So can you help me again? Thank you.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to erase everything inside a border?
Sorry I misunderstood your question. If you have a raster image with lines, I do not think you can easily change solid lines to dashed lines. You can only do that if you have a vector image such as SVG. The only way I can think to do that is to use the image as a mask and composite it with some other image that has a tiny checkerboard pattern.fmw42 wrote:Yes there is. See -draw about types of line strokes at http://www.imagemagick.org/Usage/draw/#mvg_settingsSometimes I would like the output to be a dotted line or a dashed line. Is there a way to change the code to achieve that?
I will have to get back to you later with updates on the script. I will be out most of the day.
Here is an example:
Code: Select all
convert -respect-parenthesis 1.png \
\( -size 3x3 xc:white xc:black +append \( +clone -flop \) -append \
-write mpr:checks +delete -size 640x480 tile:mpr:checks \) \
\( -clone 0 -alpha extract \) \
\( -clone 1 -clone 2 -compose multiply -composite \) \
-delete 1,2 -alpha off -compose over -compose copy_opacity -composite 1_proc.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to erase everything inside a border?
fmw42 wrote:The point is, when you enlarge the border, it expand inside. I would like it to expand equally inside and outside, which means the heart of the border is unmoved.
This works for me by changing edgein to edge and making -bordercolor none and -border = octagon value or larger if needed and then shave by octagon value. So here I use octagon:2 which will add about 2 pixels to each side of the edge.
Code: Select all
infile="1.png"
color="black"
w2=`convert $infile -format "%[fx:w-2]" info:`
h2=`convert $infile -format "%[fx:h-2]" info:`
convert $infile -background white -flatten -fill black +opaque white -bordercolor none -border 2 \
-fill none -draw "matte 2,2 floodfill matte $w2,2 floodfill matte $w2,$h2 floodfill matte 2,$h2 floodfill" \
-fill white +opaque none -fill black -opaque none \
-alpha off -morphology edge octagon:2 \
-channel rgba -fill none +opaque white -fill $color -opaque white -shave 2x2 result.png
Re: How to erase everything inside a border?
This one is cleaner. Thank you so much
Can I adjust the width of the line in pixel?
Can I adjust the width of the line in pixel?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to erase everything inside a border?
change the octagon value. It will put approximately one pixel on each side of the line. Or use a different shape, such as square. Seeooker wrote: Can I adjust the width of the line in pixel?
http://www.imagemagick.org/Usage/morphology/#kernel
Re: How to erase everything inside a border?
Thanks.
When I try your code, it runs well. However when I try to make an output as a variable:
It gives this error:
I don't know why it's wrong.
When I try your code, it runs well. However when I try to make an output as a variable:
Code: Select all
infile="overlay.png"
outfile="overlay_cleaned.png"
width=3
w2=`convert $infile -format "%[fx:w-2]" info:`
h2=`convert $infile -format "%[fx:h-2]" info:`
convert $infile -background white -flatten -fill black +opaque white -bordercolor none -border 2 \
-fill none -draw "matte 2,2 floodfill matte $w2,2 floodfill matte $w2,$h2 floodfill matte 2,$h2 floodfill" \
-fill white +opaque none -fill black -opaque none \
-alpha off -morphology edge octagon:$width \
-channel rgba -fill none +opaque white -fill $color -opaque white -shave 2x2 $outfile
Code: Select all
convert.im6: unable to open image `-opaque': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `-opaque' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `white': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `white' @ error/constitute.c/ReadImage/544.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to erase everything inside a border?
What is the value of $color? That's the message you'll get if you haven't set it.
snibgo's IM pages: im.snibgo.com
Re: How to erase everything inside a border?
Stupid me. Thank you so much