Function __global->_convert_image

Definitions

sources/images2.php

  • (Helper for convert_image / convert_image_plus).
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$from string No No required parameter N/A N/A The URL to the image to resize. May be either relative or absolute. If $using_path is set it is actually a path
&$to PATH Yes No required parameter N/A N/A The file path (including filename) to where the resized image will be saved. May be changed by reference if it cannot save an image of the requested file type for some reason
$width ?integer No No required parameter N/A N/A The maximum width we want our new image to be (null: don't factor this in)
$height ?integer No No required parameter N/A N/A The maximum height we want our new image to be (null: don't factor this in)
$box_size ?integer No No Null N/A N/A This is only considered if both $width and $height are null. If set, it will fit the image to a box of this dimension (suited for resizing both landscape and portraits fairly) (null: use width or height)
$exit_on_error boolean No No True N/A N/A Whether to exit the software if an error occurs
$ext2 ?string No No Null N/A N/A The file extension representing the file type to save with (null: same as our input file)
$using_path boolean No No False N/A N/A Whether $from was in fact a path, not a URL
$only_make_smaller boolean No No False N/A N/A Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images). Parameter is ignored for some $thumb_options combinations.
$thumb_options ?array No No Null N/A N/A This optional parameter allows us to specify cropping or padding for the image. See comments in the function. (null: no details passed)

Returns

  • The thumbnail URL (blank: URL is outside of base URL)
  • Type: URLPATH
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * (Helper for convert_image / convert_image_plus).
 *
 * @param  string $from The URL to the image to resize. May be either relative or absolute. If $using_path is set it is actually a path
 * @param  PATH $to The file path (including filename) to where the resized image will be saved. May be changed by reference if it cannot save an image of the requested file type for some reason
 * @param  ?integer $width The maximum width we want our new image to be (null: don't factor this in)
 * @param  ?integer $height The maximum height we want our new image to be (null: don't factor this in)
 * @param  ?integer $box_size This is only considered if both $width and $height are null. If set, it will fit the image to a box of this dimension (suited for resizing both landscape and portraits fairly) (null: use width or height)
 * @param  boolean $exit_on_error Whether to exit the software if an error occurs
 * @param  ?string $ext2 The file extension representing the file type to save with (null: same as our input file)
 * @param  boolean $using_path Whether $from was in fact a path, not a URL
 * @param  boolean $only_make_smaller Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images). Parameter is ignored for some $thumb_options combinations.
 * @param  ?array $thumb_options This optional parameter allows us to specify cropping or padding for the image. See comments in the function. (null: no details passed)
 * @return URLPATH The thumbnail URL (blank: URL is outside of base URL)
 */

function _convert_image(string $from, string &$to, ?int $width, ?int $height, ?int $box_size = null, bool $exit_on_error = true, ?string $ext2 = null, bool $using_path = false, bool $only_make_smaller = false, ?array $thumb_options = null) : string