How to convert an image with one kind of stroke to another?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ooker
Posts: 22
Joined: 2014-07-24T10:32:57-07:00
Authentication code: 6789

How to convert an image with one kind of stroke to another?

Post by ooker »

I have an image like this: Image
I want to convert it to dash line only. I have tried

Code: Select all

convert input.png -draw "stroke-dasharray 10 3 3 3" output.png
or

Code: Select all

convert input.png -draw "stroke-dasharray 10 3 3 3  path 'M 10,40 L 90,40'" output.png
as in http://www.imagemagick.org/Usage/draw/#mvg_settings but haven't met any success. The output is unchanged. Do you have any ideas? Thank you.
Last edited by ooker on 2014-09-02T10:32:46-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert an image with dash line only to stroke li

Post by fmw42 »

Your blue line is not dashed.

Perhaps I misunderstand. But you cannot change a line that has already been drawn to some other stroke type. You would have redraw it from scratch or clear out the old line by filling over it and then draw the new stroke type in the same positions.

If you want to draw a line with a strokewidth and color with or without dashes, see http://www.imagemagick.org/Usage/draw/#strokewidth
ooker
Posts: 22
Joined: 2014-07-24T10:32:57-07:00
Authentication code: 6789

Re: How to convert an image with one kind of stroke to anoth

Post by ooker »

Sorry for my bad English. I have checked the dictionary again and edit the post to make it clearer. Hopefully this time you won't be confused.

The blue line isn't in my image, maybe it's from the forum or the image host. I don't know.

So I can't do that, is that right?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert an image with one kind of stroke to anoth

Post by fmw42 »

Your image is a raster image. So you cannot change the kind of stroke from simple to dashed. That is only possible if you have a vector image such as SVG. If you want to make the yellow lines in the image wider or narrower, you can use -morphology dilate or erode. see http://www.imagemagick.org/Usage/morphology/#basic

The only way to make dashed lines is to composite your alpha channel with an image of a checkerboard pattern.

see
viewtopic.php?f=1&t=25970&start=15#p114991
ooker
Posts: 22
Joined: 2014-07-24T10:32:57-07:00
Authentication code: 6789

Re: How to convert an image with one kind of stroke to anoth

Post by ooker »

Let's say that I have a vector image. What should I do?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to convert an image with one kind of stroke to anoth

Post by snibgo »

Use a vector editor such as Inkscape.
snibgo's IM pages: im.snibgo.com
ooker
Posts: 22
Joined: 2014-07-24T10:32:57-07:00
Authentication code: 6789

Re: How to convert an image with one kind of stroke to anoth

Post by ooker »

Doesn't Imagemagick support that?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to convert an image with one kind of stroke to anoth

Post by snibgo »

ImageMagick can do some things with vectors, like rasterising them or (to a limited degree) vectorising a raster, but it isn't a general-purpose vector editor.

If you can open your vector file in Inkscape, you can easily do anything you want with the lines: change width, colour, style, dot-dash-dot, whatever you want. You can convert it to SVG and then use text tools to manipulate the image: change the lines, remove lines, add new lnes, whatever.
snibgo's IM pages: im.snibgo.com
ooker
Posts: 22
Joined: 2014-07-24T10:32:57-07:00
Authentication code: 6789

Re: How to convert an image with one kind of stroke to anoth

Post by ooker »

I get that. Thank you.
Post Reply