function process_form() { $angle = required_param('angle', PARAM_INT); $info = lightboxgallery_image_info($this->imagepath); if ($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $this->imagepath)) { $rotated = imagerotate($im, $angle, 0); $this->save_image_resource($rotated, $info->imagesize[2]); } }
function process_form() { $x1 = required_param('x1', PARAM_INT); $y1 = required_param('y1', PARAM_INT); $x2 = required_param('x2', PARAM_INT); $y2 = required_param('y2', PARAM_INT); $width = $x2 - $x1; $height = $y2 - $y1; $info = lightboxgallery_image_info($this->imagepath); if ($width > 0 && $height > 0) { if ($image = lightboxgallery_imagecreatefromtype($info->imagesize[2], $this->imagepath)) { $cropped = lightboxgallery_image_create($width, $height); imagecopybicubic($cropped, $image, 0, 0, $x1, $y1, $width, $height, $width, $height); $this->save_image_resource($cropped, $info->imagesize[2]); } } }
function process_form() { $button = required_param('button', PARAM_TEXT); switch ($button) { case $this->buttonresize: $size = required_param('size', PARAM_INT); list($width, $height) = explode('x', $this->resizeoptions[$size]); break; case $this->buttonscale: $scale = required_param('scale', PARAM_INT); $imagesize = getimagesize($this->imagepath); $width = $imagesize[0] * ($scale / 100); $height = $imagesize[1] * ($scale / 100); break; } $info = lightboxgallery_image_info($this->imagepath); if ($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $this->imagepath)) { $resized = lightboxgallery_resize_image($im, $info, $width, $height); $this->save_image_resource($resized, $info->imagesize[2]); } }
function process_form() { global $CFG; $mode = required_param('mode', PARAM_INT); $info = lightboxgallery_image_info($this->imagepath); $w = $info->imagesize[0]; $h = $info->imagesize[1]; if ($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $this->imagepath)) { $truecolor = (function_exists('ImageCreateTrueColor') and $CFG->gdversion >= 2); $flipped = $truecolor ? ImageCreateTrueColor($w, $h) : ImageCreate($w, $h); if ($mode & FLIP_VERTICAL) { if ($truecolor) { for ($x = 0; $x < $w; $x++) { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $im, $w - $x - 1, $y, $x, $y, 1, 1); } } } else { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $im, 0, $y, 0, $h - $y - 1, $w, 1); } } } if ($mode & FLIP_HORIZONTAL) { if ($truecolor) { for ($x = 0; $x < $w; $x++) { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $im, $x, $h - $y - 1, $x, $y, 1, 1); } } } else { for ($x = 0; $x < $w; $x++) { imagecopy($flipped, $im, $x, 0, $w - $x - 1, 0, 1, $h); } } } $this->save_image_resource($flipped, $info->imagesize[2]); } }
function lightboxgallery_image_thumbnail($courseid, $gallery, $file, $offsetx = 0, $offsety = 0) { global $CFG; // If anything fails when retrieving the thumbnail, we'll fallback to just printing a label $fallback = '[' . $file . ']'; $oldpath = $CFG->dataroot . '/' . $courseid . '/' . $gallery->folder . '/' . $file; $newpath = $courseid . '/' . $gallery->folder . '/_thumb/' . $file . '.jpg'; if (empty($CFG->gdversion)) { return $fallback; } umask(00); if (file_exists($CFG->dataroot . '/' . $newpath)) { return lightboxgallery_make_img(lightboxgallery_get_image_url($gallery->id, $file, true)); } else { $thumbdir = $CFG->dataroot . '/' . dirname($newpath); if (!file_exists($thumbdir) && !mkdir($thumbdir, $CFG->directorypermissions)) { return $fallback; } } $info = lightboxgallery_image_info($oldpath); if (!($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $oldpath))) { return $fallback; } $thumb = lightboxgallery_resize_image($im, $info, THUMB_WIDTH, THUMB_HEIGHT, $offsetx, $offsety); if (function_exists('ImageJpeg')) { @touch($CFG->dataroot . '/' . $newpath); if (ImageJpeg($thumb, $CFG->dataroot . '/' . $newpath, 90)) { @chmod($CFG->dataroot . '/' . $newpath, 0666); return lightboxgallery_make_img(lightboxgallery_get_image_url($gallery->id, $file, true)); } } else { return $fallback; } }
lightboxgallery_set_image_caption($gallery->id, $filename, $formdata->caption); $messages[] = get_string('edit_caption', 'lightboxgallery') . ': ' . $formdata->caption; } $resizeoption = 0; if (in_array($gallery->autoresize, array(AUTO_RESIZE_UPLOAD, AUTO_RESIZE_BOTH))) { $resizeoption = $gallery->resize; } else { if (isset($formdata->resize)) { $resizeoption = $formdata->resize; } } if ($resizeoption > 0) { $resizeoptions = lightboxgallery_resize_options(); $fullpath = $CFG->dataroot . '/' . $uploaddir . '/' . $filename; $info = lightboxgallery_image_info($fullpath); if ($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $fullpath)) { list($width, $height) = explode('x', $resizeoptions[$resizeoption]); if ($resized = lightboxgallery_resize_image($im, $info, $width, $height)) { switch ($info->imagesize[2]) { case 1: $function = 'ImageGIF'; break; case 2: $function = 'ImageJPEG'; break; case 3: $function = 'ImagePNG'; break; } if (function_exists($function)) { $function($resized, $fullpath, $info->imagesize[2] == 3 ? 9 : 100);