Page 2
23 Feb
Admin

How to Use Wide Image Library in PHP?

Wide image is an object oriented library that is used for image manipulation. It offers a simple way of loading, editing and saving images in the widely used common image formats. It needs PHP 5.2 + along with GD2 extension.

It supports all the formats such as GIF, PNG, JPG, GD, GD2, WBMP, XBM and XPM. It supports BMP and TGA.

How to load an image?

Before we carry out various operations on the image with the help of Wide Image Library, first of all we must load the image and to do so, we use load() method which is used to load the image from any existing file, URL, HTML, input file field as well as valid image handle.

This method comes with following syntax:

“static WideImage_Image load( mixed $source)”

Image URLs
This wide image supports cross format conversion.

Implementing Smart Coordinates:

These coordinates are applied for various procedures that include coordinates, dimensions and positioning easier. These can be used with every operation which requires various coordinates like as parameters such as resize and crop.

The numerical coordinates include: $resized = $image->resize (200, 100);

How to Re-size an image?

To resize an image with the help of Wide Image Library; one can use resize() method that has following syntax:

WideImage_Image resize( [mixed $width = null], [mixed $height = null], [string $fit = ‘inside’], [string $scale = ‘any’])-

Cropping an Image:

At times, there’s a need to crop the images. This can be done easily using Wide Image Library. The crop() method can be used here with the following syntax:

WideImage_Image crop( [mixed $left = 0], [mixed $top = 0], [mixed $width = ‘100%’], [mixed $height = ‘100%’])

Combining two images:

In order to merge two images with WideImage Library, the merge() method is to be used with the following syntax;

WideImage_Image merge( WideImage_Image $overlay, [mixed $left = 0], [mixed $top = 0], [int $pct = 100])- This method lays the overlay (watermark) on the image.

How to add shapes and text to an image:

Many times, we need to add shapes or text to an image so as to meet our needs. With Wide Image Library; one can easily draw or insert text as well as shapes in the image with the use of Canvas object that is returned by getCanvas() method.

Wide Image Library

How to rotate or mirror the images:

In order to rotate, mirror or flip the images; one needs to use any of these methods:

WideImage_Image rotate( int $angle, [int $bgColor = null], [bool $ignoreTransparent = true]) – Rotate the image for angle $angle clockwise.
WideImage_Image mirror( ) – Returns a mirrored copy of the image
WideImage_Image flip( ) – Returns a flipped (mirrored over horizontal line) copy of the image

Rounding Image Corners:

Using roundCorners() method, it is easy to provide rounded corners to an image. Apart from round corners, we can also give diagonal corners, right corners, deep and coloured corners etc.

Take Away:

Like this, we can add images in PHP with the help of WideImage Library. We can also give different effects to the image as mentioned in the entire blog post.

Hope this blog post will be useful to you. For more such tips and techniques, stay connected with Softqube Technologies; well known PHP web development Company offering web development services at affordable costs.

contact
Are you looking for real talent for your dream projects?
Inquiry
We will respond you in within 24 hours
Do you have a project in mind?
Let's start your project
Quick Contact
We can give you a fast response via email, phone call or skype.
For business inquiries
Call us on
Let's Skype
Close
Inquire
Let’s make something awesome together!
Drop us a line, or give us a heads up if you’re interested in visiting us.
  • Accepted file types: docx, xlsx, ppt, pdf, jpg, gif, png.
  • 8 + 3 =
  • This field is for validation purposes and should be left unchanged.
100% secure and private