function ctools_stylizer_image_processor::command_slice in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/stylizer.inc \ctools_stylizer_image_processor::command_slice()
Take a slice out of the current workspace and save it as an image.
File
- includes/
stylizer.inc, line 563 - Create customized CSS and images from palettes created by user input.
Class
Code
function command_slice($file, $x = NULL, $y = NULL, $width = NULL, $height = NULL) {
if (!isset($x)) {
$x = $y = 0;
$width = imagesx($this->workspace);
$height = imagesy($this->workspace);
}
$this
->log("Slice: {$file} ({$x}, {$y}, {$width}, {$height})");
$base = basename($file);
$image = $this->path . '/' . $base;
$slice = $this
->new_image($this->workspace, $width, $height);
imagecopy($slice, $this->workspace, 0, 0, $x, $y, $width, $height);
// Make sure alphas are saved:
imagealphablending($slice, FALSE);
imagesavealpha($slice, TRUE);
// Save image.
imagepng($slice, $image);
imagedestroy($slice);
// Set standard file permissions for webserver-generated files
@chmod(realpath($image), 0664);
$this->paths[$file] = $image;
}