WOOF_Image

Extends WOOF_File

Methods

A powerful class representing an image file within your WordPress site, which offers resizing, cropping, and manipulation features.

Example: Some of the many ways to obtain a WOOF_Image

Example: Obtaining other objects that delegate to WOOF_Image

List of Methods

Magic Methods

Property Methods

  • attr( String $key = null, Mixed $val = null )String OR Array

    Gets or sets the attributes stored inside this image object, which are used to output HTML attributes.

  • bit()Integer

    Retrieves the bit-depth of the image.

  • exif()WOOF_EXIF

    Retrieves a WOOF_EXIF object representing the EXIF data in the image, if available.

  • height()Integer

    Retrieves the height of the image in pixels.

  • info()Array

    Retrieves an associative array of info about this image file.

  • is_landscape()Boolean

    Returns true if the image is a landscape orientation (width is larger than height).

  • is_portrait()Boolean

    Returns true if the image is a portrait orientation (height is larger than width).

  • is_square()Boolean

    Returns true if the image is square (width equals height).

  • orientation()String

    Returns a string representing the orientation of the image:“landscape” – if the image is wider than it is tall“portrait” – if the image is taller than it is wide“square” – if the image is of equal width and height.

  • width()Integer

    Retrieves the width of the image in pixels.

Manipulation

  • save_image( String $path, Resource $image, String $mime_type, Arguments $attr = array(), Boolean $destroy = true )

    A utility method used by this class to save an image resource to disk, auto-detecting the correct format and required PHP function needed to do so.Note: this method is intended for internal use.

Theming

  • fluid( Arguments $args = array() )String

    Returns an image tag that removes the width and height attributes, for use with responsive image techniques.

  • html( Arguments $attr = array() )String

    An alias for the WOOF_Image::tag method to generate an HTML tag for the image.

  • picture( Arguments $args )String

    Outputs markup for use with the picturefill responsive images library by Scott Jehl, which allows you to specify a number of images to use at different media query breakpoints, as well as images for high-resolution displays. This method accepts a number of shorthand argument keys to quickly output the necessary media query min-width, max-width, and min-device-pixel ratio media query declarations, as well as smart values for these keys to define either separate image files to use, or a resize operation on this image. Note: MasterPress includes the picturefill.js and matchmedia.js libraries which can be enqueued with the following identifiers, anytime before wp_head().wp_enqueue_script(‘mp-matchmedia’);wp_enqueue_script(‘mp-picturefill’);.

  • picture_2x( Arguments $args )String

    A preset on the WOOF_Image::picture method to output markup for use with the picturefill responsive images library by Scott Jehl.

  • tag( Arguments $attr = array() )String

    Retrieves an HTML tag for the image.

Image Processing

  • crop( Arguments $args = array() )WOOF_Image

    A preset on the WOOF_Image::resize method which uses the argument “c=2” which will crop the image to a specified width and height without scaling the image.

  • generate( Arguments $args = array() )WOOF_Image

    An alias for the WOOF_Image::resize method to resize an image, with various cropping options.

  • res()Resource

    A convenience method to retrieve the GD image resource for the image this file represents.

  • resample( Arguments $args = array() )WOOF_Image

    An alias for woof-image which is a more appropriate method name when we just want to change the jpeg quality without resizing.

  • resize( Arguments $args = array() )WOOF_Image

    A highly useful method to resize an image, and cache the result in the image cache.

  • thumb( Arguments $args = array() )WOOF_Image

    An alias for WOOF_Image::resize to resize an image, and cache the result in the image cache.

Image Filters

  • blur( Arguments $attr = array() )WOOF_Image

    A more concise alias for the WOOF_Image::selective_blur filter to apply a selective blur to the image, and cache the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • brightness( Integer $val, Arguments $attr = array() )WOOF_Image

    Adjusts the brightness of the image, and caches the result in the image cache.

  • colorize( String $color, Arguments $attr = array(), $ )WOOF_Image

    Colorizes the image, with a given color (while retaining the other colors in the image), and caches the result in the image cache.Given the following unprocessed image:The example code produces these images:A more useful function might be the WOOF_Image::tint method, which applies a grayscale filter before colorizing the image, which produces a generally nicer effect.

  • contrast( Integer $val, Arguments $attr = array() )WOOF_Image

    Adjusts the brightness of the image, and caches the result in the image cache.

  • convolute( Array $matrix, Arguments $attr = array(), Float $offset = 0 )WOOF_Image

    Applies a convolution filter to the image, using the imageconvolution PHP function.

  • edgedetect( Arguments $attr = array() )WOOF_Image

    Creates an image based on edge detection of the source, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • emboss( Arguments $attr = array() )WOOF_Image

    Creates an embossed-look version of the image, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • gaussian_blur( Arguments $attr = array() )WOOF_Image

    Applies a gaussian blur to the image, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • gblur( Arguments $attr = array() )WOOF_Image

    A more concise alias for the WOOF_Image::gaussian_blur method (“gaussian” is rather annoying to type), to apply a gaussian blur to the image, and cache the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • grayscale( Arguments $attr = array() )WOOF_Image

    Removes the color from the image, and caches the result in the image cache.Given the following unprocessed image:The example code produces this image:.

  • laplace( Arguments $attr = array() )WOOF_Image

    Applies a laplace effect to the image via convolution.Given the following unprocessed image:  The example code produces this image:.

  • laplace_diag( Arguments $attr = array() )WOOF_Image

    Applies a laplace diagonal effect to the image via convolution.Given the following unprocessed image:  The example code produces this image:.

  • mean_removal( Arguments $attr = array() )WOOF_Image

    Applies a mean removal effect (giving a “sketched” appearance) to the image, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • pixelate( Integer $block_size, Boolean $advanced = false, Arguments $attr = array() )WOOF_Image

    Generates a pixelated version of the image, and caches the result in the image cache.Given the following unprocessed image:   The example code produces these images:.

  • selective_blur( Arguments $attr = array() )WOOF_Image

    The WOOF_Image::selective_blur filter to apply a selective blur to the image, and cache the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • sepia( String $color = #5f370e, Arguments $attr = array() )WOOF_Image

    A specialisation of the WOOF_Image::tint method, to create a sepia-tone effect on the image, and save the result to the image cache.Colorizes the image, with a given color (while retaining the other colors in the image), and caches the result in the image cache.Given the following unprocessed image:The example code produces this image: .

  • sharpen( Arguments $attr = array() )WOOF_Image

    Sharpens an image via convolution, and caches the result.Given the following unprocessed image:  The example code produces this image:.

  • sketchy( Arguments $attr = array() )WOOF_Image

    An alias for the WOOF_Image::mean_removal to give the image a “sketched” appearance, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • smooth( Integer $val, Arguments $attr = array() )WOOF_Image

    Smooths the image, and caches the result in the image cache. Given the following unprocessed image:   The example code produces these images:.

  • sobel( Arguments $attr = array() )WOOF_Image

    Applies a sobel effect to the image via convolution.Given the following unprocessed image:  The example code produces this image:.

  • tint( String $color = #5f370e, Arguments $attr = array() )WOOF_Image

    Applies a grayscale filter and then colorize to generate a tinted effect on the image, and saves the result to the image cache.Given the following unprocessed image:The example code produces these images: .

Image Effects

  • border( Arguments $attr = array() )WOOF_Image

    Generates a solid color border around the image.Given the following unprocessed image:  The example code produces the images below:.

  • reflection( Arguments $attr = array() )WOOF_Image

    Generates an upside down reflection underneath the image, giving the appearance of the image resting on a glossy surface, and caches the result in the image cache.Given the following unprocessed image:   The example code produces these images:.

  • watermark( WOOF_Image $watermark, Arguments $attr = array() )WOOF_Image

    A powerful method to apply another image as a watermark on top of this image, and then cache the result in the image cache. Given the following two images (marked $play and $cat in the example code respectively): The example code produces the following images:.

Utility

Column Listings

  • mp_thumb( Arguments $args = array() )String

    Creates a thumbnail link to the fullsize image which is intended to be augmented with the JavaScript fancyzoom plugin bundled with MasterPress  (mp_thumb abbreviates MasterPress Thumbnail).

  • mt( Arguments $args = array() )String

    An alias for the WOOF_Image::mp_thumb to create a thumbnail link to the fullsize image which is intended to be augmented with the JavaScript fancyzoom plugin bundled with MasterPress (mt abbreviates “MasterPress Thumbnail”).

Internal Use

  • cacheinfo( Arguments $attr = array() )Array

    Returns an associative array describing the path and URL of an output image, given the arguments passed.

  • filter( Integer $filter, Arguments $attr = array(), Array $args = array() )WOOF_Image

    A utility method that handles all of the code to call a PHP image filter via the imagefilter function.

  • get_at_coord( Integer $dw, Integer $dh, Integer $sw, Integer $sh, String $at = c )Array

    Gets co-ordinates to use for the anchoring points usable by the WOOF_Image::watermark method to determine where the watermark is placed.Note: this method is intended for internal use.

  • get_offset( Integer $inset, String $at = c )Array

    Gets offset co-ordinates for the anchoring points usable by the WOOF_Image::watermark method to determine where the watermark is placed.Note: this method is intended for internal use.

  • save_image( String $path, Resource $image, String $mime_type, Arguments $attr = array(), Boolean $destroy = true )

    A utility method used by this class to save an image resource to disk, auto-detecting the correct format and required PHP function needed to do so.Note: this method is intended for internal use.

  • sizeinfo()Array

    Retrieves size and other info for the image via PHP’s getimagesize function. Note: this method is intended for internal use.

  • __toString()String

    Implements the __toString PHP magic method to convert this object to an HTML tag when it is echoed.

  • attr( String $key = null, Mixed $val = null )String OR Array

    Gets or sets the attributes stored inside this image object, which are used to output HTML attributes.

  • bit()Integer

    Retrieves the bit-depth of the image.

  • blur( Arguments $attr = array() )WOOF_Image

    A more concise alias for the WOOF_Image::selective_blur filter to apply a selective blur to the image, and cache the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • border( Arguments $attr = array() )WOOF_Image

    Generates a solid color border around the image.Given the following unprocessed image:  The example code produces the images below:.

  • brightness( Integer $val, Arguments $attr = array() )WOOF_Image

    Adjusts the brightness of the image, and caches the result in the image cache.

  • cacheinfo( Arguments $attr = array() )Array

    Returns an associative array describing the path and URL of an output image, given the arguments passed.

  • colorize( String $color, Arguments $attr = array(), $ )WOOF_Image

    Colorizes the image, with a given color (while retaining the other colors in the image), and caches the result in the image cache.Given the following unprocessed image:The example code produces these images:A more useful function might be the WOOF_Image::tint method, which applies a grayscale filter before colorizing the image, which produces a generally nicer effect.

  • contrast( Integer $val, Arguments $attr = array() )WOOF_Image

    Adjusts the brightness of the image, and caches the result in the image cache.

  • convolute( Array $matrix, Arguments $attr = array(), Float $offset = 0 )WOOF_Image

    Applies a convolution filter to the image, using the imageconvolution PHP function.

  • crop( Arguments $args = array() )WOOF_Image

    A preset on the WOOF_Image::resize method which uses the argument “c=2” which will crop the image to a specified width and height without scaling the image.

  • edgedetect( Arguments $attr = array() )WOOF_Image

    Creates an image based on edge detection of the source, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • emboss( Arguments $attr = array() )WOOF_Image

    Creates an embossed-look version of the image, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • exif()WOOF_EXIF

    Retrieves a WOOF_EXIF object representing the EXIF data in the image, if available.

  • filter( Integer $filter, Arguments $attr = array(), Array $args = array() )WOOF_Image

    A utility method that handles all of the code to call a PHP image filter via the imagefilter function.

  • fluid( Arguments $args = array() )String

    Returns an image tag that removes the width and height attributes, for use with responsive image techniques.

  • gaussian_blur( Arguments $attr = array() )WOOF_Image

    Applies a gaussian blur to the image, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • gblur( Arguments $attr = array() )WOOF_Image

    A more concise alias for the WOOF_Image::gaussian_blur method (“gaussian” is rather annoying to type), to apply a gaussian blur to the image, and cache the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • generate( Arguments $args = array() )WOOF_Image

    An alias for the WOOF_Image::resize method to resize an image, with various cropping options.

  • get_at_coord( Integer $dw, Integer $dh, Integer $sw, Integer $sh, String $at = c )Array

    Gets co-ordinates to use for the anchoring points usable by the WOOF_Image::watermark method to determine where the watermark is placed.Note: this method is intended for internal use.

  • get_offset( Integer $inset, String $at = c )Array

    Gets offset co-ordinates for the anchoring points usable by the WOOF_Image::watermark method to determine where the watermark is placed.Note: this method is intended for internal use.

  • grayscale( Arguments $attr = array() )WOOF_Image

    Removes the color from the image, and caches the result in the image cache.Given the following unprocessed image:The example code produces this image:.

  • height()Integer

    Retrieves the height of the image in pixels.

  • html( Arguments $attr = array() )String

    An alias for the WOOF_Image::tag method to generate an HTML tag for the image.

  • imagecopymerge_alpha( Resource $dst_im, Resource $src_im, Integer $dst_x, Integer $dst_y, Integer $src_x, Integer $src_y, Integer $src_w, Integer $src_h, Integer $pct, Array $trans = null )WOOF_Image

    Copy and merge part of an image, while respecting alpha channels. .

  • info()Array

    Retrieves an associative array of info about this image file.

  • is_landscape()Boolean

    Returns true if the image is a landscape orientation (width is larger than height).

  • is_portrait()Boolean

    Returns true if the image is a portrait orientation (height is larger than width).

  • is_square()Boolean

    Returns true if the image is square (width equals height).

  • laplace( Arguments $attr = array() )WOOF_Image

    Applies a laplace effect to the image via convolution.Given the following unprocessed image:  The example code produces this image:.

  • laplace_diag( Arguments $attr = array() )WOOF_Image

    Applies a laplace diagonal effect to the image via convolution.Given the following unprocessed image:  The example code produces this image:.

  • mean_removal( Arguments $attr = array() )WOOF_Image

    Applies a mean removal effect (giving a “sketched” appearance) to the image, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • mp_thumb( Arguments $args = array() )String

    Creates a thumbnail link to the fullsize image which is intended to be augmented with the JavaScript fancyzoom plugin bundled with MasterPress  (mp_thumb abbreviates MasterPress Thumbnail).

  • mt( Arguments $args = array() )String

    An alias for the WOOF_Image::mp_thumb to create a thumbnail link to the fullsize image which is intended to be augmented with the JavaScript fancyzoom plugin bundled with MasterPress (mt abbreviates “MasterPress Thumbnail”).

  • orientation()String

    Returns a string representing the orientation of the image:“landscape” – if the image is wider than it is tall“portrait” – if the image is taller than it is wide“square” – if the image is of equal width and height.

  • parse_color( Array / String $color )Array

    Parses a color string into an array containing an RGB array and a hex string representing the color.

  • parse_coord( String $pair )Array

    Parses an x,y coordinate string into an array made up of an x and y integer components.

  • picture( Arguments $args )String

    Outputs markup for use with the picturefill responsive images library by Scott Jehl, which allows you to specify a number of images to use at different media query breakpoints, as well as images for high-resolution displays. This method accepts a number of shorthand argument keys to quickly output the necessary media query min-width, max-width, and min-device-pixel ratio media query declarations, as well as smart values for these keys to define either separate image files to use, or a resize operation on this image. Note: MasterPress includes the picturefill.js and matchmedia.js libraries which can be enqueued with the following identifiers, anytime before wp_head().wp_enqueue_script(‘mp-matchmedia’);wp_enqueue_script(‘mp-picturefill’);.

  • picture_2x( Arguments $args )String

    A preset on the WOOF_Image::picture method to output markup for use with the picturefill responsive images library by Scott Jehl.

  • pixelate( Integer $block_size, Boolean $advanced = false, Arguments $attr = array() )WOOF_Image

    Generates a pixelated version of the image, and caches the result in the image cache.Given the following unprocessed image:   The example code produces these images:.

  • reflection( Arguments $attr = array() )WOOF_Image

    Generates an upside down reflection underneath the image, giving the appearance of the image resting on a glossy surface, and caches the result in the image cache.Given the following unprocessed image:   The example code produces these images:.

  • res()Resource

    A convenience method to retrieve the GD image resource for the image this file represents.

  • resample( Arguments $args = array() )WOOF_Image

    An alias for woof-image which is a more appropriate method name when we just want to change the jpeg quality without resizing.

  • resize( Arguments $args = array() )WOOF_Image

    A highly useful method to resize an image, and cache the result in the image cache.

  • save_image( String $path, Resource $image, String $mime_type, Arguments $attr = array(), Boolean $destroy = true )

    A utility method used by this class to save an image resource to disk, auto-detecting the correct format and required PHP function needed to do so.Note: this method is intended for internal use.

  • selective_blur( Arguments $attr = array() )WOOF_Image

    The WOOF_Image::selective_blur filter to apply a selective blur to the image, and cache the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • sepia( String $color = #5f370e, Arguments $attr = array() )WOOF_Image

    A specialisation of the WOOF_Image::tint method, to create a sepia-tone effect on the image, and save the result to the image cache.Colorizes the image, with a given color (while retaining the other colors in the image), and caches the result in the image cache.Given the following unprocessed image:The example code produces this image: .

  • sharpen( Arguments $attr = array() )WOOF_Image

    Sharpens an image via convolution, and caches the result.Given the following unprocessed image:  The example code produces this image:.

  • sizeinfo()Array

    Retrieves size and other info for the image via PHP’s getimagesize function. Note: this method is intended for internal use.

  • sketchy( Arguments $attr = array() )WOOF_Image

    An alias for the WOOF_Image::mean_removal to give the image a “sketched” appearance, and caches the result in the image cache.Given the following unprocessed image:  The example code produces this image:.

  • smooth( Integer $val, Arguments $attr = array() )WOOF_Image

    Smooths the image, and caches the result in the image cache. Given the following unprocessed image:   The example code produces these images:.

  • sobel( Arguments $attr = array() )WOOF_Image

    Applies a sobel effect to the image via convolution.Given the following unprocessed image:  The example code produces this image:.

  • tag( Arguments $attr = array() )String

    Retrieves an HTML tag for the image.

  • thumb( Arguments $args = array() )WOOF_Image

    An alias for WOOF_Image::resize to resize an image, and cache the result in the image cache.

  • tint( String $color = #5f370e, Arguments $attr = array() )WOOF_Image

    Applies a grayscale filter and then colorize to generate a tinted effect on the image, and saves the result to the image cache.Given the following unprocessed image:The example code produces these images: .

  • watermark( WOOF_Image $watermark, Arguments $attr = array() )WOOF_Image

    A powerful method to apply another image as a watermark on top of this image, and then cache the result in the image cache. Given the following two images (marked $play and $cat in the example code respectively): The example code produces the following images:.

  • width()Integer

    Retrieves the width of the image in pixels.

Base Class Methods

View method list from the base class WOOF_File.

Latest From the Blog

MasterPress 1.4.1 is now available

27th May 2024

This update addresses backwards compatibility issues that were introduced in the previous update. There were some edge cases where PHP 7 had issues and it didn’t work at all on PHP 5.6. We have now changed it so that the PHP 8 compatibility changes will now only affect PHP 8 and will be more thorough… 

Plugin Requirements

MasterPress requires a minimum of WordPress version 4.9, MySQL 5.6, and PHP version 5.6.20.

We also recommend that PHP is configured to use a memory limit of 64MB per request (128MB may be required for sites with higher complexity).

This plug-in is not compatible with the WordPress.com hosted service.

Three AM