Use ImageMagick in PHP to achieve old photo effects

Source: Internet
Author: User
Tags imagemagick

ImageMagick is a picture processing software with powerful image processing capabilities. This article uses PHP call ImageMagick to implement the image processing as an old photo effect.

ImageMagick Address: www.imagemagick.org
To install ImageMagick, the installation method is as follows: Click to view
using ImageMagick to generate an old photo effect, you need to follow these steps
1. Use the Sepia-tone filter to process the input image
2. Generate a white mask, fill random noise, convert to grayscale, and add alpha channel
3. Use overlay for the results of steps 1 and 2 as follows compose
The code is as follows:

<?php/** * PHP call ImageMagick implement old photo effects  * Date:    2016-12-31 * Author:  fdipzone * Ver:     1.0 *//** * Call Imagema Gick achieve old photo effects * @param string $source original * @param string $dest   destination Figure */function Createoldphoto ($source, $dest) {    //command line    $cmd = sprintf ("Convert '%s '-sepia-tone ' 75%% ' \ ('%s '-fill ' #FFFFFF '-colorize ' 100%% ' +noise random-colorspace g Ray-alpha on-channel a-evaluate Set []-compose overlay-composite '%s ', $source, $source, $dest);    Execute command    exec ($cmd);} Original $source = DirName (__file__). ' /source.jpg ';//Generate $dest = DirName (__file__). ' /dest.jpg ';//Create Createoldphoto ($source, $dest);//display original and compare echo ' <meta http-equiv= ' content-type ' content= ' text/html Charset=utf-8 ">", Echo ' <p> artwork </p> '; Echo ' <p></p> '; Echo ' <p></p> '; Echo ' <p></p> ';? >


Compare the original image with the resulting old photo effect

This article explains the use of PHP ImageMagick to achieve the old photo effect, more relevant content please pay attention to the PHP Chinese web.

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.