| by Arround The Web | No comments

Fancy Up Fonts in ImageMagick

We already know how to create texts and we know how to place them on a blank canvas. But there are times when we really need to make the texts look unique. Perhaps it is a brand name or something you would like to add to your website. Either way, you will be looking at how to fancy things up. In this tutorial, we will be learning how to fancy up texts.

Installing ImageMagick

We will need ImageMagick for this, so first let’s install it:

sudo apt-get install imagemagick

The Basics

Let us start:

convert -size 1000x300 xc:khaki -pointsize 172 -fill purple -annotate +150+190 'LinuxHint' linuxhint.jpg

Size – used to define the size of the canvas. This just sets the height and width of the canvas

Xc – used to set the background color, here, I have used khaki

Pointsize – used to set the size of the text

Fill – the color used to fill the text with; here I used purple

Annotate – annotate canvas with text

Linuxhint.jpg - the name of the final result or image

linuxhint

Fancying Things Up – Tiles

In the previous example, we use the fill switch to fill the word with the color purple. However, we do not have to use the fill switch. We can use the tile switch for example.

-tile filename

In this example, we are going to use a photo called photo33.png (the picture of a tree) on the tile switch.

convert -size 1000x300 xc:khaki -pointsize 172 -tile photo33.png -annotate +150+190 'LinuxHint' linuxhint_tile.jpg

linuxhint_tile

Alternatively, you can also create gradients:

convert -size 1000x300 xc:khaki -pointsize 172 -tile gradient: -annotate +150+190 'LinuxHint' linuxhint_gradient.jpg

linuxhint_gradient

Transparent Background

In this case, to get a transparent background. We can set the background to none and the file format to png.

convert -size 1000x300 xc:none -pointsize 172 -tile photo33.png -annotate +150+190 'LinuxHint' linuxhint_tile_nobackground.png

linuxhint_tile_nobackground

Outlining Text

You can choose to outline texts the hard way:

convert -size 1000x300 xc:khaki -pointsize 172 -fill black -annotate +151+191 'LinuxHint' -annotate +152+192 'LinuxHint' -annotate +151+192 'LinuxHint' -annotate +152+191 'LinuxHint' -annotate +149+189 'LinuxHint' -annotate +148+188 'LinuxHint' -annotate +148+189 'LinuxHint' -annotate +149+188 'LinuxHint' -fill red -annotate +150+190 'LinuxHint' linuxhint_outline.png

In other words, something like this:

convert -size 1000x300 xc:khaki -pointsize 172 \

-fill black -annotate +151+191 'LinuxHint' \

-annotate +152+192 'LinuxHint' \

-annotate +151+192 'LinuxHint' \

-annotate +152+191 'LinuxHint' \

-annotate +149+189 'LinuxHint' \

-annotate +148+188 'LinuxHint' \

-annotate +148+189 'LinuxHint' \

-annotate +149+188 'LinuxHint' \

-fill red -annotate +150+190 'LinuxHint' \

linuxhint_outline.png

Basically, here, make sure you cover all borders.

linuxhint_outline

Now, let us make the outline thicker:

convert -size 1000x300 xc:khaki -pointsize 172

-fill black -annotate +151+191 ‘LinuxHint’

-annotate +152+192 ‘LinuxHint’

-annotate +151+192 ‘LinuxHint’

-annotate +152+191 ‘LinuxHint’

-annotate +149+189 ‘LinuxHint’

-annotate +148+188 ‘LinuxHint’

-annotate +148+189 ‘LinuxHint’

-annotate +149+188 ‘LinuxHint’

-annotate +147+187 ‘LinuxHint’

-annotate +146+186 ‘LinuxHint’

-annotate +153+193 ‘LinuxHint’

-fill red -annotate +150+190 ‘LinuxHint’ linuxhint_outline.png

linuxhint_outlinethick

But writing a million lines just to create a border seems like too much. So, I will introduce you to an alternative:

-stroke color

-strokewidth value

So, let us write new code:

convert -size 1000x300 xc:khaki -pointsize 172 -fill red -stroke black -strokewidth 4 -annotate +150+190 'LinuxHint' linuxhint_outline_stroke.jpg

linuxhint_outline_stroke

Then, you have the following:

Size: size of canvas

Xc: background color

Pointsize: size of the font

Fill: fill the letters with a color

Stroke: the color to create the outline with

Strokewidth: the thickness of the outline

Annotate: annotate text onto canvas

Linuxhint_outline_stroke.jpg: name of the final result

Double Lines

Now, let us see how to create a double line effect. Here, the strokewidth of the second stroke has to be of a different color and of a smaller width than the first one. Basically, it is like writing with a thick marker and then on top of it with a thinner and different colored marker. The latter would create the illusion of a double line.

Untitled

convert -size 1000x300 xc:khaki -pointsize 172 -fill red -stroke black -strokewidth 4 -annotate +150+190 'LinuxHint' -fill none -stroke white -strokewidth 1 -annotate +150+190 'LinuxHint' linuxhint_outline_stroke1.jpg

Or

convert -size 1000x300 xc:khaki -pointsize 172 \

-fill red -stroke black -strokewidth 4 -annotate +150+190 'LinuxHint' \

-fill none -stroke white -strokewidth 1 -annotate +150+190 'LinuxHint' \

linuxhint_outline_stroke1.jpg

linuxhint_outline_stroke(1)

It looks like this if zoomed in:

Untitled2

A slightly different version of this is:

convert -size 1000x300 xc:none -pointsize 172 -fill red -stroke black -strokewidth 35 -annotate +150+190 'LinuxHint' -stroke white -strokewidth 30 -annotate +150+190 'LinuxHint' -stroke black -strokewidth 25 -annotate +150+190 'LinuxHint' -stroke white -strokewidth 20 -annotate +150+190 'LinuxHint' -stroke black -strokewidth 15 -annotate +150+190 'LinuxHint' -stroke white -strokewidth 10 -annotate +150+190 'LinuxHint' -stroke black -strokewidth 5 -annotate +150+190 'LinuxHint' -stroke none -annotate +150+190 'LinuxHint' linuxhint_psychedelic.png

Or

convert -size 1000x300 xc:none -pointsize 172 -fill red \

-stroke black -strokewidth 35 -annotate +150+190 'LinuxHint' \

-stroke white -strokewidth 30 -annotate +150+190 'LinuxHint' \

-stroke black -strokewidth 25 -annotate +150+190 'LinuxHint' \

-stroke white -strokewidth 20 -annotate +150+190 'LinuxHint' \

-stroke black -strokewidth 15 -annotate +150+190 'LinuxHint' \

-stroke white -strokewidth 10 -annotate +150+190 'LinuxHint' \

-stroke black -strokewidth 5 -annotate +150+190 'LinuxHint' \

-stroke none -annotate +150+190 'LinuxHint' \

linuxhint_psychedelic.png

linuxhint_psychedelic

It would look like this if zoomed in:

Untitled3

In this case, it is the same principle as the first scenario. But the first line is very thick and black, the second is white and less thicker than the first, etc…

Shadow

Now, let us add some shadow:

convert -size 1000x300 xc:none -font Candice -pointsize 172 -annotate +150+190 'LinuxHint' -blur 0x4 -fill red -stroke black -annotate +150+190 'LinuxHint' linuxhint_shadow.png

linuxhint_shadow

Now, let us try to create a soft outline with a blurred look.

convert -size 1000x300 xc:none -pointsize 172 -fill none -stroke black -strokewidth 8 -annotate 0x0+150+190 'LinuxHint' -blur 0x20 -fill red -annotate 0x0+150+190 'LinuxHint' linuhint_reflection4.png

Or

convert -size 1000x300 xc:none -pointsize 172 \

-fill none -stroke black -strokewidth 8 -annotate 0x0+150+190 'LinuxHint' -blur 0x20 \

-fill red -annotate 0x0+150+190 'LinuxHint' \

linuhint_reflection4.png

linuhint_reflection4

Here, we are using the blur switch. We are blurring the stroke.

-blur radius{xsigma}

Please note that the most important value here is the sigma value which will determine the extent of blurring.

Now, let us look at motion blur.

-motion-blur radius{xsigma}+angle

The angle, in this case, is the angle towards which the blurring occurs.

convert -size 1000x300 xc:khaki -pointsize 172 -fill purple -annotate +150+190 'LinuxHint' -motion-blur 0x25+65 -fill red -annotate 0x0+150+190 'LinuxHint' linuxhint_mb.jpg

Or

convert -size 1000x300 xc:khaki -pointsize 172 \

-fill purple -annotate +150+190 'LinuxHint' -motion-blur 0x25+65 \

-fill red -annotate 0x0+150+190 'LinuxHint' \

linuxhint_mb.jpg

linuxhint_mb

Another example:

convert -size 1000x300 xc:khaki -pointsize 172 \

-fill purple -annotate +150+190 'LinuxHint' -motion-blur 0x25+165 \

-fill red -annotate 0x0+150+190 'LinuxHint' \

linuxhint_mb2.jpg

linuxhint_mb2

In a Circle

Now, let us put the text in a circle.

-distort method arguments

Use the distort method to distort the text. After the distort switch, specify the method (which in this case is arc that will arc the text) and then the arguments.

convert -pointsize 172 -background none -fill red label:"LinuxHint: All things Linux" -distort Arc 340 linuxhint_circle1.png

linuxhint_circle1

Reflections

The code for reflections is as follows:

convert -size 1000x300 xc:none -pointsize 172 -fill red -annotate 0x125+150+190 'LinuxHint' -fill red -annotate 0x0+150+190 'LinuxHint' linuhint_reflection.png

Or

convert -size 1000x300 xc:none -pointsize 172 \

-fill red -annotate 0x125+150+190 'LinuxHint' \

-fill red -annotate 0x0+150+190 'LinuxHint' \

linuhint_reflection.png

linuhint_reflection

Use the annotate switch.

-annotate XdegreesxYdegrees{+-}t<sub>x</sub>{+-}t<sub>y</sub> text

Xdegrees and Ydegrees represent the shear on the text. Tx and ty are the offset.

Now, let us try something else:

convert -size 1000x300 xc:none -pointsize 172 -fill red -annotate 0x125+150+190 'LinuxHint' -fill red -annotate 0x0+150+190 'LinuxHint' -fill none -stroke black -strokewidth 4 -annotate 0x0+150+190 'LinuxHint' linuhint_reflection2.png

Or

convert -size 1000x300 xc:none -pointsize 172 \

-fill red -annotate 0x125+150+190 'LinuxHint' \

-fill red -annotate 0x0+150+190 'LinuxHint' \

-fill none -stroke black -strokewidth 4 -annotate 0x0+150+190 'LinuxHint' \

linuhint_reflection2.png

linuhint_reflection2

Here, the options are innumerable and what you can do with this too.

Overlapping Characters

In order to write up a line with overlapping characters, you need to individually write and position each letter.

convert -size 700x300 xc:none -font Candice -pointsize 172 -stroke black -strokewidth 4 -fill white -stroke black -annotate +150+190 L -stroke none -annotate +150+190 L -stroke black -annotate +200+170 i -stroke none -annotate +200+170 i -stroke black -annotate +220+170 n -stroke none -annotate +220+170 n -stroke black -annotate +300+170 u -stroke none -annotate +300+170 u -stroke black -annotate +390+170 x -stroke none -annotate +390+170 x linux_overlapping.png

Or

convert -size 700x300 xc:none -font Candice -pointsize 172 \

-stroke black -strokewidth 4 -fill white \

-stroke black -annotate +150+190 L \

-stroke none -annotate +150+190 L \

-stroke black -annotate +200+170 i \

-stroke none -annotate +200+170 i \

-stroke black -annotate +220+170 n \

-stroke none -annotate +220+170 n \

-stroke black -annotate +300+170 u \

-stroke none -annotate +300+170 u \

-stroke black -annotate +390+170 x \

-stroke none -annotate +390+170 x \

linux_overlapping.png

linux_overlapping

And if you wanted to add some color:

convert -size 700x300 xc:none -font Candice -pointsize 172 -stroke black -strokewidth 4 -fill red -stroke black -annotate +150+190 L -stroke none -annotate +150+190 L -stroke black -annotate +200+170 i -stroke none -annotate +200+170 i -stroke black -annotate +220+170 n -stroke none -annotate +220+170 n -stroke black -annotate +300+170 u -stroke none -annotate +300+170 u -stroke black -annotate +390+170 x -stroke none -annotate +390+170 x linux_overlapping_red.png

Or

convert -size 700x300 xc:none -font Candice -pointsize 172 -stroke black -strokewidth 4 -fill red \

-stroke black -annotate +150+190 L \

-stroke none -annotate +150+190 L \

-stroke black -annotate +200+170 i \

-stroke none -annotate +200+170 i \

-stroke black -annotate +220+170 n \

-stroke none -annotate +220+170 n \

-stroke black -annotate +300+170 u \

-stroke none -annotate +300+170 u \

-stroke black -annotate +390+170 x \

-stroke none -annotate +390+170 x \

linux_overlapping_red.png

linux_overlapping_red

Now, the deal is that you can decide on the position of each and every letter.

Wave

Now, let us look at the wave switch.

-wave amplitudexwavelength

The wave switch will shear it using a sine wave.

convert -size 1000x300 xc:none -pointsize 172 -fill red -annotate 0x0+150+190 'LinuxHint' -wave 6x6 linuhint_shade.png

Or

convert -size 1000x300 xc:none -pointsize 172 \

-fill red -annotate 0x0+150+190 'LinuxHint' -wave 6x6 \

linuhint_wave.png

linuhint_shade

Colorful

Now, let us create a colorful piece.

-sparse-color method ‘x,y color ’…’

The method can be barycentric, bilineaanhattnoanhattantan, shepards, and inverse.

convert -font Times-Bold -pointsize 172 -background none label:"LinuxHint" -sparse-color Barycentric '0,%h blue %w,0 red' linuxhint_colorful.png

linuxhint_colorful

Mixing it up

You can also mix it all up, that is put a few of the effects together to make one whole.

So, let us put a few of the effects together:

Example #1:

In this case, we are putting tile and stroke together.

convert -size 1000x300 xc:none -pointsize 172 -tile photo33.png -stroke black -strokewidth 3 -annotate +150+190 'LinuxHint' linuxhint_mixed.png

linuxhint_mixed

Example #2:

In this example, we are putting tile, stroke, and distort together.

convert -size 1000x300 xc:none -pointsize 172 -tile photo33.png -annotate +150+190 'LinuxHint' -stroke black -strokewidth 3 -annotate +150+190 'LinuxHint' -distort Arc 340 linuxhint_mix2.png

linuxhint_mix2

Example #3:

convert -size 1000x300 xc:none -pointsize 172 -annotate 0x125+150+190 'LinuxHint' -annotate 0x0+150+190 'LinuxHint' -sparse-color Barycentric '0,%h blue %w,0 red' linuhint_mix2.png

linuhint_mix2(1)

Conclusion

Creating a fancy font is not too hard. You have to carefully think it out because one word out of place will change the entire effect. So, ensure to think out the entire process, write out little notes and then write the code, especially if it’s very complicated or very long.

Share Button

Source: linuxhint.com

Leave a Reply