Home >Backend Development >PHP Tutorial >Use php and imagemagick to handle uploading and scaling of image files (repost)_PHP tutorial

Use php and imagemagick to handle uploading and scaling of image files (repost)_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:03:481079browse

Use php and imagemagick to handle uploading and scaling of image files
It is very simple to upload files with php, but if you want to scale the uploaded images, although you can use GD to do it,
you need Perform more tedious processing. ImageMagick is an image processing package that is available in most Linux software packages. It contains many
tools for image processing. It can convert image file formats and perform various processing on images. Among them, we will use its
image scaling function. This is achieved through the convert tool in its software package. In this way, call
convert -geometry width x height source file scaled file

Please create an images directory in the current directory, and it can Make it writable by the web execution user. This directory is used to store uploaded images and
zoomed images.
The following is a simple example, including image uploading and processing, which was tested under RedHat6.0+php3.0.12. > ">
〈FORM ENCTYPE="multipart/form-data" ACTION="upload.php3" METHOD=POST>
Select image file: 〈INPUT NAME="image" TYPE="file">
〈INPUT TYPE="submit" VALUE="Send File">
〈/FORM>
〈/BODY>
〈/HTML>
upload.php3: Process the uploaded images File
";
if(isset($image) && $image &&
        ($image_type = "image/gif" || $image_type = "image/png" ")){ //Determine the format of the uploaded file, etc.
$dest_image = "./images/".$image_name;
if(@copy($image,$dest_image)){ //Copy the uploaded file to Under the images directory
$small_image = "./images/small".$image_name;





http://www.bkjia.com/PHPjc/445276.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/445276.html

TechArticle

Using php and imagemagick to handle the uploading and scaling of image files. It is very simple to use php to handle the uploading of files, but If you want to scale the uploaded images, you can use G...

Statement:
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