How to dirty a font
How to dirty a font
Hi guys,
I'm trying to "replicate" the look and feel of an old (circa 1981) print with a font that looks almost (to me) the same.
The problem is I don't have the "grain" of the old printed media.
Ok, the font is not that good (I used What's the Font Android application), but I hope you get the idea.
I had a look at Fred's scripts but I didn't manage to find one to get what I'd like.
I thought of using erode, but I don't know how to apply it to each letter.
If you ever have an idea, please let me know.
Thanks.
I'm trying to "replicate" the look and feel of an old (circa 1981) print with a font that looks almost (to me) the same.
The problem is I don't have the "grain" of the old printed media.
Ok, the font is not that good (I used What's the Font Android application), but I hope you get the idea.
I had a look at Fred's scripts but I didn't manage to find one to get what I'd like.
I thought of using erode, but I don't know how to apply it to each letter.
If you ever have an idea, please let me know.
Thanks.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to dirty a font
What version of IM? I assume v6. If v7, use "magick" instead of "convert". What platform? I assume Windows.
Many methods are possible, such as this (Windows BAT format, for IM v6.)
I prefer to work in black and white, rather than opaque and transparent, so I extract alpha at the start and copy opacity at the end.
I create a clone of the image, and replace the pixels with Gaussian random, use just the red channel, and blur it, (adjust the blur sigma from 1 if you want) and auto-level.
I take the mean of the text image and the noise, and threshold to 50% to get white characters on black background. However, there will be some small patches of black within the white characters, and small patches of white within the black background. Connected-components, followed by another threshold, removes these.
Now we have entirely white characters on black background. A small blur gives an antialias. (There are "proper" ways of doing this, but they are more complex.) If you don't want the antialias, remove that blur.
Then we create an entirely black image and copy the opacity to it.
My command is rather complex. I suspect there is a simpler method.
Many methods are possible, such as this (Windows BAT format, for IM v6.)
Code: Select all
convert ^
flowRoot3688.png -alpha extract ^
( +clone ^
-fill gray(50%%) -colorize 100 ^
+noise Gaussian ^
-channel R -separate +channel ^
-blur 0x1 ^
-auto-level ^
) ^
-evaluate-sequence Mean ^
-threshold 50%% ^
-define connected-components:area-threshold=20 ^
-define connected-components:mean-color=true ^
-connected-components 4 ^
-threshold 50%% ^
-blur 0x0.5 ^
( +clone ^
-fill Black -colorize 100 ^
) ^
+swap ^
-compose CopyOpacity -composite ^
noisyFont.png
I create a clone of the image, and replace the pixels with Gaussian random, use just the red channel, and blur it, (adjust the blur sigma from 1 if you want) and auto-level.
I take the mean of the text image and the noise, and threshold to 50% to get white characters on black background. However, there will be some small patches of black within the white characters, and small patches of white within the black background. Connected-components, followed by another threshold, removes these.
Now we have entirely white characters on black background. A small blur gives an antialias. (There are "proper" ways of doing this, but they are more complex.) If you don't want the antialias, remove that blur.
Then we create an entirely black image and copy the opacity to it.
My command is rather complex. I suspect there is a simpler method.
snibgo's IM pages: im.snibgo.com
Re: How to dirty a font
Thanks a lot for the explanation, and sorry for the lack of details.
I am working on Ubuntu with ImageMagick 6.8.9-9 Q16 x86_64 2017-07-31 http://www.imagemagick.org
I will try to understand step by step and to play with the parameters.
I am working on Ubuntu with ImageMagick 6.8.9-9 Q16 x86_64 2017-07-31 http://www.imagemagick.org
I will try to understand step by step and to play with the parameters.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to dirty a font
For bash, replace the characters at line ends from "^" to "\", replace the doubled %% with single %, and escape the parentheses thus: \( \).
snibgo's IM pages: im.snibgo.com
Re: How to dirty a font
Thanks for the tips.
I now have:
But the end result is a 1kb image. I will try to find my mistake.
I now have:
Code: Select all
#!/bin/sh
convert \
flowRoot3688.png -alpha extract \
\( +clone \
-fill gray\(50%\) -colorize 100 \
+noise Gaussian \
-channel R -separate +channel \
-blur 0x1 \
-auto-level \
\) \
-evaluate-sequence Mean \
-threshold 50% \
-define connected-components:area-threshold=20 \
-define connected-components:mean-color=true \
-connected-components 4 \
-threshold 50% \
-blur 0x0.5 \
\( +clone \
-fill Black -colorize 100 \
\) \
+swap \
-compose CopyOpacity -composite \
noisyFont.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to dirty a font
Your bash version of the command works fine for me in bash, with IM v6.9.5-3.
Connected-components are fairly new, possibly after your v6.8.9-9. Try removing those three lines, and the following "-threshold".
Incidentally, if you want to increase the noise, change the line from
to
For very extreme noise:
Connected-components are fairly new, possibly after your v6.8.9-9. Try removing those three lines, and the following "-threshold".
Incidentally, if you want to increase the noise, change the line from
Code: Select all
-evaluate-sequence Mean
Code: Select all
-compose Mathematics -define compose:args=0,0.6,0.4,0 -composite
Code: Select all
-compose Mathematics -define compose:args=0,0.9,0.1,0 -composite
snibgo's IM pages: im.snibgo.com
Re: How to dirty a font
I updated my Ubuntu machine to 17.10 in order to test these commands, but I now face a .
So I'll try to solve this and then will be back with the results.
Code: Select all
convert: error while loading shared libraries: libgvc.so.6: cannot open shared object file: No such file or directory
So I'll try to solve this and then will be back with the results.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to dirty a font
You could also use -spread 1 and then blur a little and threshold
Code: Select all
convert flowRoot3688.png -spread 1 flowRoot3688_spread1.png
or
convert flowRoot3688.png -spread 1 -blur 0x1 -threshold 50% flowRoot3688_spread1b.png
Re: How to dirty a font
I will try that. I don't know why my result is so different from snibgo's one.
I will investigate now that imagemagick is up and running again.
Thanks.
I will investigate now that imagemagick is up and running again.
Thanks.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to dirty a font
Added the simpler spread technique to "Compound Fonts" section of IM Examples
http://www.imagemagick.org/Usage/fonts/#dirty_print
May take a hour or so to appear online.
The Compound Fonts Section is one of the oldest of ImageMagick Examples, and basically explores simple techniques of modifying a simple image (drawn font) to produce various effects. It was nice to add a new example to that section.
http://www.imagemagick.org/Usage/fonts/#dirty_print
May take a hour or so to appear online.
The Compound Fonts Section is one of the oldest of ImageMagick Examples, and basically explores simple techniques of modifying a simple image (drawn font) to produce various effects. It was nice to add a new example to that section.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to dirty a font
Unix users could also use my script, disperse, for a large variety of effects. Here are few.
input:
input:
Code: Select all
disperse -s 1 -d 1 -c 1 flowRoot3688.png test1.png
Code: Select all
disperse -s 2 -d 2 -c 5 flowRoot3688.png test2.png
Code: Select all
disperse -s 2 -d 5 -c 2 flowRoot3688.png test3.png
Code: Select all
disperse -s 1 -d 2 -c 2 flowRoot3688.png test4.png
Re: How to dirty a font
Thanks a lot, guys, I will try that today.
Re: How to dirty a font
My tries are pretty encouraging.
For the time begin, I had good results with
As for the sample, I just don't get why
gives me this error:
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Ubuntu 17.10
For the time begin, I had good results with
Code: Select all
disperse -s 1 -d 2 -c 2 flowRoot3688.png test4.png
Code: Select all
convert -size 320x100 -font Candice -pointsize 72 -annotate +25+65 'Anthony' \
-spread 1 -blur 0x1 -threshold 50% -blur 0x1 font_dirty_print.jpg
Code: Select all
convert: no images defined `font_dirty_print.jpg' @ error/convert.c/ConvertImageCommand/3258.
Ubuntu 17.10
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to dirty a font
Because you have no input image. Nothing in your command reads an image or creates one.
snibgo's IM pages: im.snibgo.com
Re: How to dirty a font
This next command has no input image but works:
Code: Select all
convert -size 320x100 xc:lightblue -font Ubuntu -pointsize 72 -fill navy -annotate +25+65 'Anthony' -blur 0x3 font_fuzzy.jpg