Php uploads images and uses ImageMagick to generate thumbnails. _ PHP Tutorial

Source: Internet
Author: User
Tags imagemagick learn php programming
Php uploads images and uses ImageMagick to generate thumbnails ,. Php uploads images and uses ImageMagick to generate thumbnails. with ImageMagick, you can easily and quickly create thumbnails, which is much easier than using PHP. PhpLocationtoupload php uploads images and uses ImageMagick to generate thumbnails,

With ImageMagick, you can easily and quickly create thumbnails, which is much easier than using PHP.

<?php// Location to upload main image:$mainDir = $_SERVER['DOCUMENT_ROOT'].'/images/l/';// Location to create the thumb image:$smalDir = $_SERVER['DOCUMENT_ROOT'].'/images/s/';// Command to use:$command = '/usr/bin/convert';// Thumbnail width:$size = 210;// Make sure we have an image:if(isset($_POST['submit'])){if(getimagesize($_FILES['photo']['tmp_name'])){$name = $_FILES['photo']['name'];$uploadfile = $mainDir . $name;move_uploaded_file($_FILES['photo']['tmp_name'], $uploadfile);$lrgImg = $mainDir . $name;$smlImg = $smalDir . $name;$imageMagick = $command . " '". $lrgImg . "' -resize '$size' '" . $smlImg . "'";shell_exec($imageMagick);}header("Location: /test.php");exit;}else{?><?phpforeach(glob($smalDir.'*') as $img){echo '  ';}}?>

I hope this article will help you learn php programming.

Articles you may be interested in:
  • PHP image upload class with image display
  • Simple PHP image upload program
  • Php image upload code
  • An extremely useful php image upload class (random name, thumbnail, and watermark)
  • PHP image upload code
  • PHPThumb PHP image thumbnail library
  • Thinkphp implements image upload function sharing
  • The thumbnails generated using the imagemagick and gd libraries are supported in php.
  • Php multi-file and image upload examples

Using ImageMagick, you can easily and quickly create thumbnails, which is much easier than using PHP. Php // Location to upload...

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.