Exemplo n.º 1
0
 function _upload_success($image_path, $image_url)
 {
     if ($res = image_is_too_big($image_path)) {
         $this->too_big = true;
         $this->set_error('The chosen image is too large for the server to process. The uncompressed image is ' . format_bytes_as_human_readable($res['image_size']) . ' bytes. Only ' . format_bytes_as_human_readable($res['size_limit']) . ' bytes of memory may be used for processing images of this type.');
     } else {
         if ($this->_needs_resizing($image_path)) {
             $this->_resize_image($image_path);
         }
     }
     parent::_upload_success($image_path, $image_url);
 }
Exemplo n.º 2
0
 /**
  *
  */
 function verify_image($img_pathname)
 {
     // return true if the image is an image, false otherwise
     $size = getimagesize($img_pathname);
     if (!$size) {
         trigger_error('Uploaded image at location ' . $img_pathname . ' returns false on getimagesize and will not be imported. The user has been notified.');
         return false;
     } elseif (image_is_too_big($img_pathname)) {
         trigger_error('Uploaded image at location ' . $img_pathname . ' is too big and will not be imported. The user has been notified.');
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
		// fix a permission idiosyncrasy so the permissions are consistent
		@copy($temp_path, $temp_path.".tmp");
		@rename($temp_path.".tmp", $temp_path);
		list($orig_width, $orig_height) = $img_info;
		list($width, $height) = $img_info;
		
		// If exceeds width or height limit, store an original and resize the standard image
		if ($constraints && !empty($constraints['max_dimensions'])) {
			list($max_width, $max_height) = $constraints['max_dimensions'];
			
			if ($width > $max_width || $height > $max_height) {
				$unscaled_path = add_name_suffix($temp_path, '-unscaled');
				if (@copy($temp_path, $unscaled_path)) {
				
					//Make sure the image won't make php crash:
					if(image_is_too_big($temp_path))
					{
						final_response(422, "The uploaded image's dimensions are too large for the server to process. Try a smaller image.");
					}

				
					if (resize_image($temp_path, $max_width, $max_height)) {
						list($width, $height) = getimagesize($temp_path);
						clearstatcache();
						$filesize = filesize($temp_path);
					} else {
						@unlink($unscaled_path);
						$unscaled_path = null;
					}
				}
			}