コード例 #1
0
ファイル: user.php プロジェクト: laiello/my-imouto-booru
 function reduce_and_crop($image_width, $image_height, $params)
 {
     $cropped_image_width = $image_width * ($params['right'] - $params['left']);
     $cropped_image_height = $image_height * ($params['bottom'] - $params['top']);
     $size = Danbooru::reduce_to(array('width' => $cropped_image_width, 'height' => $cropped_image_height), array('width' => CONFIG::avatar_max_width, 'height' => CONFIG::avatar_max_height), 1, true);
     $size['crop_top'] = $image_height * $params['top'];
     $size['crop_bottom'] = $image_height * $params['bottom'];
     $size['crop_left'] = $image_width * $params['left'];
     $size['crop_right'] = $image_width * $params['right'];
     return $size;
 }
コード例 #2
0
ファイル: post.php プロジェクト: laiello/my-imouto-booru
 function generate_preview()
 {
     if (!$this->is_image() && !$this->width && !$this->height) {
         return true;
     }
     $size = Danbooru::reduce_to(array('width' => $this->width, 'height' => $this->height), array('width' => 300, 'height' => 300));
     # Generate the preview from the new sample if we have one to save CPU, otherwise from the image.
     if (file_exists($this->tempfile_sample_path())) {
         list($path, $ext) = array($this->tempfile_sample_path(), "jpg");
     } elseif (file_exists($this->sample_path())) {
         list($path, $ext) = array($this->sample_path(), "jpg");
     } elseif (file_exists($this->tempfile_path)) {
         list($path, $ext) = array($this->tempfile_path, $this->file_ext);
     } elseif (file_exists($this->file_path())) {
         list($path, $ext) = array($this->file_path(), $this->file_ext);
     } else {
         return false;
     }
     try {
         Danbooru::resize($ext, $path, $this->tempfile_preview_path(), $size, 85);
     } catch (Exception $e) {
         $this->record_errors->add("preview", "couldn't be generated ({$e->getMessage()})");
         return false;
     }
     $this->actual_preview_width = $this->raw_preview_dimensions('w');
     $this->actual_preview_height = $this->raw_preview_dimensions('h');
     $this->preview_width = $this->preview_dimensions('w');
     $this->preview_height = $this->preview_dimensions('h');
     return true;
 }