whichlasas.blogg.se

Php wideimage
Php wideimage




php wideimage

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.

  • Complex coordinates (are the combination of the above ones): $cropped = $image->crop('100%-70', '100%-50', 60, 40) Resizing an imageįor resizing an image using the WideImage library, we use the resize() method, with the following syntax: WideImage_Image resize(, ,, ) - Resize the image to given dimensions.
  • Alignment labels: $cropped = $image->crop('center', 'center', 200, 250).
  • Numeric coordinates: $resized = $image->resize(200, 100).
  • They can be useful with any operation that requires coordinates as parameters, like resize, crop, etc. Smart coordinates were implemented to make operations that involve coordinates, dimensions, and positioning easier. Note: WideImage supports cross-format conversion you can easily load an image in one format, then save it in another: WideImage::load('file.jpg')->saveToFile('converted.png') Smart coordinates 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():

    php wideimage

    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).

    php wideimage

    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.






    Php wideimage