Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
Render Text and Shapes on Images in PHP
Sep 25, 2018 @ 17:36:25

TutsPlus.com has continued their series of posts covering the use of image manipulation functionality in PHP using the GD library. In this latest tutorial they cover drawing shapes in images and rendering fonts.

Besides using GD for manipulating regular images, we can also create our own from scratch. Different functions in the library can be used to draw basic shapes like ellipses, circles, rectangles, polygons, and simple lines. With some maths, these shapes can create nice patterns. There are also functions available to draw text on the rendered image, which opens up a lot of possibilities.

This tutorial will teach you how to draw basic shapes in PHP and how to render text using your favorite font.

The tutorial starts by explaining what functions to use to draw lines, circles, arcs, rectangles, and polygons. Example code is provided showing all of these in action together to create a basic line drawing of a house and sun. They then enhance this with changes of line thickness, color fills and the use of a "brush" created from another image to make a new house picture. The tutorial finishes with a look at how to integrate fonts into the image and insert whatever text you might want (using a true-type font).

tagged: tutorial series image manipulation part3 text shapes

Link: https://code.tutsplus.com/tutorials/rendering-text-and-basic-shapes-using-gd--cms-31767


Trending Topics: