How to use timthumb to generate thumbnails in php, timthumb thumbnails_PHP tutorial

WBOY
Release: 2016-07-12 09:00:12
Original
814 people have browsed it

How PHP uses timthumb to generate thumbnails, timthumb thumbnails

The example in this article describes how PHP uses timthumb to generate thumbnails. Share it with everyone for your reference, the details are as follows:

There are two ways to generate thumbnails:

1. Generate it in advance for calling

The common practice for thumbnails is to start with how many types of thumbnails you want to generate based on the image specifications on the website. The thumbnails will be generated during the image upload process for different needs. One disadvantage of this method is that if you increase the image specifications, the previously uploaded images do not have the specifications and will have to be regenerated.

2. Generate thumbnails when calling. This is why I wrote this article.

I recommend timthumb. Personally, I think this thing is definitely easy to use without considering performance and efficiency.

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

2. How to use

After downloading, put it in your web environment, create a cache folder in the directory parallel to timthumb.php, and give it 755 permissions. If you are using Windows, you don’t need it. The test code is as follows:

<&#63;php
$image = "http://localhost/test/pen_pic03.png";
&#63;>
<html>
<head>
<title>timthumb</title>
</head>
<body>
 <img src="http://localhost/test/timthumb.php&#63;src=<&#63;php echo $image; &#63;>&w=58&h=46&zc=1" alt="" />
</body>
</html>

Copy after login

Parameter description:

w=58 means the image width is 58
h=46 means the image height is 46

You can set it up as needed.

The biggest advantage of timthumb is convenience. I have not encountered such a tool so far. The shortcomings are equally obvious. Every time a request is made, php-cgi or php-cli will be called, and the cached data will be placed in the cache directory. When calling data, you have to search the directory, and the performance will be relatively low.

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • php upload images to generate thumbnails (GD library)
  • Detailed explanation of examples of php generating high-definition thumbnails
  • Using PHP How to generate image thumbnails
  • How to simply generate thumbnail albums in PHP
  • How to batch generate image thumbnails in PHP
  • php uses GD library to create image thumbnails Method
  • PHP method to dynamically generate thumbnails and output the display
  • Thinkphp method to call the Image class to generate thumbnails
  • PHP based on GD2 graphics library to generate image thumbnail class code Share
  • How to generate multiple thumbnails in thinkphp3.2.2

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1094745.htmlTechArticleHow to use timthumb to generate thumbnails in php, timthumb thumbnails This article describes how to use timthumb to generate thumbnails in php . Share it with everyone for your reference, the details are as follows: Generate...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template