”;
Creating a 3D Effect
A picture that appears to be having height, width, and depth is called a 3-dimensional(3D) picture. 3D images provide a realistic replica of the object to the users.
To create this effect directly on the server, Imagemagick offers an inbuilt function called ”shadeImage()”. This is handy and it is capable of transforming standard 2D images into high-quality 3D renderings with ease.
Syntax
public Imagick::shadeImage(bool $gray, float $azimuth, float $elevation): bool
This function takes 3 parameters: gray, azimuth, and elevation.
-
Gray is a Boolean value that is used to shade the intensity of each pixel.
-
Azimuth’ and ‘elevation’ are float values that define the light source directions off the x-axis and above the z-axis respectively.
For creating a 3D effect, the amount of light and the direction of light is mainly considered. This function the image as input and produces the image with a 3D effect as output.
Example
This example shows the use of the ”shadeImage()” function In here, an Imagick object is created and an image is passed as input. The ”shadeImage()” function is then called with gray value, azimuth value, and elevation supplied as parameters.
<?php $image=new Imagick($_SERVER[''DOCUMENT_ROOT'']."/test/image.png"); $image->shadeImage(true, 50, 30); $image->writeImage($_SERVER[''DOCUMENT_ROOT'']."/test/shadeImage.png"); ?>
Assume that the following is the input image (image.png) in the program −
Output
Creating a Solarizing Effect
The effect that is seen when the photographic film is extremely overexposed is called as the solarize effect. To create that effect in PHP, there is an inbuilt function ‘solarizeImage()’ provided by Imagemagick.
This effect results in an image with reversed tones, where the highlights become dark and vice versa.
Syntax
public Imagick::solarizeImage(int $threshold): bool
This function takes ‘threshold’ as a parameter. It is an integer value that is used to measure the extent of the solarizing effect.
Example
This example shows the implementation of ‘solarizeImage()’ function. A new imagick object is created and image is taken as input. Now,
‘solarizeImage()’
function is applied with a threshold value as its parameter and the output image obtained is in the form ‘solarizeImage.png’.
<?php $image=new Imagick($_SERVER[''DOCUMENT_ROOT'']."/test/imagee.png"); $image->solarizeImage(0.3); $image->writeImage($_SERVER[''DOCUMENT_ROOT'']."/test/solarizeImage.png"); ?>
Assume that the following is the input image (image.png) in the program −
Output
Creating a Wave Filter Effect
Imagemagick has provided an inbuilt function called ‘waveImage()’ which helps in simulating a wave filter on an image. It takes an image as input and the output obtained is the image with a wave filter.
Syntax
public Imagick::waveImage(float $amplitude, float $length): bool
This function has two parameters: amplitude and length.
-
Amplitude specifies the amplitude of the wave.
-
length specifies the length of the wave.
Example
This is an example which shows the implementation of ‘waveImage()’ function. At first, a new imagick object is created and an image is taken as input. Then, ‘waveImage()’ function is applied on that image. The required output is obtained in the form of ‘waveImage.png’.
<?php $image=new Imagick($_SERVER[''DOCUMENT_ROOT'']."/test/image.png"); $image->waveImage(2, 4); $image->writeImage($_SERVER[''DOCUMENT_ROOT'']."/test/waveImage.png"); ?>
Assume that the following is the input image (image.png) in the program −
Output
Creating a Swirl Effect
In this chapter, you will be learning to swirl an image. Generally, swirling means to move quickly with a twisting or a circular movement. The image that contains this type of effect is called a swirled image. Creating a swirl image manually is difficult. But, to make this easier, Imagemagick has provided an inbuilt function ‘swirlImage()’ which swirls the pixels about the center of the image.
Syntax
Imagick::swirlImage(float $degrees): bool
This function takes in a single parameter: degrees. ‘Degrees’ is a float value that indicates the sweep of the arc through which each pixel is moved. By this, you get a more dramatic effect as the degrees move from 1 to 360.
Example
In the below example, you first create a new imagick object and input an image. Then, ‘swirlImage()’ function is applied by specifying the degrees(degrees=200). And finally, that swirled image is obtained as output.
<?php $image=new Imagick($_SERVER[''DOCUMENT_ROOT'']."/test/imagee.png"); $image->swirlImage(200); $image->writeImage($_SERVER[''DOCUMENT_ROOT'']."/test/swirlImage.png"); ?>
Assume that the following is the input image (image.png) in the program −
Output
”;