”;
In this chapter, you will be learning to tile a texture image repeatedly. Tiling a texture image is the process of creating a pattern in which the texture image is repeated which is in the form of tiles.
With ImageMagick, you can easily tile an image into equal-sized pieces. You can also adjust the size and orientation of each piece, allowing you to customize your tiled image however you want. In this tutorial, we”ll explain how to use PHP ImageMagick”s Image tile to achieve perfect results in creating stunningly beautiful tiled images!
Syntax
Imagick::textureImage(Imagick $texture_wand): Imagick
This function consists of one parameter
-
‘texture_wand’. It is an Imagick object that is used as a texture image.
-
New image creation − It involves the creation of a new image using the function ‘newImage()’ which takes the column size and row size as arguments. Hence, an image with those measurements is created.
-
Scaling the image − A function ‘scaleImage()’ is used to scale the image to a particular dimension and the image is shortened with those dimensions and hence can be tiled on the new image that we created.
The below example is a program to tile the images. This program has a few additional are used other than ‘textureImage()’.
This function takes the image as input and the output obtained is the image that contains the pattern of tiles of texture images.
Example
Below example shows the implementation of the ‘textureImage()’ function. Here, a new Imagick object is created with the specified measurements and color as parameters.
-
The image format is also set. Then, an image is taken as input by creating a new Imagick object.
-
Now, the image is scaled to some specific dimension using the ‘scaleImage()’ function.
-
The scaled image is continuously tiled on the new image that is created in the beginning using the ‘textureImage()’ function.
-
The final output is obtained in the form ‘textureImage.png’.
<?php $img=new Imagick(); $img->newImage(940, 670, new ImagickPixel(''red'')); $img->setImageFormat("jpg"); $image=new Imagick($_SERVER[''DOCUMENT_ROOT'']."/test/image.jpeg"); $image->scaleimage($image->getimagewidth() / 8, $image->getimageheight() / 8); $img=$img->textureImage($image); $image->writeImage($_SERVER[''DOCUMENT_ROOT'']."/test/textureImage.png"); ?>
Assume that the following is the input image (image.jpeg) in the program −
Output
”;