From the course: Code Clinic: PHP

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Calculating the scaling ratio

Calculating the scaling ratio - PHP Tutorial

From the course: Code Clinic: PHP

Calculating the scaling ratio

Before embarking on the PHP code let's take a look at the ImageMagick documentation for matching sub-images and shapes. The key information is here. It says the search basically does a compare of the small image at every possible location in the larger image. As such, it's slow. Very, very slow. The best idea is to compare a very, very small sub-image to find possible locations. With that in mind, the first task is to find out how big the original images are and calculate a scaling ratio to generate smaller versions. So let's go to the PHP code. In my editing program I've created a new file called find underscore crop dot PHP which is where I'll be building the main script. I've saved it in the top level of the problem 02 folder of my testing site. I'm gonna begin by initializing some variables that I'll paste in from variables dot txt that you can find in the exercise files for this video. The first four variables are the image folders and then we've got three empty arrays for files…

Contents