PHPThumb image processing example_PHP tutorial
Download address (github.com/masterexploder/PHPThumb).
Note that this class library has the same name called phpThumb, the only difference is in upper and lower case, so be careful when searching for documentation.
In the process of website construction, there are countless places where images need to be processed. It is very cumbersome to use PHP image functions to process images. And it is very difficult for novices to master. Now we can use the PHPThumb class library to process images, including image resizing, image interception, image watermarking, image rotation and other functions.
Usage demonstration:
//Load class library file
require_once 'path /to/ThumbLib.inc.php';
//Instantiate the class library, the address of the image you want to process can be a network address or a local address
$thumb = PhpThumbFactory::create('http://www.jb51.net /');
//Reduce the image proportionally to the maximum width of 100px or up to 100px. When only one parameter is entered, it is the widest size limit.
$thumb->resize(100, 100);
//Reduce the image to the original percentage, for example, 50 is 50% of the original.
$thumb->resizePercent(50);
//Intercept a 175px * 175px picture. Note that this is an interception, and the excess part is directly cropped, not forced to change the size.
$thumb->adaptiveResize(175, 175);
//Calculate from the center of the image and intercept the 200px * 100px image.
$thumb->cropFromCenter(200, 100);
//Screenshot, the first two parameters are the coordinates X and Y of the upper right corner of the picture to be solved. The next two parameters are the width and height of the image that needs to be solved.
$thumb->crop(100, 100, 300, 200);
//Reverse the image 180 degrees clockwise
$thumb->rotateImageNDegrees(180);
//Save (generate) the image, you can save it in other formats, please refer to the document for details
$thumb->save( 'NewPath/Of/image.jpg ' );
This class library has more functions, so I won’t introduce them in detail. If you also need to process images when developing a PHP website, you may wish to read the documentation of this class library to ensure that it is very simple for you to process images, and you no longer have to deal with images. Dealing with those dozen annoying php image processing functions!
Another powerful PHP image thumbnail class: phpThumb
In addition to scaling images, this class can also convert images into different formats for output (such as outputting images in GIF format to PNG format). Its special features also include color, special effects, etc.
Official website: http: //phpthumb.sourceforge.net/
Generally you only need the following file:
[code]We'll be using phpThumb, the open source PHP script to generate thumbnails on the fly.
Download and extract phpThumb to somewhere in your website folder. Now to use a rounded corner thumbnail of an image, simply use the img tag of HTML with src as
Adjust the path to phpThumb according to where you place the phpThumb files.

[code]
In fact, the function of phpThumb is more powerful than I originally thought. Here are some other useful parameters List it out:
src: the address of the target image
w: the width of the output image
h: the height of the output image (if not specified, it will be scaled equally according to the w parameter)
q: output if It is in JPG format, and its output quality can be specified
bg: background during output (if needed)
sw, sh, sx, sy: partial output, width, height, starting position
f: output Format, can be jpeg, png, gif, ico
sfn: output a certain frame in the gif animation
fltr[]: filter, which can have many effects, including sharpening, blurring, rotation, watermark, Borders, masking, color adjustments, etc.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Using Imgscalr for image processing in Java API development With the development of mobile Internet and the popularity of Internet advertising, images have become an indispensable element in many applications. Whether it is displaying products, building social circles, or enhancing user experience, images play an important role. In applications, it is often necessary to perform operations such as cropping, scaling, and rotating images, which requires the use of some image processing tools. Imgscalr is a very commonly used image in Java API development.

Golang image processing: How to perform color gradient and grayscale mapping of images Introduction: With the development of digital media, image processing has become an indispensable part of our daily life. In the Go language, we can use some libraries for image processing, such as github.com/disintegration/imaging. This article will introduce how to use this library to perform color gradient and grayscale mapping of images. 1. Introduce the library First, we need to introduce github.com/ in the Go project

Overview of how to use Golang to enhance borders and edges on images: In the field of image processing, border and edge enhancement is a commonly used technique that can effectively improve the visual effects of images and improve the accuracy of image recognition. This article will introduce how to use Golang language to perform border and edge enhancement operations on images, and provide corresponding code examples. Note: This article assumes that you have installed and configured the Golang development environment in your local environment. Import dependency packages First, we need to import the following dependency packages for image processing operations

Laravel Development Suggestions: How to Optimize Image Processing and Caching Introduction In modern web development, image processing and caching is a common and important issue. Optimizing image processing and caching strategies not only improves website performance and user experience, but also reduces bandwidth consumption and server load. This article will explore methods and suggestions on how to optimize image processing and caching in Laravel development. 1. Choose the appropriate image format Choosing the appropriate image format is the first step in optimizing image processing. Common image formats include JPEG and PNG

How to use Python to add noise to pictures Introduction: With the development of technology, digital image processing has become a common image processing method. Among them, adding noise to the image is an important step in image processing. By adding noise, the realism and complexity of the image can be improved. This article will introduce how to use Python to add noise to images and provide relevant code examples. 1. Understanding image noise Image noise refers to random disturbances that affect image quality and clarity. Common image noises include Gaussian noise,

How to use Golang to mask and mask effects on pictures In modern image processing, masking and masking effects are very common special effects. This article will introduce how to use Golang to mask and mask effects on images. Installing the Necessary Libraries Before we start, we need to install some necessary libraries to process images. Run the following command to install the necessary libraries: goget-ugithub.com/fogleman/gggoget-ugolang.org/x/im

How to handle image caching and preloading in Vue? When developing Vue projects, we often need to deal with caching and preloading of images to improve website performance and user experience. This article will introduce some methods of handling image caching and preloading in Vue, and give corresponding code examples. 1. Image caching uses image lazy loading (LazyLoading) Image lazy loading is a technology that delays loading images, that is, the image is not loaded until the page scrolls to the location of the image. This reduces requests for image resources when the page is first loaded

How to use PHP to blur images Image blurring is a common operation in image processing, which can add a blur effect to the image to make it look softer and more artistic. In PHP, we can use the GD library to blur images. The following will introduce how to use PHP to blur images, and attach corresponding code examples. Installing the GD library Before starting, you need to make sure that your server has the GD library installed. You can do this by adding the phpinfo() function to your PHP file
