Commonly used image processing tools are gd,imagemagick,graphicsmagick and so on. GD is a fools, skip to mention; ImageMagick is currently the most popular image processing tool, its function is very rich; GraphicsMagick's function is slightly less than ImageMagick, but it's more efficient, like Apache and Nginx, A more powerful, more efficient one.
It's more about efficiency now, so this article takes GraphicsMagick as an example:
For Phper, there are two ways to use GraphicsMagick:
1: Use pecl gmagick extension.
2: Use the GraphicsMagick command line.
I don't like the way the pecl expands. One pecl code bugs a lot, and then pecl extension of the implementation of the code to write very verbose: such as scaling an animated GIF picture, if you use the way of command line, and a word is done, and with pecl expansion, you have to calculate the animation has a few frames, and then cycle processing, Very troublesome. So I am more inclined to use the command line, although the command line operation sounds very "heavy", but if set up a number of image servers, through the Gearman connected, in fact, very flexible.
Let's take GraphicsMagick as an example, using the command line to see how to use the thumbnail feature:
First the original picture (input.jpg:160x120), which will be used in future examples:
The actual picture size is: 100x75, which means that by pressing this command, the picture is kept unchanged to generate thumbnails. This is good, but there is a potential problem: we can not simply know the final size of the picture, the result is the front of the display, can not set the IMG tag width and Height properties, if I remember correctly, is generally recommended to set the width and Height properties, Otherwise the browser may be slightly slower to render.
This time not only guarantees the size, but also guarantees the proportions, without any cropping of the picture, and the extra parts are filled in the specified color.
This time, the size and proportions are guaranteed, 10000 of which is the product of the 100x100, and a balance is made between padding and cropping.
Understand the above examples, thumbnails are basically all in all, there must be one that will suit your needs. GraphicsMagick's data is very small, but the good news is that GraphicsMagick and ImageMagick are basically compatible, so you can use the ImageMagick data to apply.
Add: Imgareaselect is a good choice if you want users to manually crop the headers.
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.