PHP Class CI_Image_lib, TastyIgniter

Author: ExpressionEngine Dev Team
Exibir arquivo Open project: tastyigniter/tastyigniter Class Usage Examples

Public Properties

Property Type Description
$copy_fnc string Name of function to copy image
$create_fnc string Name of function to create image
$create_thumb boolean Whether to create a thumbnail
$dest_folder string Destination image folder
$dynamic_output boolean Whether to send to browser or write to disk
$error_msg array Error messages
$file_permissions integer File permissions
$full_dst_path string Full path to destination image
$full_src_path string Full path to source image
$height integer Image height
$image_library string PHP extension/library to use for image manipulation Can be: imagemagick, netpbm, gd, gd2
$image_type string Image format
$library_path string Path to the graphic library (if applicable)
$maintain_ratio boolean Whether to maintain aspect ratio when resizing or use hard values
$master_dim string auto, height, or width. Determines what to use as the master dimension
$mime_type string Image mime-type
$new_image string Path to the modified image
$orig_height integer Original image height
$orig_width integer Original image width
$quality integer Quality percentage of new image
$rotation_angle string Angle at to rotate image
$size_str string Size of current image
$source_folder string Source image folder
$source_image string Path to original image
$thumb_marker string String to add to thumbnail version of image
$width integer Image width
$wm_font_path string TT font
$wm_font_size integer Font size (different versions of GD will either use points or pixels)
$wm_hor_alignment string Horizontal alignment: L R C
$wm_hor_offset integer Lets you push text to the right
$wm_opacity integer Image opacity: 1 - 100 Only works with image
$wm_overlay_path string Watermark image path
$wm_padding integer Padding around text
$wm_shadow_distance integer Dropshadow distance
$wm_text string Watermark text if graphic is not used
$wm_type string Type of watermarking. Options: text/overlay
$wm_use_truetype boolean Whether to use truetype fonts
$wm_vrt_alignment string Vertical alignment: T M B
$wm_vrt_offset integer Lets you push text down
$wm_x_transp integer Default transparency for watermark
$wm_y_transp integer Default transparency for watermark
$x_axis integer X Coordinate for manipulation of the current image
$y_axis integer Y Coordinate for manipulation of the current image

Protected Properties

Property Type Description
$wm_font_color string Text color
$wm_shadow_color string Dropshadow color
$wm_use_drop_shadow boolean Whether to have a drop shadow on watermark

Public Methods

Method Description
__construct ( array $props = [] ) : void Initialize Image Library
clear ( ) : void Initialize image properties
crop ( ) : boolean Image Crop
display_errors ( $open = '<p>', $close = '</p>' ) : string Show error messages
explode_name ( $source_image ) : array Explode source_image
gd_loaded ( ) : boolean Is GD Installed?
gd_version ( ) : mixed Get GD version
get_image_properties ( $path = '', $return = FALSE ) : mixed Get image properties
image_create_gd ( $path = '', $image_type = '' ) : resource Create Image - GD
image_display_gd ( $resource ) : void Dynamically outputs an image
image_mirror_gd ( ) : boolean Create Mirror Image using GD
image_process_gd ( $action = 'resize' ) : boolean Image Process Using GD/GD2
image_process_imagemagick ( $action = 'resize' ) : boolean Image Process Using ImageMagick
image_process_netpbm ( $action = 'resize' ) : boolean Image Process Using NetPBM
image_reproportion ( ) : void Re-proportion Image Width/Height
image_rotate_gd ( ) : boolean Image Rotate Using GD
image_save_gd ( $resource ) : boolean Write image file to disk - GD
initialize ( $props = [] ) : boolean initialize image preferences
overlay_watermark ( ) : boolean Watermark - Graphic Version
resize ( ) : boolean Image Resize
rotate ( ) : boolean Image Rotate
set_error ( $msg ) : void Set error message
size_calculator ( $vals ) : array Size calculator
text_watermark ( ) : boolean Watermark - Text Version
watermark ( ) : boolean Image Watermark

Method Details

__construct() public method

Initialize Image Library
public __construct ( array $props = [] ) : void
$props array
return void

clear() public method

Resets values in case this class is used in a loop
public clear ( ) : void
return void

crop() public method

This is a wrapper function that chooses the proper cropping function based on the protocol specified
public crop ( ) : boolean
return boolean

display_errors() public method

Show error messages
public display_errors ( $open = '<p>', $close = '</p>' ) : string
return string

explode_name() public method

This is a helper function that extracts the extension from the source_image. This function lets us deal with source_images with multiple periods, like: my.cool.jpg It returns an associative array with two elements: $array['ext'] = '.jpg'; $array['name'] = 'my.cool';
public explode_name ( $source_image ) : array
return array

gd_loaded() public method

Is GD Installed?
public gd_loaded ( ) : boolean
return boolean

gd_version() public method

Get GD version
public gd_version ( ) : mixed
return mixed

get_image_properties() public method

A helper function that gets info about the file
public get_image_properties ( $path = '', $return = FALSE ) : mixed
return mixed

image_create_gd() public method

This simply creates an image resource handle based on the type of image being processed
public image_create_gd ( $path = '', $image_type = '' ) : resource
return resource

image_display_gd() public method

Dynamically outputs an image
public image_display_gd ( $resource ) : void
return void

image_mirror_gd() public method

This function will flip horizontal or vertical
public image_mirror_gd ( ) : boolean
return boolean

image_process_gd() public method

This function will resize or crop
public image_process_gd ( $action = 'resize' ) : boolean
return boolean

image_process_imagemagick() public method

This function will resize, crop or rotate
public image_process_imagemagick ( $action = 'resize' ) : boolean
return boolean

image_process_netpbm() public method

This function will resize, crop or rotate
public image_process_netpbm ( $action = 'resize' ) : boolean
return boolean

image_reproportion() public method

When creating thumbs, the desired width/height can end up warping the image due to an incorrect ratio between the full-sized image and the thumb. This function lets us re-proportion the width/height if users choose to maintain the aspect ratio when resizing.
public image_reproportion ( ) : void
return void

image_rotate_gd() public method

Image Rotate Using GD
public image_rotate_gd ( ) : boolean
return boolean

image_save_gd() public method

Takes an image resource as input and writes the file to the specified destination
public image_save_gd ( $resource ) : boolean
return boolean

initialize() public method

initialize image preferences
public initialize ( $props = [] ) : boolean
return boolean

overlay_watermark() public method

Watermark - Graphic Version
public overlay_watermark ( ) : boolean
return boolean

resize() public method

This is a wrapper function that chooses the proper resize function based on the protocol specified
public resize ( ) : boolean
return boolean

rotate() public method

This is a wrapper function that chooses the proper rotation function based on the protocol specified
public rotate ( ) : boolean
return boolean

set_error() public method

Set error message
public set_error ( $msg ) : void
return void

size_calculator() public method

This function takes a known width x height and recalculates it to a new size. Only one new variable needs to be known $props = array( 'width' => $width, 'height' => $height, 'new_width' => 40, 'new_height' => '' );
public size_calculator ( $vals ) : array
return array

text_watermark() public method

Watermark - Text Version
public text_watermark ( ) : boolean
return boolean

watermark() public method

This is a wrapper function that chooses the type of watermarking based on the specified preference.
public watermark ( ) : boolean
return boolean

Property Details

$copy_fnc public_oe property

Name of function to copy image
public string $copy_fnc
return string

$create_fnc public_oe property

Name of function to create image
public string $create_fnc
return string

$create_thumb public_oe property

Whether to create a thumbnail
public bool $create_thumb
return boolean

$dest_folder public_oe property

Destination image folder
public string $dest_folder
return string

$dynamic_output public_oe property

Whether to send to browser or write to disk
public bool $dynamic_output
return boolean

$error_msg public_oe property

Error messages
public array $error_msg
return array

$file_permissions public_oe property

File permissions
public int $file_permissions
return integer

$full_dst_path public_oe property

Full path to destination image
public string $full_dst_path
return string

$full_src_path public_oe property

Full path to source image
public string $full_src_path
return string

$height public_oe property

Image height
public int $height
return integer

$image_library public_oe property

PHP extension/library to use for image manipulation Can be: imagemagick, netpbm, gd, gd2
public string $image_library
return string

$image_type public_oe property

Image format
public string $image_type
return string

$library_path public_oe property

Path to the graphic library (if applicable)
public string $library_path
return string

$maintain_ratio public_oe property

Whether to maintain aspect ratio when resizing or use hard values
public bool $maintain_ratio
return boolean

$master_dim public_oe property

auto, height, or width. Determines what to use as the master dimension
public string $master_dim
return string

$mime_type public_oe property

Image mime-type
public string $mime_type
return string

$new_image public_oe property

Path to the modified image
public string $new_image
return string

$orig_height public_oe property

Original image height
public int $orig_height
return integer

$orig_width public_oe property

Original image width
public int $orig_width
return integer

$quality public_oe property

Quality percentage of new image
public int $quality
return integer

$rotation_angle public_oe property

Angle at to rotate image
public string $rotation_angle
return string

$size_str public_oe property

Size of current image
public string $size_str
return string

$source_folder public_oe property

Source image folder
public string $source_folder
return string

$source_image public_oe property

Path to original image
public string $source_image
return string

$thumb_marker public_oe property

String to add to thumbnail version of image
public string $thumb_marker
return string

$width public_oe property

Image width
public int $width
return integer

$wm_font_color protected_oe property

Text color
protected string $wm_font_color
return string

$wm_font_path public_oe property

TT font
public string $wm_font_path
return string

$wm_font_size public_oe property

Font size (different versions of GD will either use points or pixels)
public int $wm_font_size
return integer

$wm_hor_alignment public_oe property

Horizontal alignment: L R C
public string $wm_hor_alignment
return string

$wm_hor_offset public_oe property

Lets you push text to the right
public int $wm_hor_offset
return integer

$wm_opacity public_oe property

Image opacity: 1 - 100 Only works with image
public int $wm_opacity
return integer

$wm_overlay_path public_oe property

Watermark image path
public string $wm_overlay_path
return string

$wm_padding public_oe property

Padding around text
public int $wm_padding
return integer

$wm_shadow_color protected_oe property

Dropshadow color
protected string $wm_shadow_color
return string

$wm_shadow_distance public_oe property

Dropshadow distance
public int $wm_shadow_distance
return integer

$wm_text public_oe property

Watermark text if graphic is not used
public string $wm_text
return string

$wm_type public_oe property

Type of watermarking. Options: text/overlay
public string $wm_type
return string

$wm_use_drop_shadow protected_oe property

Whether to have a drop shadow on watermark
protected bool $wm_use_drop_shadow
return boolean

$wm_use_truetype public_oe property

Whether to use truetype fonts
public bool $wm_use_truetype
return boolean

$wm_vrt_alignment public_oe property

Vertical alignment: T M B
public string $wm_vrt_alignment
return string

$wm_vrt_offset public_oe property

Lets you push text down
public int $wm_vrt_offset
return integer

$wm_x_transp public_oe property

Default transparency for watermark
public int $wm_x_transp
return integer

$wm_y_transp public_oe property

Default transparency for watermark
public int $wm_y_transp
return integer

$x_axis public_oe property

X Coordinate for manipulation of the current image
public int $x_axis
return integer

$y_axis public_oe property

Y Coordinate for manipulation of the current image
public int $y_axis
return integer