To round corners of an image you should use the roundCorners() method: WideImage_Image roundCorners( int $radius,, , ) - Returns an image with round corners Next listing shows the effect of the above three methods: rotate(15) WideImage_Image flip( ) - Returns a flipped (mirrored over horizontal line) copy of the image WideImage_Image mirror( ) - Returns a mirrored copy of the image To rotate, mirroring or flipping an image you need to use the below methods: WideImage_Image rotate( int $angle,, ) - Rotate the image for angle $angle clockwise. The output image after the adding circles and text is: adding the '2016' text on the bottom of the image with the font Arial and size 16 drawing six circles of different colors and positions on the image 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.
Parameters: mixed $source File name, url, HTML file input field name, binary string, or a GD image resource. This function checks the input and decides whether to use WideImage::loadFromHandle(), WideImage::loadFromFile(), WideImage::loadFromUpload() or WideImage::loadFromString(): 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.