Sample code for PHP to generate thumbnails using Timthumb

Source: Internet
Author: User
Timthumb is a very concise and easy to use in the layout of the PHP program, as long as you set some parameters, it can generate thumbnails. Now many WordPress theme, use Timthumb this PHP class library for thumbnail image processing. This article mainly introduces PHP using Timthumb to generate thumbnails of the method, the example analysis of PHP call Timthumb generated thumbnail operation skills and related considerations, the need for friends can refer to, specific as follows:

There are two ways to generate a indented graph:

First, the early generation of good, for the call

The general practice is to start based on the image specifications in the site, how many kinds of indented graph to generate, the image upload process will generate indentation, for different needs to call. A little bit like this method is, if you add the image specifications, the previously uploaded pictures do not have the specifications, but also to regenerate.

second, when the call is generated in the indented graph . That's why I'm writing this article.

Recommend a timthumb, personally feel that in the case of performance, efficiency, this thing, is absolutely easy to use.

1, download Address: http://timthumb.googlecode.com/svn/trunk/timthumb.php

2, how to use

After downloading, put in your web environment, in a directory parallel to the timthumb.php to build a cache folder, give 755 permissions, Windows, it is not. The test code is as follows:

<?php$image = "Http://localhost/test/pen_pic03.png";? >

Parameter description:

W=58 indicates a picture width of 58
H=46 indicates a picture height of 46

Can be set casually as needed.

Timthumb The biggest advantage is the convenience, has not encountered such a tool, the shortcomings are equally obvious, each time the request, will call php-cgi or PHP-CLI, the cached data in the cache directory, call data to find the directory, the performance will be relatively low.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.