PHP generated image thumbnail class code sharing based on GD2 graphics library
This article mainly introduces the PHP generated image based on the GD2 graphics library thumbnail class code sharing, this article directly give the implementation code
A perfect solution for low image quality caused by creating thumbnails in PHP. Recently, a forum will be created. The top 10 users with the most comments will be listed on the homepage, A thumbnail in the list is the latest file uploaded by the user.
Php Tutorial program for generating thumbnails by proportional ratioThis program is very practical, but it is only used to generate thumbnails in proportion. You need to upload the file to the server and then operate it using this function. If you
Header ("Content-type: image/jpeg ");$ Filename = 'book_rabbit_rule.jpg ';/* Read the image file */$ Im = imagecreatefromjpeg ($ filename );/* How much image is to be cut, length/width */$ New_img_width = 120;$ New_img_height = 42;/* Create a new
Copy Code code as follows:
/**
* Basic image processing, to complete the image indentation, watermark add
* When the watermark map exceeds the target picture size, the watermark can be automatically adapted to the target image and reduce
*
The code is as follows
Copy Code
uploads.php file Class image_upload{Private $srcimg; Original picturePrivate $destimg; Target picturePrivate $width; The width of the original picturePrivate $height; The height of the original
?
/*** Generate watermark, call to generate watermark text and watermark picture two methods*/function _createmask (){if ($this->mask_word){Get font information$this->_setfontinfo ();if ($this->_isfull ()){Die ("Watermark text too
PHP to generate thumbnail images:
To use PHP to generate thumbnail images, make sure your PHP server has the GD2 graphics library installed
Use a class to generate a thumbnail of the picture, the source of the class is shown below
Calling methods
Just learn PHP soon, in a project to build a step-by-step accumulation and learning, hope to share the things others can bring help, less detours.PHP/** * Picture Operation class * @author Harlan Song*//** * Compress the picture, to the width of the
To use PHP to generate thumbnail images, make sure your PHP server has the GD2 graphics library installed
Use a class to generate a thumbnail of the picture, the source of the class is shown below
Calling methods of this class:
$resizeimage =
PHP tutorial generates thumbnail classes that support custom high and wide. Also supported by high and wide screenshots
Class Resizeimage{Picture typevar $type;Actual widthvar $width;Actual heightvar $height;The width after the changevar $resize
Class Resizeimage {
Picture type
var $type;
Actual width
var $width;
Actual height
var $height;
The width after the change
var $resize _width;
Change the height of the post
var $resize _height;
Whether or not to cut the map
var $cut;
Source
Someone has previously published a method to use the PNG image compression function. The IDAT chunks structure of PNG is used to fill a webshell with a single sentence. For a set of Modulo operations,
Image operations are widely used on websites, especially when the Internet is highly developed. Many content is displayed in images. Now let's talk about using php to operate uploaded images, 3D image rendering, image scaling, image rotation, image
The method for creating thumbnails in php is also very simple. It is to use imagecopyresampled to create a smaller image based on the source image. Let's look at the code check_image_addthumbs.php? Php changes image effects $ dbmysql_connect
This article mainly introduces PHP generation of proportional thumbnails class and user-defined function sharing, respectively encapsulated into a class and user-defined function. For more information, see
This article mainly introduces PHP
PHP crop an image, which is generally the imagecopyresampled () function. By default, the image is cut from the upper left corner. After reading the code of cutting the image from the middle corner on the Internet, it is very complicated. In fact,
A realization of the generation of the implementation of the small graph function code, there is a need for friends to refer to, each has a detailed description of the parameters.
The code is as follows
Copy Code
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.