Hi,
I want to draw a rectangular line with some angle on the bottom part. Please see attached image.
This line need to be in different colors that user will select. What is the best way of drawing this type of border on an image.
Thanks,
Irfan
How to draw an arbitrary border line on image?
How to draw an arbitrary border line on image?
- Attachments
-
- Need to draw the border on the fly
- curved.jpg (29.05 KiB) Viewed 24556 times
Re: How to draw an arbitrary border line on image?
You have posted in the Imagick section - are you using Imagick with php?
Just checking as some people get confused between Imagick and Imagemagick.
Just checking as some people get confused between Imagick and Imagemagick.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to draw an arbitrary border line on image?
How did you create this the first time? If you have the same image and just need to change the color of the line, see -fill somecolor -opaque black. That will work if the line is not anti-aliased.
If you need to draw the line from scratch, then see -draw. There is no freehand part, but you can use curved shapes (ellipse) or bezier curves or polylines.
http://www.imagemagick.org/Usage/draw/
If you need to draw the line from scratch, then see -draw. There is no freehand part, but you can use curved shapes (ellipse) or bezier curves or polylines.
http://www.imagemagick.org/Usage/draw/
Re: How to draw an arbitrary border line on image?
yes I am using the php Imagick library.
Bonzo wrote:You have posted in the Imagick section - are you using Imagick with php?
Just checking as some people get confused between Imagick and Imagemagick.
Re: How to draw an arbitrary border line on image?
I have created this image in the MS Paint.fmw42 wrote:How did you create this the first time? If you have the same image and just need to change the color of the line, see -fill somecolor -opaque black. That will work if the line is not anti-aliased.
If you need to draw the line from scratch, then see -draw. There is no freehand part, but you can use curved shapes (ellipse) or bezier curves or polylines.
http://www.imagemagick.org/Usage/draw/
What I want to achieve is to draw that line inside that curvy image, with different colors that is selected by users. Should bezier curves will do that?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to draw an arbitrary border line on image?
gurupk wrote:I have created this image in the MS Paint.fmw42 wrote:How did you create this the first time? If you have the same image and just need to change the color of the line, see -fill somecolor -opaque black. That will work if the line is not anti-aliased.
If you need to draw the line from scratch, then see -draw. There is no freehand part, but you can use curved shapes (ellipse) or bezier curves or polylines.
http://www.imagemagick.org/Usage/draw/
What I want to achieve is to draw that line inside that curvy image, with different colors that is selected by users. Should bezier curves will do that?
I do not know for sure. The best is to try different curves or polylines/polygon with -draw. see http://www.imagemagick.org/Usage/draw/
The problem is that IM is not interactive, so you have to specify each line segment or a curve.
If you can draw this shape elsewhere, then you can use that in IM and fill it with different colors. If you draw it without anti-aliasing, then you can also change the line's color once you get it into IM.
Re: How to draw an arbitrary border line on image?
Hi,
How can I draw an inner border?
I think this way i can achieve the solution. So if I have a PNG file and it has the curved from the bottom, so when i apply border inside, the library automatically draws the lines with the curve, not outer side, but inside the image with 3px inner.
Is this possible to do?
Thanks,
How can I draw an inner border?
I think this way i can achieve the solution. So if I have a PNG file and it has the curved from the bottom, so when i apply border inside, the library automatically draws the lines with the curve, not outer side, but inside the image with 3px inner.
Is this possible to do?
Thanks,
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to draw an arbitrary border line on image?
Post an example image where you want the line drawn inside the border. And explain exactly where you want the line drawn.gurupk wrote:Hi,
How can I draw an inner border?
I think this way i can achieve the solution. So if I have a PNG file and it has the curved from the bottom, so when i apply border inside, the library automatically draws the lines with the curve, not outer side, but inside the image with 3px inner.
Is this possible to do?
Thanks,
Or see -morphology EdgeIn http://www.imagemagick.org/Usage/morphology/#edgein
Re: How to draw an arbitrary border line on image?
Hi,
Attach is the image, which I used to place a inside border, but it is not exactly rounded with the outer edge. This is done through series of image composition on each other.
But if there is a direct way to draw the border like this inside the image, then that will be great.
Please any thoughts.
Regards,
Attach is the image, which I used to place a inside border, but it is not exactly rounded with the outer edge. This is done through series of image composition on each other.
But if there is a direct way to draw the border like this inside the image, then that will be great.
Please any thoughts.
Regards,
- Attachments
-
- bsave7.png (3.3 KiB) Viewed 24359 times
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to draw an arbitrary border line on image?
OK. I took your image and got rid of the line. So my starting image looks like the following:
Then I extracted the alpha channel, reduces its size by 10 pixels in each direction, got the edge from it, extended the edge image back to original size padding with black. Then I composited the image with a solid green image using the processed edge image as a mask.
infile="bsave7_new.png"
inset=10
color="springgreen3"
inname=`convert $infile -format "%t" info:`
ww=`convert $infile -format "%w" info:`
hh=`convert $infile -format "%h" info:`
ww2=`convert xc: -format "%[fx:$ww-$inset]" info:`
hh2=`convert xc: -format "%[fx:$hh-$inset]" info:`
echo "$infile; $inset; $color; $ww; $hh; $ww2; $hh2;"
convert $infile \
\( -size ${ww}x${hh} xc:"$color" \) \
\( -clone 0 -alpha extract -resize ${ww2}x${hh2}! -edge 1 -background black -gravity center -extent ${ww}x${hh} \) \
-gravity center -compose over -composite ${inname}_line.png
Then I extracted the alpha channel, reduces its size by 10 pixels in each direction, got the edge from it, extended the edge image back to original size padding with black. Then I composited the image with a solid green image using the processed edge image as a mask.
infile="bsave7_new.png"
inset=10
color="springgreen3"
inname=`convert $infile -format "%t" info:`
ww=`convert $infile -format "%w" info:`
hh=`convert $infile -format "%h" info:`
ww2=`convert xc: -format "%[fx:$ww-$inset]" info:`
hh2=`convert xc: -format "%[fx:$hh-$inset]" info:`
echo "$infile; $inset; $color; $ww; $hh; $ww2; $hh2;"
convert $infile \
\( -size ${ww}x${hh} xc:"$color" \) \
\( -clone 0 -alpha extract -resize ${ww2}x${hh2}! -edge 1 -background black -gravity center -extent ${ww}x${hh} \) \
-gravity center -compose over -composite ${inname}_line.png