0

There are many programs to convert an image to ascii art, but I want to opposite. Let's say I have a simple ascii art with only one character #. How can I wrap around all the outer nodes like this?

I want to convert this art:

                            ##                       ##
                      ##   ##                         ##
     ############    #### ##                  ###      ##
    ############    ##  ##                   ###        ##
        ###        ##    ##                 ###  ###     
       ###  #####    ###      ##   ##      ###  ###  ##    ##
      ###  ##  ##   ####     ###  ##      ###  ###    ##  ##
     ###  ##  ##   ## ##    #### ##      ########      ####
    ###  ######   ##  ##   ## ####      #######         ##
   ###  ##  ##   #######  ##  ###      ###   ###       ##
  ###  ##    ## ##    ## ##   ##      ###     ###     ##
 ###                                 ###       ###   ##
                                                    ##
#####################################################
####################################################

Actually, I don't want it to wrap to all exact outer nodes. I just want it to get the overall shape. Is it possible?

Any program is fine.

2

3 Answers 3

3

Ok first lets make the image a pixel image where # are black and blanks are white, so i open the ascii graphics in a text editor (any would do but a more comprehensive one helps). Here im using scite.

So first one must make the image a rectangle so the end must be padded so it has equal amount of characters.

enter image description here

Image 1: Pad the end of the line. Spaces are represented by dots as i have show whitespace on

Now we have a 15x61 image. So lets turn this into a image format. PBM is ascii text so it easy to do with search and replace.

We search and replace each space by "0 " and then each hash by "1 ", it's important to do it in this order. then we add a header

P1
60 14

then we save the file with .pbm extension that we can open as a image. The image looks like this:

enter image description here

Image 2 Resulting image

we can now open that image in inkscape and auto trace it.

enter image description here

Image 3 Naive autotrace of ascii image with default settings

You can make it different by lowering the smooth corners setting and speckles setting.

enter image description here

Image 4: Less smoothing

or you can scale the image in a pixel editor and then trace....

enter image description here

Image 5: Image scaled with nearest by double and more smoothing in tracing

And finally since your ascii is not square while the pixels are squish the image a bit enter image description here

Image 6 Quick and dirty result, no smoothing, doubled pixels

All of this can be automated with very little effort. You could image convolve after scale to get a better result. Adjust smooth corners until your satisfied.

Alternative approaches

  1. make a font where the # is a blob.
  2. same as 1 but squish together
  3. Same as 1 or 2 but blur between in image editor then trace. ....
1

Inkscape has in Align & Distribute panel a rearranging tool which swaps the places of the selected objects. If you have prepared a set of new shapes which has exactly as many pieces as your artwork has the # shapes you can swap them all. The swapping needs one click per a swap, but it's only pressing one key repeatedly. It needs also some preparation steps, but the process is still quite simple. The idea is to lift all new shapes above the old ones in the stacking order at first, then select both object sets at the same time and then press repeatedly Exchange in Z-order.

See it in this tutorial video https://www.youtube.com/watch?v=9SNvArDGzDU or in this Incscape forum article https://inkscape.org/forums/beyond/how-to-accomplish-multiple-objects-replacements-find-and-replace/

You cannot use this to change only some properties of the shapes, for ex. change the geometric forms, but keep the colors or otherwise. The swapping exchanges the shapes with all their properties.

The question is possible to be interpreted differently. The # shapes seem to form thick straight lines. You may want just to get those lines. My advice: Draw them with the Bezier curve tool. Either use a wide stroke and click the line endpoints. Or use a thin stroke and click the line corner points (total 5 clicks to get a closed shape) as you have done already, but only for a # shape.

1

This is not a fully automated method, but might work for you. For Inkscape 1.3

  1. Select the text and do Path > Object to Path, then Path > Split Path. This will make each # symbol its own object. Select all and set their fill to a different colour

  2. Draw a black filled octagon shape over one of the # symbols, set the fill semi-transparent.

  3. Duplicate it, and using snapping move it over the next #

  4. Do Ctrl+Alt+D to repeat the duplicate and transform along the entire line.

  5. Repeat steps 3 and 4 for each row

  6. Delete the gaps.

Something like this

enter image description here

When you have finished, select one octagon, and do Edit > Select Same > Fill colour. Group them, then move the group away from the original # symbols.

If on the other hand you want to convert the complete graphic to a solid filled graphic, you could just use the Pen tool and redraw it manually.

enter image description here

3
  • Why not just make a font where hash looks like a blob?
    – joojaa
    Oct 14, 2023 at 10:04
  • @joojaa - sure, you could if you want to go to that much trouble. Perhaps feasible if you have a lot of these to do.
    – Billy Kerr
    Oct 14, 2023 at 10:31
  • Well last time i made a one letter font it took 4 minutes... but it was not blob
    – joojaa
    Oct 14, 2023 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.