function 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 555
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.
$temp_name = drupal_tempnam('temporary://', 'file');
imagepng($slice, drupal_realpath($temp_name));
file_unmanaged_move($temp_name, $image);
imagedestroy($slice);
// Set standard file permissions for webserver-generated files
@chmod(realpath($image), 0664);
$this->paths[$file] = $image;
}