Reputation:
I want to generate text like this using ImageMagick:
I have the font as a TTF file and know how to generate an image with just the undistorted text. What I'm having trouble with is applying the distortion.
The "envelope" I want to use looks like this:
I've been reading over ImageMagick's examples on distortions but can't seem to figure out the right command.
Please note, this is not an arc.
Upvotes: 4
Views: 778
Reputation: 12375
This is a quite complex task: ImageMagick has some built-in distortion effects, but no one resembles the one you need.
To achieve your goal you can try to define a custom distortion: for example using image maps (in particular absolute distortion lookup maps, more info here).
Basically you create a black/white gradient image (the map) that define how a particular effect should be applied to every single pixel of the image.
The tricky part is correctly generating image map: you can do it manually or using ImageMagick.
For example this command taken from ImageMagick docs creates a spherical distortion map:
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:
once you've created your distortion map you can apply it to your image for example with:
convert input.png lut_mask.png -fx 'p{ v*w, j }' output.png
Upvotes: 2