Php and imagemagick are used to process Upload and zoom of image files. _ PHP Tutorial

Source: Internet
Author: User
Tags imagemagick
Php and imagemagick are used to process the upload and zoom (posting) of image files ). It is easy to use php and imagemagick to process the upload and scaling of image files. However, if you want to scale the uploaded image, although G can be used with php and imagemagick to process Upload and zoom of image files
Php is very easy to process file uploads. However, if you want to scale the uploaded image, you can use GD,
Complicated processing is required. ImageMagick is an image processing package, which is available in common Linux software packages. It contains
The multi-processing image tool can convert the image file format and perform various processing on the image.
Image scaling function. This is implemented through convert, a tool in its software package, so as to call
Convert-geometry width x High source file scaled file

Create an images directory in the current directory and enable users to write images on the web. this directory is used to store uploaded images and
The scaled image.
Below is a simple example, including image upload and processing. the test passes in RedHat6.0 + php3.0.12.
Uploadform.html: file upload form
<HTML>
<HEAD>
<TITLE> select a file </TITLE>
</HEAD>
<Body align = "CENTER">
<Form enctype = "multipart/form-data" ACTION = "upload. php3" METHOD = POST>
Select an image file: <input name = "image" TYPE = "file">
<Input type = "submit" VALUE = "Send File">
</FORM>
</BODY>
</HTML>
Upload. php3: process uploaded image files
<Html>
<Head>
<Title> processing </title>
</Head>
<Body>
<〈?
$ Flag = "true ";
If (isset ($ image) & $ image &&
($ Image_type = "image/gif" | $ image_type = "image/png"
| $ Image_type = "image/pjpeg") {// you can specify the format of the uploaded file.
$ Dest_image = "./images/". $ image_name;
If (@ copy ($ image, $ dest_image) {// copy the uploaded file to the images Directory
$ Small_image = "./images/small". $ image_name;

Php is very easy to process file uploads, but if you want to scale the uploaded image, although G...

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.