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.