Download the PHP package realitaetsverlust/imagewrapper without Composer
On this page you can find all versions of the php package realitaetsverlust/imagewrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download realitaetsverlust/imagewrapper
More information about realitaetsverlust/imagewrapper
Files in realitaetsverlust/imagewrapper
Package imagewrapper
Short Description An OOP-Wrapper for images in PHP
License WTFPL
Informations about the package imagewrapper
ImageWrapper
A simple wrapper for image in PHP
ImageWrapper is one of my simplistic OOP Wrappers for PHP. My goal with this project was to create a library which is lightweight, has little to no dependencies and requires little to no explanation on how it works. And I think that I definitely succeeded. Image wrapper has no dependencies, is not very complex and extremely simple to integrate in existing or new web applications.
Keep in mind that this software is still in development. It's currently in a state that is absolutely useable in productive environments, but it may have occasional bugs here and there, especially with older GDLb versions. If you notice a bug, please leave an issue, stating exactly the PHP Version and GDLib version you're using.
Installation:
You can easiely install ImageWrapper via composer:
composer require realitaetsverlust/imagewrapper
What can ImageWrapper do for you:
- Load, edit, convert and output images of any kind with ease
- Provide a nice to use API for all filetypes
- No fancy stuff: Every method maps to one, sometimes two PHP functions. Very straighforward
For example: You want to load an image called test.png
, convert it into a JPEG file and output it:
Tadaa, that's all necessary to convert an image from PNG to JPEG. If you prefer it a little bit fancier, you can also make use of the method chaining ImageWrapper provides:
Almost every method returns itself in the end, with a few exceptions. So you can chain methods as often and as much as you like!
Also, if you don't know which kind of image you have there or you simply don't want to bother, no worries, ImageWrapper got your back. There is ImageFactory::create()
that automatically checks the filetype using exif_imagetype()
and returns the corresponding object:
ImageWrapper has support for all image types PHP supports, which are:
- .png
- .jpeg
- .gif
- .webp
- .bmp
- .wbmp
- .xbm
- .xpm (only read, no write)
The elements of the library:
ImageBase:
ImageBase
is the base class of all images. It's an abstract class that contains definitions for all methods. Every method maps to one PHP function, sometimes two if the two methods are very similar. A full documentation of methods inside ImageBase
is below
Color:
The Color()
class is a RGB representation which is used throughout the the library. The main advantage of it is that it can convert RGB values as well as a hex-based string (#ff00ff) and even CMYK.
Every time a function expects a color represenation, you should pass a Color object. This may look like the following:
This will colorize the image red. However, you can, as mentioned above, also add other values that represent a color:
Usually, you never have to care about the allocation of the color, the picture class handles those by itself. However, the method allocateColor()
allows you to perform the allocation of colors yourself.
Method-Documentation:
Outputs the image. If $destination
is set, the image is saved at the given path. If it is not, it's directly send as output.
This method is ont inside ImageBase
, but inside the child classes. PHPs output functions are not very streamlined which makes it really hard to write a proper function for all of them.
Converts an image from one image type to another. Please keep in mind that this function returns a new object you have to use. So something like the following will not work.
Chaining the methods, however, will obviously work.
This method sends the headers as a browser would expect them in the format Content-Type: image/png
. They are determined by image_type_to_mime_type()
. In general, you don't have to call this function yourself, it is called automatically if the method output()
does not get any $destination
parameter. However, there may be a situation where you want to fire the function yourself, for example if you want to set some parameters before you send the image to the receiver.
Returns the current file type of the image. This is not determined by the extension, but by exif_imagetype()
Returns the file size of the image.
Returns the minimum quality PHP accepts in the output function.
Returns the maximum quality PHP accepts in the output function.
Set the blending mode for the image
Activate the fast drawing antialiased methods for lines and wired polygons.
Draws an arc. if $style is passed, the arc will be filled
Draws a char horizontally or vertically onto the image.
Fetches the color value at a specific location
Cuts a part from the current image and copies it into a new image
Crops image to given dimension
Draws a line onto the image
Draws an ellipse. If $fill isp passed, the ellipse will be filled with the passed color.
Performs a flood fill onto the image
Draws a polygon. If $fill is passed, the polygon will be filled with the passed color.
Draws a rectangle. If $fill is passed, the rectangle will be filled with the given color.
Inverts the color of an image (white to black, black to white etc)
Convert image into a grayscale image. Alpha components are retained.
Set brightness of given image
Sets contrast of the given image
Colorizes an image
Uses edge detection to highlight the edges in the image.
Embosses the image
Blurs an image. If $useGauss is passed, the gauss blur will be used instead of the selective blur
Transforms the image to have a sketchy look
Smoothes the iamge
Pixelates the iamge
Applies a scatter effect to the image.
Gamma correction method
Flips the image using the given mode. Modes are IMG_FLIP_HORIZONTAL, IMG_FLIP_VERTICAL and IMG_FLIP_BOTH
Enables/Disables interlace
Determines if an image is a true color image
Allocates a color and adds it to the list of allocated colors.
All versions of imagewrapper with dependencies
ext-exif Version *
ext-gd Version *