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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Identify the image subset3m 14s
-
Overview of my solution3m 19s
-
Setting up the files2m 43s
-
Calculating the scaling ratio6m 28s
-
Using a custom class to scale images6m 25s
-
Generating the thumbnails7m 49s
-
Using subimage-search in ImageMagick4m 32s
-
Analyzing the image statistics4m 45s
-
Finding the cropped images7m 13s
-
Running the script and displaying the results3m 19s
-
-
-
-
-