class Image
Manipulate images using standard methods such as resize, crop, rotate, etc.
This class must be re-initialized for every image you wish to manipulate. Source code (43 results) /config/tinymce4.php Highlighted file source
Line 15: 'styleselect | style-h2 style-h3 style-h4 style-p | bullist numlist indent outdent | alignleft alignright | image sprout_gallery media table ' Line 40: array('title' => 'Popup Image', 'value' => 'js-popup-image'), Line 44: * Image classes for the Standard group Line 46: $config['Standard']['image_class_list'] = array(
 /sprout/config/file.php Highlighted file source
Line 17: use Sprout\Helpers\ResizeImageTransform; Line 21: * Image transformations Line 23: * This is an array of different operations that should be applied to the image Line 26: * ResizeImageTransform ( width , height ) Line 27: * CropImageTransform ( width , height , top_pos = 'center' , left_pos = 'center') Line 31: * You can also create your own transformations, just implement the ImageTransform interface Line 34: $config['image_transformations']['small'] = array( Line 35: new ResizeImageTransform (400, 400), Line 38: $config['image_transformations']['medium'] = array( Line 39: new ResizeImageTransform (680, null), Line 42: $config['image_transformations']['large'] = array( Line 43: new ResizeImageTransform (1280, null), Line 48: * The size to use for image links added using a rich text editor. Line 51: $config['imagelink_size'] = 'r500x500';
 /sprout/config/image.php Highlighted file source
Line 18: * @package Image Line 26: * ImageMagick - set the "directory" parameter to your ImageMagick installation directory Line 31: * Maximum size an image can be resized to before we emit an error Line 39: * Maximum dimensions to store 'original' version of uploaded image Line 41: * When a larger image is uploaded, the original is to be discarded and a shrunken copy stored instead
 /sprout/Controllers/Admin/FileAdminController.php Highlighted file source
Line 38: use Sprout\Helpers\Image; Line 119: if (!empty($file['type']) and $file['type'] == FileConstants::TYPE_IMAGE) $list['embed_author'] = 'Embed author credit in image'; Line 332: if ($data['type'] == FileConstants::TYPE_IMAGE) { Line 337: $max_dims = Kohana::config('image.original_size'); Line 350: $view->image_too_large = true; Line 398: // For images, calculate the expected RAM requirement of the resizing Line 400: if ($type == FileConstants::TYPE_IMAGE) { Line 401: $dimensions = getimagesize(APPPATH . 'temp/' . $_POST['tmp_file']); Line 457: $size = getimagesize($src); Line 458: $max_dims = Kohana::config('image.original_size'); Line 461: $temp_path = APPPATH . 'temp/original_image_' . time() . '_' . Sprout::randStr(4); Line 463: $img = new Image($src); Line 481: // Index documents, resize images, etc Line 490: $html = '<div class="file-upload__item__feedback__response file-upload__item__feedback__response--success file-upload__item__feedback__response--success--not-image">'; Line 593: if (@$_POST['type'] == 'image') { Line 678: // Update file name and do image resizing, text indexing, and other postprocessing Line 703: if ($view->data['type'] == FileConstants::TYPE_IMAGE) { Line 704: $size = File::imageSize($view->item['filename']); Line 708: $view->original_image = ''; Line 711: Notification::error('Image may be missing from server'); Line 720: $image_url = File::resizeUrl($view->data['filename'], 'r200x0'); Line 721: $image_url .= (strpos($image_url, '?') === false ? '?' : '&'); Line 722: $view->original_image = $image_url . 'version=' . Sprout::randStr(10); Line 820: } else if ($file['type'] == FileConstants::TYPE_IMAGE) { Line 823: // No sense in keeping the focal point for a replaced image Line 844: // Image manipulations Line 845: if ($file['type'] == FileConstants::TYPE_IMAGE) { Line 847: // Do image manipulations, if requested Line 852: $img = new Image($temp_filename); Line 859: case 'flip-horizontal': $img->flip(Image::HORIZONTAL); break; Line 860: case 'flip-vertical': $img->flip(Image::VERTICAL); break; Line 862: throw new Exception('Invalid image manipulation "' . $_POST['manipulate'] . '"'); Line 878: // No sense in keeping the focal point for a manipulated image Line 881: Notification::confirm('Image was manipulated successfully'); Line 906: if ($file['type'] == FileConstants::TYPE_IMAGE) { Line 938: if ($file['type'] == FileConstants::TYPE_IMAGE and $needs_regenerate_sizes) { Line 951: if ($file['type'] == FileConstants::TYPE_IMAGE) { Line 952: $variants = array_merge($variants, array_keys(Kohana::config('file.image_transformations'))); Line 960: // For image variants: Line 983: if ($file['type'] == FileConstants::TYPE_IMAGE) { Line 1151: $tools[] = '<li class="config"><a href="admin/extra/file/redo_sizes">Recreate resized images</a></li>'; Line 1294: * On the fly image resizing Line 1305: $img = new Image($temp_filename); Line 1322: $img->flip(Image::HORIZONTAL); Line 1326: $img->flip(Image::VERTICAL); Line 1334: 'gif' => 'image/gif', Line 1335: 'jpg' => 'image/jpeg', Line 1336: 'jpeg' => 'image/jpeg', Line 1337: 'png' => 'image/png', Line 1456: if ($_GET['f_type'] == FileConstants::TYPE_IMAGE or strpos(File::mimetype($row['filename']), 'image/') === 0) { Line 1481: $sizes = Kohana::config('file.image_transformations'); Line 1541: * Renders a HTML subset containing a focal crop image Line 1544: * @param string $filename E.g. 123_image.jpg
 /sprout/Controllers/EmbedVideoController.php Highlighted file source
Line 22: use Sprout\Helpers\Image; Line 33: * Trims black bars from the top and the bottom of the image Line 52: // Download thumbnail image file Line 59: throw new Exception('Unable to download thumbnail image'); Line 66: $img = new Image($temp_filename); Line 70: $file_size = getimagesize($temp_filename); Line 86: $master = Image::WIDTH; Line 88: $master = Image::HEIGHT; Line 109: header('Content-type: image/jpeg'); Line 122: $black = imagecolorat($img, 1, 1); Line 125: $col = imagecolorat($img, 1, $y);
 /sprout/Controllers/FileController.php Highlighted file source
Line 24: use Sprout\Helpers\Image; Line 35: * Provides access to file and image data Line 41: * On the fly image resizing Line 63: // Prevent browser using cached image if it has been deleted and needs re-creation Line 79: // Look up image in DB and see if it needs author attribution Line 104: $img = new Image($temp_filename); Line 109: throw new Exception('Invalid image resize parameters'); Line 114: $size_limits = Kohana::config('image.max_size'); Line 118: throw new Exception('Image dimensions exceed the maximum limit.'); Line 123: $file_size = File::imageSize($filename); Line 138: $resize_dims = $img->calcResizeDims($width, $height, Image::AUTO); Line 144: $master = Image::WIDTH; Line 146: $master = Image::HEIGHT; Line 152: foreach (FileConstants::$image_ratios as $orient_name => $orient_ratio) { Line 175: $full_dims = File::imageSize($filename); Line 177: if ($master == Image::WIDTH) { Line 187: if ($master == Image::WIDTH) { Line 227: 'gif' => 'image/gif', Line 228: 'jpg' => 'image/jpeg', Line 229: 'jpeg' => 'image/jpeg', Line 230: 'png' => 'image/png', Line 242: // Image Line 298: * @param string $size One of the 'file.image_transformations' config options, e.g. 'small'
 /sprout/Helpers/CropImageTransform.php Highlighted file source
Line 18: * Does image resizing, etc Line 20: class CropImageTransform implements ImageTransform Line 31: * @param int $width The width to crop the image at. Line 32: * @param int $height The height to crop the image at. Line 48: * @param Image $img The image to transform Line 50: public function transform(Image $img)
 /sprout/Helpers/Drivers/Image/GD.php Highlighted file source
Line 16: namespace Sprout\Helpers\Drivers\Image; Line 21: use Sprout\Helpers\Image; Line 22: use Sprout\Helpers\Drivers\ImageDriver; Line 26: * GD Image Driver. Line 28: class GD extends ImageDriver Line 40: throw new Kohana_Exception('image.gd.requires_v2'); Line 47: throw new Kohana_Exception('image.gd.requires_v2'); Line 50: public function process($image, $actions, $dir, $file, $render = FALSE) Line 53: switch ($image['type']) Line 55: case IMAGETYPE_JPEG: Line 56: $create = 'imagecreatefromjpeg'; Line 58: case IMAGETYPE_GIF: Line 59: $create = 'imagecreatefromgif'; Line 61: case IMAGETYPE_PNG: Line 62: $create = 'imagecreatefrompng'; Line 71: $save = 'imagejpeg'; Line 74: $save = 'imagegif'; Line 77: $save = 'imagepng'; Line 81: // Make sure the image type is supported for import Line 83: throw new Kohana_Exception('image.type_not_allowed', $image['file']); Line 85: // Make sure the image type is supported for saving Line 87: throw new Kohana_Exception('image.type_not_allowed', $dir.$file); Line 89: // Load the image Line 90: $this->image = $image; Line 92: // Create the GD image resource Line 93: $this->tmp_image = $create($image['file']); Line 106: imagealphablending($this->tmp_image, TRUE); Line 107: imagesavealpha($this->tmp_image, TRUE); Line 111: case 'imagejpeg': Line 113: imageinterlace($this->tmp_image, Kohana::config('sprout.jpeg_progressive')); Line 115: case 'imagegif': Line 119: case 'imagepng': Line 129: $status = isset($quality) ? $save($this->tmp_image, $dir.$file, $quality) : $save($this->tmp_image, $dir.$file); Line 133: // Output the image directly to the browser Line 136: case 'imagejpeg': Line 137: header('Content-Type: image/jpeg'); Line 139: case 'imagegif': Line 140: header('Content-Type: image/gif'); Line 142: case 'imagepng': Line 143: header('Content-Type: image/png'); Line 147: $status = isset($quality) ? $save($this->tmp_image, NULL, $quality) : $save($this->tmp_image); Line 150: // Destroy the temporary image Line 151: imagedestroy($this->tmp_image); Line 160: $width = imagesx($this->tmp_image); Line 161: $height = imagesy($this->tmp_image); Line 163: // Create the flipped image Line 164: $flipped = $this->imagecreatetransparent($width, $height); Line 166: if ($direction === Image::HORIZONTAL) Line 170: $status = imagecopy($flipped, $this->tmp_image, $x, 0, $width - $x - 1, 0, 1, $height); Line 173: elseif ($direction === Image::VERTICAL) Line 177: $status = imagecopy($flipped, $this->tmp_image, 0, $y, 0, $height - $y - 1, $width, 1); Line 188: // Swap the new image for the old one Line 189: imagedestroy($this->tmp_image); Line 190: $this->tmp_image = $flipped; Line 202: $width = imagesx($this->tmp_image); Line 203: $height = imagesy($this->tmp_image); Line 205: // Create the temporary image to copy to Line 206: $img = $this->imagecreatetransparent($properties['width'], $properties['height']); Line 209: if ($status = imagecopyresampled($img, $this->tmp_image, 0, 0, $properties['left'], $properties['top'], $width, $height, $width, $height)) Line 211: // Swap the new image for the old one Line 212: imagedestroy($this->tmp_image); Line 213: $this->tmp_image = $img; Line 222: $width = imagesx($this->tmp_image); Line 223: $height = imagesy($this->tmp_image); Line 241: if ($properties['master'] === Image::AUTO) Line 244: $properties['master'] = (($width / $properties['width']) > ($height / $properties['height'])) ? Image::WIDTH : Image::HEIGHT; Line 247: if (empty($properties['height']) OR $properties['master'] === Image::WIDTH) Line 253: if (empty($properties['width']) OR $properties['master'] === Image::HEIGHT) Line 277: // Create the temporary image to copy to Line 278: $img = $this->imagecreatetransparent($pre_width, $pre_height); Line 280: if ($status = imagecopyresized($img, $this->tmp_image, 0, 0, 0, 0, $pre_width, $pre_height, $width, $height)) Line 282: // Swap the new image for the old one Line 283: imagedestroy($this->tmp_image); Line 284: $this->tmp_image = $img; Line 292: // Create the temporary image to copy to Line 293: $img = $this->imagecreatetransparent($properties['width'], $properties['height']); Line 296: if ($status = imagecopyresampled($img, $this->tmp_image, 0, 0, 0, 0, $properties['width'], $properties['height'], $width, $height)) Line 298: // Swap the new image for the old one Line 299: imagedestroy($this->tmp_image); Line 300: $this->tmp_image = $img; Line 308: // Use current image to rotate Line 309: $img = $this->tmp_image; Line 312: $transparent = imagecolorallocatealpha($img, 255, 255, 255, 127); Line 315: $img = imagerotate($img, 360 - $amount, $transparent, -1); Line 318: imagecolortransparent($img, $transparent); Line 320: // Merge the images Line 321: if ($status = imagecopymerge($this->tmp_image, $img, 0, 0, 0, 0, imagesx($this->tmp_image), imagesy($this->tmp_image), 100)) Line 324: imagealphablending($img, TRUE); Line 325: imagesavealpha($img, TRUE); Line 327: // Swap the new image for the old one Line 328: imagedestroy($this->tmp_image); Line 329: $this->tmp_image = $img; Line 338: if ( ! function_exists('imageconvolution')) Line 339: throw new Kohana_Exception('image.unsupported_method', __FUNCTION__); Line 353: return imageconvolution($this->tmp_image, $matrix, $amount - 8, 0); Line 358: return array(imagesx($this->tmp_image), imagesy($this->tmp_image)); Line 362: * Returns an image with a transparent background. Used for rotating to Line 365: * @param integer image width Line 366: * @param integer image height Line 369: protected function imagecreatetransparent($width, $height) Line 374: self::$blank_png = imagecreatefromstring(base64_decode Line 385: self::$blank_png_width = imagesx(self::$blank_png); Line 386: self::$blank_png_height = imagesy(self::$blank_png); Line 389: $img = imagecreatetruecolor($width, $height); Line 391: // Resize the blank image Line 392: imagecopyresized($img, self::$blank_png, 0, 0, 0, 0, $width, $height, self::$blank_png_width, self::$blank_png_height); Line 395: imagealphablending($img, FALSE); Line 396: imagesavealpha($img, TRUE); Line 405: $colour = imagecolorallocate($this->tmp_image, 0xFF, 0xFF, 0xFF); Line 408: $fill_colour = imagecolorallocate($this->tmp_image, 0x20, 0x20, 0x20); Line 410: /** Width of image which will have text added */ Line 411: $w = imagesx($this->tmp_image); Line 413: /** Height of image which will have text added */ Line 414: $h = imagesy($this->tmp_image); Line 431: /** Opacity between 0 (retain underlying image) and 100 (completely obscure underlying image) */ Line 435: * Y-point at which text should be rendered inside image. Line 437: * N.B. One would expect the text to start at (image height - text height - border), but the Line 438: * position for imagettftext is based on the font's baseline, which is font dependent but assumed Line 448: $bounds = imagettfbbox($font_size, $angle, $font_file, $text); Line 453: // Don't embed text if it can't fit into the image Line 457: $rect = imagecreatetruecolor($rect_w, $rect_h); Line 458: imagefill($rect, 0, 0, $fill_colour); Line 460: // Merge the rectangle into the original image, with some transparency Line 461: imagealphablending($this->tmp_image, TRUE); Line 462: imagecopymerge($this->tmp_image, $rect, 0, $h - $rect_h, 0, 0, $rect_w, $rect_h, $opacity); Line 466: imagettftext($this->tmp_image, $font_size, $angle, $border, $y, $colour, $font_file, $text); Line 471: } // End Image GD Driver
 /sprout/Helpers/Drivers/Image/GraphicsMagick.php Highlighted file source
Line 16: namespace Sprout\Helpers\Drivers\Image; Line 20: use Sprout\Helpers\Image; Line 21: use Sprout\Helpers\Drivers\ImageDriver; Line 25: * GraphicsMagick Image Driver. Line 27: class GraphicsMagick extends ImageDriver Line 36: // Temporary image filename Line 37: protected $tmp_image; Line 52: throw new Kohana_Exception('image.graphicsmagick.not_found'); Line 62: throw new Kohana_Exception('image.graphicsmagick.not_found', 'gm'.$this->ext); Line 70: * Creates a temporary image and executes the given actions. By creating a Line 71: * temporary copy of the image before manipulating it, this process is atomic. Line 73: public function process($image, $actions, $dir, $file, $render = FALSE) Line 76: $image = $image['file']; Line 79: $this->tmp_image = $dir.'k2img--'.sha1(time().$dir.$file).substr($file, strrpos($file, '.')); Line 81: // Copy the image to the temporary file Line 82: copy($image, $this->tmp_image); Line 92: $this->cmd_image = escapeshellarg($this->tmp_image); Line 93: $this->new_image = ($render)? $this->cmd_image : escapeshellarg($dir.$file); Line 97: // Use convert to change the image into its final version. This is Line 100: if ($error = exec(escapeshellcmd($this->dir.'gm'.$this->ext.' convert').' -quality '.$quality.'% '.$this->cmd_image.' '.$this->new_image)) Line 106: // Output the image directly to the browser Line 109: $contents = file_get_contents($this->tmp_image); Line 114: header('Content-Type: image/jpeg'); Line 117: header('Content-Type: image/gif'); Line 120: header('Content-Type: image/png'); Line 128: // Remove the temporary image Line 129: unlink($this->tmp_image); Line 130: $this->tmp_image = ''; Line 143: if ($error = exec(escapeshellcmd($this->dir.'gm'.$this->ext.' convert').' -crop '.$geometry.' '.$this->cmd_image.' '.$this->cmd_image)) Line 155: $dir = ($dir === Image::HORIZONTAL) ? '-flop' : '-flip'; Line 157: if ($error = exec(escapeshellcmd($this->dir.'gm'.$this->ext.' convert').' '.$dir.' '.$this->cmd_image.' '.$this->cmd_image)) Line 170: case Image::WIDTH: // Wx Line 173: case Image::HEIGHT: // xH Line 176: case Image::AUTO: // WxH Line 179: case Image::NONE: // WxH! Line 185: if ($error = exec(escapeshellcmd($this->dir.'gm'.$this->ext.' convert').' -resize '.$dim.' '.$this->cmd_image.' '.$this->cmd_image)) Line 196: if ($error = exec(escapeshellcmd($this->dir.'gm'.$this->ext.' convert').' -rotate '.escapeshellarg($amt).' -background transparent '.$this->cmd_image.' '.$this->cmd_image)) Line 208: // spread between 1 and 100 without pixelizing the image badly. Line 216: if ($error = exec(escapeshellcmd($this->dir.'gm'.$this->ext.' convert').' -unsharp '.$sharpen.' '.$this->cmd_image.' '.$this->cmd_image)) Line 227: return array_slice(getimagesize($this->tmp_image), 0, 2, FALSE); Line 230: } // End Image GraphicsMagick Driver
 /sprout/Helpers/Drivers/Image/ImageMagick.php Highlighted file source
Line 16: namespace Sprout\Helpers\Drivers\Image; Line 20: use Sprout\Helpers\Image; Line 21: use Sprout\Helpers\Drivers\ImageDriver; Line 25: * ImageMagick Image Driver. Line 27: class ImageMagick extends ImageDriver Line 36: // Temporary image filename Line 37: protected $tmp_image; Line 40: * Attempts to detect the ImageMagick installation directory. Line 52: throw new Kohana_Exception('image.imagemagick.not_found'); Line 62: throw new Kohana_Exception('image.imagemagick.not_found', 'convert'.$this->ext); Line 69: * Creates a temporary image and executes the given actions. By creating a Line 70: * temporary copy of the image before manipulating it, this process is atomic. Line 72: public function process($image, $actions, $dir, $file, $render = FALSE) Line 75: $image = $image['file']; Line 78: $this->tmp_image = $dir.'k2img--'.sha1(time().$dir.$file).substr($file, strrpos($file, '.')); Line 80: // Copy the image to the temporary file Line 81: copy($image, $this->tmp_image); Line 91: $this->cmd_image = escapeshellarg($this->tmp_image); Line 92: $this->new_image = ($render)? $this->cmd_image : escapeshellarg($dir.$file); Line 96: // Use convert to change the image into its final version. This is Line 99: if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' -quality '.$quality.'% '.$this->cmd_image.' '.$this->new_image)) Line 105: // Output the image directly to the browser Line 108: $contents = file_get_contents($this->tmp_image); Line 113: header('Content-Type: image/jpeg'); Line 116: header('Content-Type: image/gif'); Line 119: header('Content-Type: image/png'); Line 127: // Remove the temporary image Line 128: unlink($this->tmp_image); Line 129: $this->tmp_image = ''; Line 142: if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' -crop '.$geometry.' '.$this->cmd_image.' '.$this->cmd_image)) Line 154: $dir = ($dir === Image::HORIZONTAL) ? '-flop' : '-flip'; Line 156: if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' '.$dir.' '.$this->cmd_image.' '.$this->cmd_image)) Line 169: case Image::WIDTH: // Wx Line 172: case Image::HEIGHT: // xH Line 175: case Image::AUTO: // WxH Line 178: case Image::NONE: // WxH! Line 184: if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' -resize '.$dim.' '.$this->cmd_image.' '.$this->cmd_image)) Line 195: if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' -rotate '.escapeshellarg($amt).' -background transparent '.$this->cmd_image.' '.$this->cmd_image)) Line 207: // spread between 1 and 100 without pixelizing the image badly. Line 215: if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' -unsharp '.$sharpen.' '.$this->cmd_image.' '.$this->cmd_image)) Line 226: return array_slice(getimagesize($this->tmp_image), 0, 2, FALSE); Line 229: } // End Image ImageMagick Driver
 /sprout/Helpers/Drivers/ImageDriver.php Highlighted file source
Line 20: * Image API driver. Line 22: abstract class ImageDriver { Line 24: // Reference to the current image Line 25: protected $image; Line 27: // Reference to the temporary processing image Line 28: protected $tmp_image; Line 51: * Sanitize and normalize a geometry array based on the temporary image Line 64: // Width and height cannot exceed current image size Line 101: * Return the current width and height of the temporary image. This is mainly Line 109: * Process an image with a set of actions. Line 111: * @param string image filename Line 117: abstract public function process($image, $actions, $dir, $file); Line 120: * Flip an image. Valid directions are horizontal and vertical. Line 128: * Crop an image. Valid properties are: width, height, top, left. Line 136: * Resize an image. Valid properties are: width, height, and master. Line 144: * Rotate an image. Valid amounts are -180 to 180. Line 152: * Sharpen and image. Valid amounts are 1 to 100. Line 159: } // End Image Driver
 /sprout/Helpers/File.php Highlighted file source
Line 25: * Methods for working with files, including images Line 59: * @param string $original Original image name, e.g. 123_example.jpg Line 60: * @param string $size_name One of the 'file.image_transformations' config options, e.g. 'small' Line 80: * @param string $filename Full filename, e.g. 'image.large.jpg', '/path/to/image.png' Line 225: * Returns the relative URL for a dynamically resized image. Line 240: * Gets the relative URL for a fixed or dynamically resized image Line 244: * The value can either be a size name from the 'file.image_transformations' config option, Line 344: * Returns the size of an image, or false on failure. Line 346: * Output format is the same as getimagesize, but will be at a minimum: Line 352: public static function imageSize($filename) Line 354: return self::backend()->imageSize($filename); Line 360: * If the file is an image, any resized variants (e.g. 'small', 'medium' etc.) are deleted too Line 361: * @param string $filename The name of the file in the repository, e.g. '123_some_image.jpg' Line 369: $transforms = Kohana::config('file.image_transformations'); Line 530: $size_names = Kohana::config('file.image_transformations'); Line 613: // Spekky query for gallery images Line 626: INNER JOIN ~gallery_sources AS src ON src.gallery_id = g.id AND src.type = :type_image Line 630: $params['type_image'] = GalleryConstants::SOURCE_FILES_IMAGE; Line 664: * @return string E.g. 'image/png' Line 692: $size = getimagesize($filename); Line 693: return ($size[2] == IMAGETYPE_JPEG); Line 696: $size = getimagesize($filename); Line 697: return ($size[2] == IMAGETYPE_PNG); Line 700: $size = getimagesize($filename); Line 701: return ($size[2] == IMAGETYPE_GIF); Line 740: return 'image/svg+xml; charset=UTF-8'; Line 850: $img = new Image($temp_filename); Line 857: $file_size = File::imageSize($filename); Line 873: $master = Image::WIDTH; Line 875: $master = Image::HEIGHT; Line 912: * @param array $dimensions Dimensions of the original image; 0 = width, 1 => height Line 920: $sizes = Kohana::config('file.image_transformations'); Line 942: * Create default image sizes as per the config parameter 'file.image_transformations' Line 959: $sizes = Kohana::config('file.image_transformations'); Line 969: // Look up image in DB and see if it needs author attribution Line 986: $img = new Image($temp_filename); Line 995: if ($t instanceof ResizeImageTransform) { Line 1014: throw new Exception('Save of new image failed'); Line 1020: throw new Exception('Image copy of new file into repository failed'); Line 1034: * @param int $file_type The new file type - e.g. DOCUMENT or IMAGE; see FileConstants Line 1054: case FileConstants::TYPE_IMAGE: Line 1062: * Generates a cropped, base-64 encoded thumbnail of an image Line 1063: * @param string $file_path Path to the original image Line 1068: * 'original_width': width of the original image Line 1069: * 'original_height': height of the original image Line 1070: * @return false If file doesn't exist or can't be recognised as an image Line 1075: $size = getimagesize($file_path); Line 1079: $current_size = new ResizeImageTransform($w, $h); Line 1080: $resize = new ResizeImageTransform($width, $height); Line 1087: 'encoded_thumbnail' => Image::base64($file_path, $resize), Line 1097: * @param string $filename Name of file, with no path, e.g. 123_image.jpg Line 1098: * @return string Updated URL (relative to root), e.g. 'files/123_new_image.png' or 'file/download/123' Line 1119: * This only works for full-sized images, e.g. 123_example.jpg, not 123_example.small.jpg Line 1121: * @param string $filename Name of file, with no path, e.g. 123_image.jpg Line 1122: * @return string Updated filename, e.g. '123_new_image.png'
 /sprout/Helpers/FileConvert.php Highlighted file source
Line 24: * - convert (e.g. from the graphicsmagick-imagemagick-compat Debian package) Line 25: * - exiftool (e.g. from the libimage-exiftool-perl Debian package) Line 48: * Note that spreadsheets cannot be directly converted to images, but can be converted to PDFs which can Line 49: * then be converted using {@see FileConvert::imagemagick} Line 84: * Convert file using ImageMagick Line 93: * @throws RuntimeException ImageMagick isn't installed/accessible to PHP Line 94: * @throws FileConversionException ImageMagick failed to convert the file Line 96: public static function imagemagick($in_file, $out_ext, $page_index = 0, $density = 400) { Line 115: throw new RuntimeException("Program 'convert' not installed - try the 'graphicsmagick-imagemagick-compat' package"); Line 117: throw new FileConversionException('Imagemagick converting to ' . $out_ext . ' failed - exec() error'); Line 121: throw new FileConversionException('Imagemagick converting to ' . $out_ext . ' failed - destination file not found'); Line 146: throw new RuntimeException("Program 'exiftool' not installed - try the 'libimage-exiftool-perl' package"); Line 174: * @param string $program The program name; 'libreoffice', 'convert' (i.e. ImageMagick), 'exiftool'
 /sprout/Helpers/Image.php Highlighted file source
Line 23: use Sprout\Helpers\Drivers\ImageDriver; Line 27: * Manipulate images using standard methods such as resize, crop, rotate, etc. Line 28: * This class must be re-initialized for every image you wish to manipulate. Line 30: class Image Line 42: // Allowed image types Line 45: IMAGETYPE_GIF => 'gif', Line 46: IMAGETYPE_JPEG => 'jpg', Line 47: IMAGETYPE_PNG => 'png', Line 48: IMAGETYPE_TIFF_II => 'tiff', Line 49: IMAGETYPE_TIFF_MM => 'tiff', Line 58: // Reference to the current image filename Line 59: protected $image = ''; Line 62: * Creates a new Image instance and returns it. Line 64: * @param string filename of image Line 68: public static function factory($image, $config = NULL) Line 70: return new Image($image, $config); Line 74: * Creates a new image editor instance. Line 77: * @param string filename of image Line 81: public function __construct($image, $config = NULL) Line 86: ($check === NULL) and $check = function_exists('getimagesize'); Line 89: throw new Kohana_Exception('image.getimagesize_missing'); Line 91: // Check to make sure the image exists Line 92: if ( ! is_file($image)) Line 93: throw new Kohana_Exception('image.file_not_found', $image); Line 98: // Fetch the image size and mime type Line 99: $image_info = getimagesize($image); Line 104: // Make sure that the image is readable and valid Line 105: if ( ! is_array($image_info) OR count($image_info) < 3) Line 106: throw new Kohana_Exception('image.file_unreadable', $image); Line 108: // Check to make sure the image type is allowed Line 109: if ( ! isset(Image::$allowed_types[$image_info[2]])) Line 110: throw new Kohana_Exception('image.type_not_allowed', $image); Line 112: // Image has been validated, load it Line 113: $this->image = array Line 115: 'file' => str_replace('\\', '/', realpath($image)), Line 116: 'width' => $image_info[0], Line 117: 'height' => $image_info[1], Line 118: 'type' => $image_info[2], Line 119: 'ext' => Image::$allowed_types[$image_info[2]], Line 120: 'mime' => $image_info['mime'] Line 124: $this->config = (array) $config + Kohana::config('image'); Line 127: $driver = 'Sprout\\Helpers\\Drivers\\Image\\' . ucfirst($this->config['driver']); Line 137: if ( ! ($this->driver instanceof ImageDriver)) Line 138: throw new Kohana_Exception('core.driver_implements', $this->config['driver'], get_class($this), 'ImageDriver'); Line 142: * Handles retrieval of pre-save image properties Line 149: if (isset($this->image[$property])) Line 151: return $this->image[$property]; Line 160: * Resize an image to a specific width and height. By default, Kohana will Line 162: * wish to use height as master dim, set $image->master_dim = Image::HEIGHT Line 168: * @param integer one of: Image::NONE, Image::AUTO, Image::WIDTH, Image::HEIGHT Line 174: throw new Kohana_Exception('image.invalid_width', $width); Line 177: throw new Kohana_Exception('image.invalid_height', $height); Line 180: throw new Kohana_Exception('image.invalid_dimensions', __FUNCTION__); Line 185: $master = Image::AUTO; Line 188: throw new Kohana_Exception('image.invalid_master'); Line 201: * Crop an image to a specific width and height. You may also set the top Line 215: throw new Kohana_Exception('image.invalid_width', $width); Line 218: throw new Kohana_Exception('image.invalid_height', $height); Line 221: throw new Kohana_Exception('image.invalid_top', $top); Line 224: throw new Kohana_Exception('image.invalid_left', $left); Line 227: throw new Kohana_Exception('image.invalid_dimensions', __FUNCTION__); Line 241: * Allows rotation of an image by 180 degrees clockwise or counter clockwise. Line 276: * Flip an image horizontally or vertically. Line 284: if ($direction !== Image::HORIZONTAL AND $direction !== Image::VERTICAL) Line 285: throw new Kohana_Exception('image.invalid_flip'); Line 293: * Change the quality of an image. Line 306: * Sharpen an image. Line 319: * Save the image to a new image or overwrite this image. Line 322: * @param string new image filename Line 323: * @param integer permissions for new image Line 324: * @param boolean keep or discard image process actions Line 327: public function save($new_image = FALSE, $chmod = 0644, $keep_actions = FALSE) Line 329: // If no new image is defined, use the current image Line 330: empty($new_image) and $new_image = $this->image['file']; Line 333: $dir = pathinfo($new_image, PATHINFO_DIRNAME); Line 334: $file = pathinfo($new_image, PATHINFO_BASENAME); Line 340: throw new Kohana_Exception('image.directory_unwritable', $dir); Line 342: if ($status = $this->driver->process($this->image, $this->actions, $dir, $file)) Line 347: @chmod($new_image, $chmod); Line 359: * Output the image to the browser. Line 361: * @param boolean keep or discard image process actions Line 366: $new_image = $this->image['file']; Line 369: $dir = pathinfo($new_image, PATHINFO_DIRNAME); Line 370: $file = pathinfo($new_image, PATHINFO_BASENAME); Line 375: // Process the image with the driver Line 376: $status = $this->driver->process($this->image, $this->actions, $dir, $file, $render = TRUE); Line 438: if ($value !== Image::NONE AND Line 439: $value !== Image::AUTO AND Line 440: $value !== Image::WIDTH AND Line 441: $value !== Image::HEIGHT) Line 451: * Adds text to the base of an image, e.g. for copyright credit Line 452: * @param string $text The text to add to the image Line 453: * @return Image self, for chaining Line 466: * @param int $master Master dimension, e.g. Image::HEIGHT for a portrait image, Line 467: * Image::AUTO for any kind of image Line 472: if ($master == Image::NONE) return [$width, $height]; Line 474: $img_width = $this->image['width']; Line 475: $img_height = $this->image['height']; Line 477: if ($width == 0) $master = Image::HEIGHT; Line 478: if ($height == 0) $master = Image::WIDTH; Line 481: if ($master == Image::AUTO) { Line 483: $master = Image::WIDTH; Line 485: $master = Image::HEIGHT; Line 490: if ($master == Image::WIDTH) { Line 492: } elseif ($master == Image::HEIGHT) { Line 495: $err = 'Invalid master dimension; see Image constants'; Line 504: * Generate a base64-encoded PNG image, e.g. for an <img src="data:image/png;base64,..."> tag Line 507: public static function base64($file_path, ImageTransform $transform = null) Line 509: $img = new Image($file_path); Line 520: } // End Image
 /sprout/Helpers/ImageTransform.php Highlighted file source
Line 18: * Does image resizing, or whatever transforms wanted really. Line 20: interface ImageTransform { Line 25: * @param Image $img The image object to transform. This is an object Line 29: * @see http://docs.kohanaphp.com/libraries/image Line 31: function transform (Image $img);
 /sprout/Helpers/MultiEdit.php Highlighted file source
Line 21: * $images = MultiEdit::load('gallery_images', ['gallery_id' => $gallery_id], 'record_order'); Line 22: * MultiEdit::itemName('Image'); Line 25: * MultiEdit::display('images', $images, @$_SESSION['gallery']['field_errors']['multiedit_images']); Line 97: * e.g. 'image'
 /sprout/Helpers/phpqrcode/qrimage.php Highlighted file source
Line 5: * Image output of code using GD2 Line 25: define('QR_IMAGE', true); Line 27: class QRimage { Line 32: $image = self::image($frame, $pixelPerPoint, $outerFrame, $back_color, $fore_color); Line 35: Header("Content-type: image/png"); Line 36: ImagePng($image); Line 39: ImagePng($image, $filename); Line 40: header("Content-type: image/png"); Line 41: ImagePng($image); Line 43: ImagePng($image, $filename); Line 47: ImageDestroy($image); Line 53: $image = self::image($frame, $pixelPerPoint, $outerFrame); Line 56: Header("Content-type: image/jpeg"); Line 57: ImageJpeg($image, null, $q); Line 59: ImageJpeg($image, $filename, $q); Line 62: ImageDestroy($image); Line 66: private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $back_color = 0xFFFFFF, $fore_color = 0x000000) Line 74: $base_image =ImageCreate($imgW, $imgH); Line 88: $col[0] = ImageColorAllocate($base_image, $r2, $g2, $b2); Line 89: $col[1] = ImageColorAllocate($base_image, $r1, $g1, $b1); Line 91: imagefill($base_image, 0, 0, $col[0]); Line 96: ImageSetPixel($base_image,$x+$outerFrame,$y+$outerFrame,$col[1]); Line 101: $target_image =ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint); Line 102: ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH); Line 103: ImageDestroy($base_image); Line 105: return $target_image;
 /sprout/Helpers/ResizeImageTransform.php Highlighted file source
Line 18: * Does image resizing, etc Line 20: class ResizeImageTransform implements ImageTransform Line 30: * @param int $width The width to resize the image to. Line 31: * @param int $height The height to resize the image to. Line 32: * @param int $master Optional master dimension. Image::WIDTH or Image::HEIGHT Line 45: * @param Image $img The image to transform Line 47: public function transform(Image $img)
 /sprout/Helpers/RteLibraryImages.php Highlighted file source
Line 22: class RteLibraryImages extends RteLibrary Line 24: protected $name = 'Media repository - images'; Line 52: $res = Pdb::query($q, [FileConstants::TYPE_IMAGE], 'pdo'); Line 71: $res = Pdb::query($q, [$cat_id, FileConstants::TYPE_IMAGE], 'pdo'); Line 73: $size = Kohana::config('file.imagelink_size'); Line 110: $params = [FileConstants::TYPE_IMAGE]; Line 121: $size = Kohana::config('file.imagelink_size');
 /sprout/Helpers/TinyMCE4RichText.php Highlighted file source
Line 64: $options['plugins'] = 'anchor code fullscreen image link paste searchreplace table lists visualblocks fullscreen contextmenu stylebuttons media'; Line 87: // Image float fun Line 102: 'styleselect | style-h2 style-h3 style-h4 style-p | bullist numlist indent outdent | alignleft alignright | image media table'
 /sprout/i18n/en_US/image.php Highlighted file source
Line 17: 'getimagesize_missing' => 'The Image library requires the getimagesize() PHP function, which is not available in your installation.', Line 18: 'unsupported_method' => 'Your configured driver does not support the %s image transformation.', Line 19: 'file_not_found' => 'The specified image, %s, was not found. Please verify that images exist by using file_exists() before manipulating them.', Line 20: 'type_not_allowed' => 'The specified image, %s, is not an allowed image type.', Line 28: // ImageMagick specific messages Line 29: 'imagemagick' => array Line 31: 'not_found' => 'The ImageMagick directory specified does not contain a required program, %s.', Line 43: 'requires_v2' => 'The Image library requires GD2. Please see http://php.net/gd_info for more information.',
 /sprout/sprout_load.php Highlighted file source
Line 42: Register::rteLibrary('\\Sprout\\Helpers\\RteLibraryImages'); Line 53: Register::contentReplace('main_content', ['Sprout\\Widgets\\ImageGalleryWidget', 'contentReplace']); Line 94: 'ImageGallery' => 'Image gallery', Line 150: 'ImageGallery' => 'Image gallery',
 /sprout/tests/DocImport/docImportTest.php Highlighted file source
Line 55: * Data for testGetHtmlImages Line 57: public function htmlImagesData() Line 60: array('<img rel="aaa"/>', '<img src="image_aaa.jpg">'), Line 61: array('<p>Hello</p><img rel="aaa"/>', '<p>Hello</p><img src="image_aaa.jpg">'), Line 62: array('<img rel="aaa"/><p>Hello</p>', '<img src="image_aaa.jpg"><p>Hello</p>'), Line 63: array('<img rel="aaa"/><img rel="bbb"/>', '<img src="image_aaa.jpg"><img src="image_bbb.jpg">'), Line 64: array('<img rel="aaa"/><img rel="bbb"/><img rel="ccc"/>', '<img src="image_aaa.jpg"><img src="image_bbb.jpg">'), Line 66: array('<img rel="aaa" width="100" height="150"/>', '<img width="100" height="150" src="image_aaa.jpg">'), Line 67: array('<img rel="aaa" width="" height=""/>', '<img src="image_aaa.jpg">'), Line 68: array('<img rel="aaa" width="0" height="0"/>', '<img src="image_aaa.jpg">'), Line 79: * Image getHtml tests Line 81: * @dataProvider htmlImagesData Line 83: public function testGetHtmlImages($xml, $expect) Line 86: 'aaa' => 'image_aaa.jpg', Line 87: 'bbb' => 'image_bbb.jpg', Line 110: * Image getHtml tests
 /sprout/views/admin/file_edit.php Highlighted file source
Line 30: if ($data['type'] == FileConstants::TYPE_IMAGE) { Line 31: Needs::fileGroup('sprout/image_edit'); Line 40: <?php if ($data['type'] == FileConstants::TYPE_IMAGE): ?> Line 41: <li><a href="#main-tabs-manipulate">Manipulate image</a></li> Line 90: <?php if ($data['type'] == FileConstants::TYPE_IMAGE): ?><th>Image dimensions</th><?php endif; ?> Line 96: <?php if ($data['type'] == FileConstants::TYPE_IMAGE): ?><td><?= Enc::html($img_dimensions); ?></td><?php endif; ?> Line 104: <?php if ($data['type'] == FileConstants::TYPE_IMAGE): ?> Line 125: $dimensions = File::imageSize($filename); Line 144: <?php if ($data['type'] == FileConstants::TYPE_IMAGE): ?> Line 146: <?= Fb::heading('Manipulate image'); ?> Line 155: <?php if (function_exists('imagerotate')): ?> Line 171: <p><strong>Original image:</strong></p> Line 172: <img src="<?= Enc::html($original_image); ?>" alt=""> Line 176: <p><b>New image:</b></p> Line 187: <p>Click the position on the image where you want the focal point to be set.</p> Line 188: <p>When the image is resized, the resizing will be done so that the focal point is always visible, and as close to the centre as possible.</p> Line 190: image in all orientations. However, if you need more control, you can choose a different focal points for Line 191: any particular orientations. Click an orientation and then click within the image to set a specific focal Line 204: <input type="hidden" id="image-focal-points" name="focal_points" value="<?= Enc::html(@$data['focal_points']); ?>"> Line 209: <p>Please note that this is just an example of the type of orientation, and does not represent how the image will look on your site.</p> Line 211: <p><span id="focal-point-preview-image"></span></p>
 /sprout/views/tinymce4/image_size.php Highlighted file source
Line 25: Choose the size you would like to insert the image <b><?php echo Enc::html($image['name']); ?></b>. Line 37: echo '<a href="javascript:;" data-src="', Enc::html(File::sizeUrl($image['id'], $size)), '" data-alt="', Enc::html($image['name']), '">', ucwords(str_replace('_', ' ', $size)), '</a>'; Line 41: echo '<a href="javascript:;" data-src="', Enc::html(File::relUrl($image['id'])), '" data-alt="', Enc::html($image['name']), '">Original</a>'; Line 51: TinyMCE4.setField("Image description", $(this).attr("data-alt"));
 /sprout/Widgets/ImageGalleryWidget.php Highlighted file source
Line 28: class ImageGalleryWidget extends Widget Line 30: protected $friendly_name = "Image Gallery"; Line 31: protected $friendly_desc = 'A gallery of images from your media repository'; Line 37: public $classname = 'ImageGallery'; Line 89: $this->settings['num_images'] = (int) @$this->settings['num_images']; Line 90: if ($this->settings['num_images'] < 1) $this->settings['num_images'] = 1; Line 143: $images = array(); Line 146: $images[] = $row; Line 151: $config = Kohana::config('sprout.image_gallery'); Line 164: $view = new View('sprout/image_gallery_tall_' . $this->settings['display_opts']); Line 166: $view = new View('sprout/image_gallery_wide_' . $this->settings['display_opts']); Line 171: $image_resize = 'thumb_size_2'; Line 175: $image_resize = 'thumb_size_3'; Line 179: $image_resize = 'thumb_size_4'; Line 183: $image_resize = 'thumb_size_5'; Line 190: $view->images = $images; Line 198: $view->slider_images = $this->settings['num_images']; Line 217: $cats = Pdb::query($q, [FileConstants::TYPE_IMAGE], 'map'); Line 230: * Returns the SQL which should be used for ordering the images Line 333: $widget = Widgets::render(WidgetArea::ORIENTATION_EMAIL, 'Sprout\Widgets\ImageGalleryWidget', [
A total of 700 lines in 43 files were found
|