gdr2_Img

Collection of the functions to handle images resizing.


function get_extension($input)

  • $input: file path or file name.

Returns extension of a file.
Function returns: string file extension.


public create_thumbnail($input_file, $new_width, $new_height, $output_folder = ”, $new_name = ‘%NAME%_thumb.jpg’, $output_type = ‘jpg’)

  • $input_file: file to create thumbnail from.
  • $new_width: thumbnail width.
  • $new_height: thumbnail height.
  • $output_folder: where to save the thumbnail. if empty, saves in the input image folder.

Creates a thumbnail from input image.


public create_thumbnail_crop($input_file, $new_width, $new_height, $output_folder = ”, $new_name = ‘%NAME%_thumb.jpg’, $output_type = ‘jpg’)

  • $input_file: file to create thumbnail from.
  • $new_width: thumbnail width.
  • $new_height: thumbnail height.
  • $output_folder: where to save the thumbnail. if empty, saves in the input image folder.

Creates a thumbnail from input image using crop resize.


public resize_image($input_file, $new_width, $new_height, $output_folder = ”, $delete_input = false, $new_name = ‘%NAME%.%EXT%’, $output_type = ”)

  • $input_file: file to resize.
  • $new_width: image width.
  • $new_height: image height.
  • $output_folder: where to save new image. if empty, saves in the input image folder.
  • $delete_input: should the input image be deleted.
  • $new_name: created file name.
  • $new_extension: created file extension.

Resizes the image.


public resize_image_crop($input_file, $new_width, $new_height, $output_folder = ”, $delete_input = false, $new_name = ‘%NAME%.%EXT%’, $output_type = ”)

  • $input_file: file to resize
  • $new_width: image width.
  • $new_height: image height.
  • $output_folder: where to save new image. if empty, saves in the input image folder.
  • $delete_input: should the input image be deleted.
  • $new_name: created file name.
  • $new_extension: created file extension.

Resizes the image to exact dimensions using cropping.


public create_image_overlay($src_image, $src_size, $new_width, $new_height, $background_color = array(255, 255, 255)”)

  • $src_image: start image.
  • $src_size: getimage size result array.
  • $new_width: image width.
  • $new_height: image height.
  • $background_color: rgb color.

Create new image and overlays src_image in the middle.
Function returns: image image resource.


public random_with_time($rand_length = 8)

  • $rand_length:

Get random string using rand function and timestamp.
Function returns: string random string.


public upload_image($upl_file, $output_folder, $new_name = ”, $settings = array())

  • $upl_file: uploaded file from the $_FILES.
  • $output_folder: where to save the file.
  • $settings: upload settings based on $img_default.

Handles upload of image into.


public serve_image($path, $content_type, $ext)

  • $path: image path.
  • $content_type: full content type.
  • $ext: extension.

Returns the image.

Comments

Leave a Reply