How to Create Image Thumbnails

Image thumbnails are basically a smaller size copy of a larger image. They can be created using PHP GD Library functions alongside a file system function that we already learned about. The getimagesize() file function will return the dimensions of the image specified. It can be used together with the list() function to minimize code […]

How to Add Image Filters & Effects

The imagefilter() function can be used to apply various fun and/or useful effects to an existing image or photograph. The selection of effects is: Parameter Description Arguments IMG_FILTER_NEGATE Reverses All Colors of the Image IMG_FILTER_GRAYSCALE Converts the Image Into Grayscale IMG_FILTER_BRIGHTNESS Changes the Brightness of the Image Use arg1 to Set the Level of Brightness […]

How to Add Text to An Image

In order to add text to an image, you need two things: the image and the font. For our example, we will use an existing image, rather than creating our own. We will also need a “.ttf” font file (of any font type/style that you want) uploaded to the server that your script will be […]

How to Draw Shapes On An Image

Drawing squares, rectangles, circles, ellipses and polygons are all fairly simple using PHP’s GD Library functions. First, let’s create a 300px by 300px image, allocate two different colors (grey and green), fill up the image with the grey color, send it to the browser, and clear the memory: <?php header(‘Content-type: image/png’); $png_image = imagecreate(300, 300); […]

How to Draw Lines On An Image

Before we begin drawing on our image, there are two functions that we should consider, for added variety. 1. Line color can be modified using the imagecolorallocate() function, which we learned about before. It should be stored in a variable to be used later. 2. Line thickness can be modified using the imagesetthickness() function, which […]

Creating An Image With the PHP GD Library

The three standard type of images that can be created from scratch with the PHP GD Library are: JPG, GIF and PNG. JPG Is Designed to Compress Full-Color Images, & Is Ideal For Digital Photos, Etc. GIF Is Designed to Support Only 256 Colors, Along With Transparency, Interlacing & Animation PNG Is Designed As An […]

GD Library Function Reference

The “GD Library” is the most used image-processing tool in PHP, allowing the dynamic creation and editing of images, charts, thumbnails, etc. The file types that can be created and/or edited using the GD library are GIF, JPEG and PNG. The GD library will be included with most PHP installations. To confirm if the GD […]

MYSQL Security & Handling User Input

Last, but not least (in fact this might be the most important step of all), I would like to caution you about handling user input, or allowing random people to put random data into your database queries. Why might you do that? Every time you use a website’s search feature to enter in your search […]

Handling MYSQL Query Results In PHP

Now, how do we handle the results of the MYSQL statements executed? Decisions, decisions… That all depends on what you want to do. The mysqli_num_rows() function, when handed the result of an executed SELECT or SHOW statement, will return the number of rows that will be returned. The mysqli_affected_rows() function, when handed the result of […]

MYSQL Connect & Close

The #1 most important step of integrating MYSQL into your PHP script is connecting to the database. And while it is not strictly necessary to close the connection, it is always good practice to tie up any loose ends. Here we will learn how to do both. The mysqli_connect() function is used to connect. It […]