Apply custom ImageMagick (GraphicsMagick) envelope distortion to text

I want to generate text like this using ImageMagick:

Warped text

I have a font as a TTF file and you know how to generate an image with undistorted text. I'm having trouble applying distortion.

The "envelope" that I want to use is as follows:

Envelope

I read ImageMagick examples on distortions, but I can not understand the correct command.

Please note that this is not an arc.

+4
source share
1 answer

This is a pretty tricky task: ImageMagick has built-in distortion effects, but nobody looks like the one you need.

To achieve your goal, you can try to determine user distortion: for example, using image cards (in particular, cards with distortions with distortion distortions, more information here ).

Basically, you create a black and white gradient image (map) that defines how a particular effect should be applied to each pixel in the image.

The hard part generates the image map correctly: you can do it manually or using ImageMagick.

For example, this command, taken from ImageMagick documents, creates a map of spherical distortions:

convert -size 100x100 xc: -channel R \ -fx 'yy=(j+.5)/h-.5; (i/w-.5)/(sqrt(1-4*yy^2))+.5' \ -separate +channel sphere_lut.png 

this is the resulting image:

spherical distortion map

once you have created a distortion map, you can apply it to your image, for example:

 convert input.png lut_mask.png -fx 'p{ v*w, j }' output.png 
+2
source

Source: https://habr.com/ru/post/1481247/


All Articles