
- PHP ImageMagick - Home
- PHP ImageMagick - Introduction
- Background Color
- Image Reflections
- Image Cropping
- Image Bordering
- Image Resizing
- Composite Images
- Contrast & Brightness
- Enhancing &Equalizing
- Sharpening & Blurring
- Image Tiling
- Image Threshold
- Modifying Colors
- Different effects
- Securing The Images
- Simulation Of Sketches
- Editing TheAppearance
- Rotation and Rolling
- Splicing & Spreading
- Miscellaneous Functions
- PHP ImageMagick Useful Resources
- PHP ImageMagick - Quick Guide
- PHP ImageMagick - Resources
- PHP ImageMagick - Discussion
PHP ImageMagick - Simulation Of Sketches
In this chapter, you will be learning to simulate different types of sketches using a few inbuilt functions provided by Imagemagick.
Simulating a Charcoal Drawing
ImageMagick provided a method called charcoalImage() which produces the charcoal drawing of the input image.
Syntax
public Imagick::charcoalImage(float $radius, float $sigma): bool
This function takes 2 parameters: radius and sigma.
Radius is a float value that specifies the radius of the Gaussian (in pixels), not counting the center pixel.
Sigma is also a float value that specifies the standard deviation of the Gaussian, in pixels.
Example
This is an example which shows the implementation of charcoalImage() function. At first, a new imagick object is created and an image is taken as input. Then, charcoalImage() function is applied on that image. The required output is obtained in the form of charcoalImage.png.
<?php $image=new Imagick($_SERVER['DOCUMENT_ROOT']."/test/image.png"); $image->charcoalImage(2, 2); $image->writeImage($_SERVER['DOCUMENT_ROOT']."/test/charcoalImage.png"); ?>
Assume that the following is the input image (image.png) in the program −

Output

Simulating a Pencil Sketch
There is an inbuilt function called sketchImage() provided by Imagemagick which produces the pencil sketch of the input image.
Syntax
public Imagick::sketchImage(float $radius, float $sigma, float $angle): bool
This function consists of 3 parameters: radius, sigma, and angle. These are float values. Radius specifies the radius of the Gaussian (in pixels), sigma specifies the standard deviation of the Gaussian (in pixels) and angle specifies the angle by which the effect must be applied and specifies the angle of the blurring motion.
Example
This is an example which shows the implementation of sketchImage() function. At first, a new imagick object is created and an image is taken as input. Then, sketchImage() function is applied on that image. The required output is obtained in the form of sketchImage.png.
<?php $image=new Imagick($_SERVER['DOCUMENT_ROOT']."/test/image.png"); $image->sketchImage(11, 11, 30); $image->writeImage($_SERVER['DOCUMENT_ROOT']."/test/sketchImage.png"); ?>
Assume that the following is the input image (image.png) in the program −

Output

Simulating an Oil Painting
Oil painting is a type of painting produced using oil-based paints. Without using oil paints in real, this oil painting can be simulated using an inbuilt function oilPaintImage() of Imagemagick in PHP.
Syntax
public Imagick::oilPaintImage(float $radius): bool
This function contains only one parameter which is radius which is a float value. It specifies the radius of the circular neighborhood. This function takes an image as input and applies a special effect filter that simulates an oil painting and produces that as output.
Example
This is an example which shows the implementation of oilPaintImage() function. At first, a new imagick object is created and an image is taken as input. Then, oilPaintImage() function is applied on that image. The required output is obtained in the form of oilPaintImage.png.
<?php $image=new Imagick($_SERVER['DOCUMENT_ROOT']."/test/image.png"); $image->oilPaintImage(2); $image->writeImage($_SERVER['DOCUMENT_ROOT']."/test/oilPaintImage.png"); ?>
Assume that the following is the input image (image.png) in the program −

Output
