How to use PHP to process images in a Linux environment

Source: Internet
Author: User
Tags linux

Using PHP to create images is a fairly easy thing to do. As long as you install some Third-party library files and have some knowledge of geometry, you can use PHP to create and process images. PHP currently uses the GD library to process images. Some image functions can be used directly in PHP, but most functions need to install the GD function library. The GD library provides a series of functions for drawing, using colors, processing stored images, and filling operations. The GD library is written by Thomas Boutell in the ANSI C language, while supporting the mapping of Perl and Tcl languages. Since GD is a library that can be built into shared or static, it is very easy to use the GD library for image manipulation in PHP. GD Image Library Working principle see figure 1.

Figure 1 PHP Image invocation principle

GD Library is currently maintained by Boutell company, the official web site is: http://www.boutell.com/gd/, the latest version of this article is: November 03, 2004, 4 released GD 2.0.33.

A. PHP supported image formats and fonts

The GD library version of PHP supports the following image formats and fonts:

1.PNG

PNG (Portable Network Graphics) is a bitmap file format that stores 32-bit information, and its image quality is much better than GIF. Like GIF, PNG also uses lossless compression to reduce the size of the file. When compressing bitmap data, it uses a variant of the highly acclaimed L Z77 algorithm. At present, more and more software is starting to support this format, in the near future, it may be widely popular throughout the Web. The PNG image can be a grayscale (16-bit) or color (48-bit) or 8-bit indexed color. The PNG image uses a high-speed alternating display scheme that is fast enough to display a low-resolution preview image with only 1/64 of the image information to be downloaded. Unlike GIF, the PNG image format does not support animations. PNG is the true province of PHP support image format.

2.JPEG

JPEG (Joint Photographic Expert Group) is a 24-bit image file format and is an efficient compression format, the file format is the JPEG (joint Image Expert Group) standard Product, The standard, developed by ISO and CCITT (International Telegraph and Telephone Advisory Committee), is a compression standard for continuous-tone still images. Its original purpose is to use 64Kbps communication lines to transmit 720x576 resolution compressed images. By losing very little resolution, you can reduce the amount of storage required for an image to 10% of its original size. Because of its efficient compression efficiency and standardization requirements, has been widely used in color fax, still images, conference calls, printing and news pictures of the transmission. However, the deleted data can not be restored in the decompression, so the JPEG file is not suitable for enlarged viewing, output to print when the quality will be affected. In general, JPEG files are only dozens of KB, and the highest number of colors can reach 24 bits, so it is widely used on the Internet to save valuable network transport resources.

3.WBMP

WBMP (Wireless Bitmap), a wireless bitmap, is an image format designed for mobile communications devices such as mobile phones and PDAs. This format is used for wireless Communication Protocol (WAP) Web pages. WBMP is a 1-bit format, so only two colors are visible: black and white.

4.XBM

XBM (X BitMap) is a graphics file format. is an old but common image file format that is compatible with many of today's web browsers. The X-windows graphical interface (Unix and Linux common GUI) has a component in the C code library Xlib that specifically describes its specification. The XBM format was originally designed to store monochrome system bitmaps, such as icons and mouse pointers. The XBM graph is essentially a C source code file that uses a 16 binary array to represent binary images. X-bitmaps is an interesting choice for generating simple web graphics, and it doesn't require anything else, as long as it has a browser to work with.

5.GIF

GIF (Graphics Interchange Format) is a compressed graphic file format that can be processed on various graphics processing software on various platforms. The data in GIF files is a lossless compression format for continuous tones based on the LZW algorithm. Its compression rate is generally around 50%, it does not belong to any application. At present, almost all of the relevant software support it, the public domain has a large number of software in the use of GIF image files. Because of the Unisys company patent reason (the LZW algorithm used in GIF format involves Unisys's patent) PHP once it does not support GIF format. If you like this format very much, you can download this earlier version in http://www.linuxguruz.org/downloads/gd1.3.tar.gz but it is not recommended. For more information on the GIF format patent issue, please see the page: http://lpf.ai.mit.edu/Patents/Gif/Gif.html.

6. TrueType Fonts

TrueType is the scalable font that both print and screen apply to. First developed by Apple, it is the main font type on the computer today. Bitmap fonts can only display proportions in their single fixed size, and TrueType fonts display proportions in three different sizes.

7. PostScript fonts

PostScript, first developed by Adobe, is a page description language that describes the location and appearance of graphics and text output (usually to PostScript printers). PostScript printers can open text created by any type of font, but to maximize the performance of PostScript, users need dedicated PostScript fonts. PostScript fonts are often referred to as printer fonts.

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.