

In the next example we will add six different colored circles and an Arial text with the dimension 16 placed on the bottom of image and centered: getCanvas() Using WideImage library we can also draw text and shapes on the image using the Canvas object, returned by the getCanvas() method. The output image of merging the two above images is: Next example merge the test.jpg image and snowflake.jpg by laying the snowflake.jpg onto the test.jpg on different position and opacity: merge($watermark, 'center', 'bottom – 10', 70) $cropped = $image->crop('center', 'center', 200, 250) įor merging an image using the WideImage library, use the merge() method, with the following syntax: WideImage_Image merge( WideImage_Image $overlay,, , )- This method lays the overlay (watermark) on the image. The next listing crops a 200×250 rectangle part from the center of our test.jpg image: crop('50%-100', '50%-125', 200, 250) The result of running the above listing is:įor cropping an image using the WideImage library, we use the crop() method, with the following syntax: WideImage_Image crop(, ,, ) - and returns a cropped rectangular portion of the image. To save an image to file use the saveToFile() method: resize(200, 100) The below example resizes the test.jpg image, using the numeric and percent coordinates and saves the new images into a file.

Static WideImage_Image load( mixed $source) The load() method has the following syntax: Loading an imageīefore performing different operations on the images using the WideImage library, we need first to load an image – and for that we use the load() method that loads an image from a file, URL, HTML input file field, binary string, or a valid image handle. It also supports BMP (read/write) and TGA (read only). It requires PHP 5.2+ with GD2 extension WideImage supports all formats that are natively supported by the GD extension on the server (this currently includes GIF, PNG, JPG, GD, GD2, WBMP, XBM, XPM).

WideImage is an object-oriented library for image manipulation that provides a simple way of loading, manipulating and saving images in the most common image formats.
