/*
*
* Class methods
* #############################################################################
* chkQuality() - Validate image quality values
* chkType() - Validate image type to supported values
* getImageInfo() - Get image width, height, type, color dept (bits) and mime type
* getImageSize() - If reference size supplied, calculate the needed width
* and height to keep image proportional. Else, return current
* image width and height.
* getRemoteImageSize() - If reference size supplied, calculate the needed width
* and height to keep image proportional. Else, return
* current image width and height.
* getImageType() - Get image type (jpg, png, webp, gif or bmp)
* getImgTypeName() - Convert from php numeric type of image to image type name
* imagecopymergealpha() - Patch to fix troubles with alpha channels with imagecopymerge
* initImg() - Array values to initialize resize, watermark, show and save functions
* init() - initIMG alias <-----------------------------------------------------
* initBackup() - Copy all init vars to backup to use vars to new operations
* initRestore() - Restore all init vars from backup to continue operatios
* loadImg() - Load image file to resize and save or show
* outImg() - Out loaded image resource
* resampleImg() - Resize and resample image to a given width and height
* If there is not any valid value return as jpg
* resizeImg() - Resize image to width, heigh, both or scale to a percentage
* resize() - resizeImg() alias <-----------------------------------------------
* saveImg() - Save loaded image to a given file
* save() - saveImg() alias <---------------------------------------------------
* scaleStamp() - Scale watermark stamp image
* showImg() - Show loaded image to screen
* show() - showImg() alias <---------------------------------------------------
* addWatermark() - Add a centered watermark to image from png stamp
* cropImg() - Crop image
* rotateImg() - Rotate image
* flipImg() - Flip image
* pdfThumb() - Create a PDF thumbnail
* renderText() - Generate a new image rendered with the input text
* getExifInfo() - Get image Exif info using exiftool
* getICCInfo() - Get image ICC profile info using exiftool
* imagecreatefrombmp() - Return an image resource from BMP (not existing in PHP)
*
*/
img::initImg()
/**
* Init vars from conf array
* image = Main image resource to work with
* stamp = Stamp PNG image resource to generate watermarks
* imagefile = Image file to generate (overwrite), the image resource
* stampfile = Stamp PNG file to generate (overwrite), the stamp resource
* filename = Output file name to save images
* width = The width value to reescale images
* height = The height value to reescale images
* scale = The percent value to reescale images
* pct = The transparency percent of stam to watermark images
* stampps = Stamp percent size
* stampos = Stamp position (ul, ur, center, ll, lr)
* type = The php IMAGETYPE constant value of every type of image
* quality = Quality compression of jpeg, webp and png images
* debug = Set true to show debugging info
*
* @param array $conf conf values to use with show, save, resize & watermark
*/
Use:
$cnf['conf_param'] = 'conf_value';
$wv->img->initImg($cnf);
Examples:
//Resize image and save it
//Config
$conf['quality'] = 85; //Compression quality
$conf['pct'] = 60; //Transparency
$conf['imagefile'] = "/path/to/origin/image.jpg"; //origin image
$conf['width'] = 480; //Resize to 480px width
$conf['type'] = IMAGETYPE_JPEG; //Save as jpeg
$conf['filename'] = "/path/to/file/image.jpg"; //Target file name
//Execute
$wv->img->initImg($conf);
$wv->img->resizeImg();
$wv->img->saveImg();
//Add watermark
//Config
$conf['quality'] = 80; //Compression quality
$conf['stampps'] = 20; //Stamp percent size
$conf['stampos'] = 'center'; //stamp position (ul, ur, center, ll, lr)
$conf['pct'] = 40; //Transparency
$conf['stampfile'] = "/path/to/watermark.png"; //stamp image
$conf['imagefile'] = "/path/to/origin/image.jpg"; //origin image
$conf['width'] = 1024; //Resize to 1024px width
$conf['type'] = IMAGETYPE_JPEG; //Save as jpeg
$conf['filename'] = "/path/to/file/image.jpg"; //Target file name
//Execute
$wv->img->initImg($conf);
$wv->img->resizeImg();
$wv->img->saveImg();