Esempio n. 1
0
 public function resize()
 {
     $md5 = md5_file($this->file);
     $newresized = IMAGES . SL . 'booru' . SL . 'resized' . SL . $md5 . '.jpg';
     $this->worker = Transform_Image::get_worker($this->file);
     $this->animated = $this->is_animated($this->file);
     $resized = $this->check_resize($newresized);
     return $resized;
 }
Esempio n. 2
0
 protected function process()
 {
     global $key;
     $newthumb = '/var/www/frontend/demo/art/_' . $key . '.jpg';
     $this->worker = Transform_Image::get_worker($this->file);
     $this->animated = $this->is_animated($this->file);
     $this->scale(array(150, 150), $newthumb);
     $this->set(array());
 }
Esempio n. 3
0
 protected function process()
 {
     $thumb = md5(microtime(true));
     $newthumb = IMAGES . SL . 'avatar' . SL . $thumb . '.jpg';
     chmod($this->file, 0755);
     $this->worker = Transform_Image::get_worker($this->file);
     $this->animated = $this->is_animated($this->file);
     $this->scale(array(Config::get('avatar', 'width'), Config::get('avatar', 'height')), $newthumb);
     $this->set(array('thumb' => $thumb));
 }
Esempio n. 4
0
 protected static function get_worker_name()
 {
     if (empty(self::$worker_name)) {
         if (!class_exists('Imagick', false)) {
             self::$worker_name = 'Transform_Image_Gd';
         } else {
             self::$worker_name = 'Transform_Image_Imagick';
         }
     }
     return self::$worker_name;
 }
Esempio n. 5
0
 protected function process()
 {
     $time = str_replace('.', '', microtime(true));
     $extension = strtolower(pathinfo($this->name, PATHINFO_EXTENSION));
     $newfile = IMAGES . SL . 'news' . SL . 'full' . SL . $time . '.' . $extension;
     $newthumb = IMAGES . SL . 'news' . SL . 'thumb' . SL . $time . '.jpg';
     chmod($this->file, 0755);
     if (!move_uploaded_file($this->file, $newfile)) {
         file_put_contents($newfile, file_get_contents($this->file));
     }
     $this->worker = Transform_Image::get_worker($newfile);
     $this->scale(array(0 => 200, 1 => 150), $newthumb);
     $this->set(array('success' => true, 'image' => SITE_DIR . '/images/news/thumb/' . $time . '.jpg', 'data' => $time . '.' . $extension));
 }
Esempio n. 6
0
 protected function process()
 {
     $pathinfo = pathinfo($this->name);
     if (!file_exists(IMAGES . SL . 'small' . $pathinfo['dirname'])) {
         mkdir(IMAGES . SL . 'small' . $pathinfo['dirname']);
     }
     if (!file_exists(IMAGES . SL . 'full' . $pathinfo['dirname'])) {
         mkdir(IMAGES . SL . 'full' . $pathinfo['dirname']);
     }
     $newthumb = IMAGES . SL . 'small' . $pathinfo['dirname'] . SL . $pathinfo['filename'] . '.jpg';
     chmod($this->file, 0755);
     $this->worker = Transform_Image::get_worker($this->file);
     $this->animated = false;
     if ($this->info[0] > Config::get('card', 'full_width')) {
         $this->scale(array(Config::get('card', 'full_width'), Config::get('card', 'full_height')), IMAGES . SL . 'full' . SL . $this->name);
     } else {
         copy($this->file, IMAGES . SL . 'full' . SL . $this->name);
     }
     $this->scale(array(Config::get('card', 'width'), Config::get('card', 'height')), $newthumb);
 }
Esempio n. 7
0
 protected function process()
 {
     $md5 = md5_file($this->file);
     $extension = strtolower(pathinfo($this->name, PATHINFO_EXTENSION));
     $newname = $md5 . '.' . $extension;
     $newfile = IMAGES . SL . 'board' . SL . 'full' . SL . $newname;
     chmod($this->file, 0755);
     if (!file_exists($newfile)) {
         if (!move_uploaded_file($this->file, $newfile)) {
             file_put_contents($newfile, file_get_contents($this->file));
         }
     }
     $thumb = md5(microtime(true));
     $newthumb = IMAGES . SL . 'board' . SL . 'thumbs' . SL . $thumb . '.jpg';
     $this->worker = Transform_Image::get_worker($newfile);
     $width = $this->worker->get_image_width();
     $height = $this->worker->get_image_height();
     $this->scale(array(def::board('thumbwidth'), def::board('thumbheight')), $newthumb);
     $this->set(array('success' => true, 'image' => SITE_DIR . '/images/board/thumbs/' . $thumb . '.jpg', 'data' => $newname . '#' . $thumb . '.jpg#' . $this->size . '#' . $width . 'x' . $height, 'full' => $newname, 'thumb' => $thumb, 'size' => $this->size, 'width' => $width, 'height' => $height));
 }
Esempio n. 8
0
 protected function scale_animated($new_size, $target)
 {
     $worker = $this->worker;
     $old_x = $worker->get_image_width();
     $old_y = $worker->get_image_height();
     $this->sizes = $old_x . 'x' . $old_y;
     $aspect = !empty($new_size) ? $new_size[0] / $old_x : 1 / 2;
     $x = round($old_x * $aspect);
     $y = round($old_y * $aspect);
     do {
         $worker->scale_image($x, $y, 1);
     } while ($worker->next_image());
     $worker = $worker->deconstruct_images();
     $target = preg_replace('/\\.jpe?g$/i', '.gif', $target);
     $worker->write_images($target, true);
     $worker->clear();
     $this->worker = Transform_Image::get_worker($target);
     return true;
 }
Esempio n. 9
0
	protected function save ($image_data, $username, $timer = 0) {
		
		$image_file = $this->get_temp_file($image_data);		
		$image = new Transform_Image($image_file);
		
		$format = strtolower($image->get_format());
		$time = time();
		
		$save_full = IMAGES.SL.'gallery'.SL.$this->user_id.SL.'full'.SL.$time.'.'.$format;
		$save_resized = IMAGES.SL.'gallery'.SL.$this->user_id.SL.'resized'.SL.$time.'.jpg';
		$save_large_thumbnail = IMAGES.SL.'gallery'.SL.$this->user_id.SL.'large_thumbnail'.SL.$time.'.jpg';
		$save_thumbnail = IMAGES.SL.'gallery'.SL.$this->user_id.SL.'thumbnail'.SL.$time.'.jpg';		
		
		$this->test_upload_dirs('gallery', $this->user_id, 'full');
		$this->test_upload_dirs('gallery', $this->user_id, 'resized');
		$this->test_upload_dirs('gallery', $this->user_id, 'large_thumbnail');
		$this->test_upload_dirs('gallery', $this->user_id, 'thumbnail');		
		
		$resized = 0;
		$resized_settings = Config::image('resized');
		$large_thumbnail_settings = Config::image('large_thumbnail');
		$thumbnail_settings = Config::image('thumbnail');
		
		$image->save($save_full);
		
		if (
			$image->get_width() > $resized_settings['width'] ||
			$image->get_height() > $resized_settings['height']
		) {
			$resized = min(
				$resized_settings['width'] / $image->get_width(),
				$resized_settings['height'] / $image->get_height()
			);			
			
			$image->target($save_resized)->scale(
				array(
					$resized_settings['width'], 
					$resized_settings['height']
				),
				$resized_settings['compression']
			);
			$image = new Transform_Image($save_resized);
		}
		
		$image->target($save_large_thumbnail)->scale(
			array(
				$large_thumbnail_settings['width'], 
				$large_thumbnail_settings['height']
			),
			$large_thumbnail_settings['compression'],
			true
		);
		$image = new Transform_Image($save_large_thumbnail);
		
		$image->target($save_thumbnail)->scale(
			array(
				$thumbnail_settings['width'], 
				$thumbnail_settings['height']
			),
			$thumbnail_settings['compression'],
			true
		);
		
		Art_Input::save($save_full, $username, $resized, $this->user_id, $timer);
	}