Some sweeping syntax changes for consistency:

(! foo) changed to ( ! foo)
|| changed to OR
changed newline standardization code in various places from preg_replace to str_replace
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 4017afb..a602b46 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1,4 +1,4 @@
-<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

 /**

  * CodeIgniter

  *

@@ -158,7 +158,7 @@
 		 * properties using ImageMagick and NetPBM

 		 *

 		 */		

-		if (! function_exists('getimagesize'))

+		if ( ! function_exists('getimagesize'))

 		{

 			$this->set_error('imglib_gd_required_for_props');

 			return FALSE;		

@@ -188,7 +188,7 @@
 		$this->source_folder = str_replace($this->source_image, '', $full_source_path);

 								

 		// Set the Image Properties

-		if (! $this->get_image_properties($this->source_folder.$this->source_image))

+		if ( ! $this->get_image_properties($this->source_folder.$this->source_image))

 		{

 			return FALSE;	   	

 		}				

@@ -226,7 +226,7 @@
 				}

 				

 				// Is there a file name?

-				if (! preg_match("#[\.jpg|\.jpeg|\.gif|\.png]$#i", $full_dest_path))

+				if ( ! preg_match("#[\.jpg|\.jpeg|\.gif|\.png]$#i", $full_dest_path))

 				{

 					$this->dest_folder = $full_dest_path.'/';

 					$this->dest_image = $this->source_image;

@@ -478,7 +478,7 @@
 			// we'll simply make a copy of the original with the new name		

 			if (($this->orig_width == $this->width AND $this->orig_height == $this->height) AND ($this->source_image != $this->new_image))			

 			{

-				if (! @copy($this->full_src_path, $this->full_dst_path))

+				if ( ! @copy($this->full_src_path, $this->full_dst_path))

 				{

 					$this->set_error('imglib_copy_failed');

 					return FALSE;

@@ -494,7 +494,7 @@
 		}

 		

 		//  Create the image handle

-		if (! ($src_img = $this->image_create_gd()))

+		if ( ! ($src_img = $this->image_create_gd()))

 		{		

 			return FALSE;

 		}

@@ -528,7 +528,7 @@
 		else

 		{

 			// Or save it

-			if (! $this->image_save_gd($dst_img))

+			if ( ! $this->image_save_gd($dst_img))

 			{

 				return FALSE;

 			}

@@ -564,9 +564,9 @@
 			return FALSE;

 		}

 				

-		if (! eregi("convert$", $this->library_path))

+		if ( ! eregi("convert$", $this->library_path))

 		{

-			if (! eregi("/$", $this->library_path)) $this->library_path .= "/";

+			if ( ! eregi("/$", $this->library_path)) $this->library_path .= "/";

 		

 			$this->library_path .= 'convert';

 		}

@@ -712,14 +712,14 @@
 	{	

 		// Is Image Rotation Supported?

 		// this function is only supported as of PHP 4.3

-		if (! function_exists('imagerotate'))

+		if ( ! function_exists('imagerotate'))

 		{

 			$this->set_error('imglib_rotate_unsupported');

 			return FALSE;

 		}

 		

 		//  Create the image handle

-		if (! ($src_img = $this->image_create_gd()))

+		if ( ! ($src_img = $this->image_create_gd()))

 		{		

 			return FALSE;

 		}

@@ -742,7 +742,7 @@
 		else

 		{

 			// Or save it

-			if (! $this->image_save_gd($dst_img))

+			if ( ! $this->image_save_gd($dst_img))

 			{

 				return FALSE;

 			}

@@ -771,7 +771,7 @@
 	 */			

 	function image_mirror_gd()

 	{		

-		if (! $src_img = $this->image_create_gd())

+		if ( ! $src_img = $this->image_create_gd())

 		{

 			return FALSE;

 		}

@@ -828,7 +828,7 @@
 		else

 		{

 			// Or save it

-			if (! $this->image_save_gd($src_img))

+			if ( ! $this->image_save_gd($src_img))

 			{

 				return FALSE;

 			}

@@ -877,7 +877,7 @@
 	 */			

 	function overlay_watermark()

 	{

-		if (! function_exists('imagecolortransparent'))

+		if ( ! function_exists('imagecolortransparent'))

 		{

 			$this->set_error('imglib_gd_required');

 			return FALSE;		

@@ -968,7 +968,7 @@
 		}

 		else

 		{

-			if (! $this->image_save_gd($src_img))

+			if ( ! $this->image_save_gd($src_img))

 			{

 				return FALSE;

 			}

@@ -990,7 +990,7 @@
 	 */			

 	function text_watermark()

 	{

-		if (! ($src_img = $this->image_create_gd()))

+		if ( ! ($src_img = $this->image_create_gd()))

 		{		

 			return FALSE;

 		}

@@ -1144,7 +1144,7 @@
 		switch ($image_type)

 		{

 			case	 1 :

-						if (! function_exists('imagecreatefromgif'))

+						if ( ! function_exists('imagecreatefromgif'))

 						{

 							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));

 							return FALSE;

@@ -1153,7 +1153,7 @@
 						return imagecreatefromgif($path);

 				break;

 			case 2 :

-						if (! function_exists('imagecreatefromjpeg'))

+						if ( ! function_exists('imagecreatefromjpeg'))

 						{

 							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));

 							return FALSE;

@@ -1162,7 +1162,7 @@
 						return imagecreatefromjpeg($path);

 				break;

 			case 3 :

-						if (! function_exists('imagecreatefrompng'))

+						if ( ! function_exists('imagecreatefrompng'))

 						{

 							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));				

 							return FALSE;

@@ -1194,7 +1194,7 @@
 		switch ($this->image_type)

 		{

 			case 1 :

-						if (! function_exists('imagegif'))

+						if ( ! function_exists('imagegif'))

 						{

 							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));

 							return FALSE;		

@@ -1203,7 +1203,7 @@
 						@imagegif($resource, $this->full_dst_path);

 				break;

 			case 2	:

-						if (! function_exists('imagejpeg'))

+						if ( ! function_exists('imagejpeg'))

 						{

 							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));

 							return FALSE;		

@@ -1217,7 +1217,7 @@
 						@imagejpeg($resource, $this->full_dst_path, $this->quality);

 				break;

 			case 3	:

-						if (! function_exists('imagepng'))

+						if ( ! function_exists('imagepng'))

 						{

 							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));

 							return FALSE;		

@@ -1280,10 +1280,10 @@
 	 */			

 	function image_reproportion()

 	{

-		if (! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0)

+		if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0)

 			return;

 		

-		if (! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0)

+		if ( ! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0)

 			return;

 		

 		$new_width	= ceil($this->orig_width*$this->height/$this->orig_height);		

@@ -1328,7 +1328,7 @@
 		if ($path == '')

 			$path = $this->full_src_path;

 				

-		if (! file_exists($path))

+		if ( ! file_exists($path))

 		{

 			$this->set_error('imglib_invalid_path');		

 			return FALSE;				

@@ -1382,14 +1382,14 @@
 	 */			

 	function size_calculator($vals)

 	{

-		if (! is_array($vals))

+		if ( ! is_array($vals))

 			return;

 			

 		$allowed = array('new_width', 'new_height', 'width', 'height');

 	

 		foreach ($allowed as $item)

 		{

-			if (! isset($vals[$item]) OR $vals[$item] == '')

+			if ( ! isset($vals[$item]) OR $vals[$item] == '')

 				$vals[$item] = 0;

 		}

 		

@@ -1460,9 +1460,9 @@
 	 */	

 	function gd_loaded()

 	{

-		if (! extension_loaded('gd'))

+		if ( ! extension_loaded('gd'))

 		{

-			if (! dl('gd.so'))

+			if ( ! dl('gd.so'))

 			{

 				return FALSE;

 			}