From 114ab0988e20ac6be39ad363ff897a1a3b85e565 Mon Sep 17 00:00:00 2001
From: Razican All three major image libraries are supported: GD/GD2, NetPBM, and ImageMagick All three major image libraries are supported: GD/GD2, NetPBM, and ImageMagick Note: Watermarking is only available using the GD/GD2 library.
In addition, even though other libraries are supported, GD is required in
-order for the script to calculate the image properties. The image processing, however, will be performed with the
+order for the script to calculate the image properties. The image processing, however, will be performed with the
library you specify.
$this->load->library('image_lib');
-Once the library is loaded it will be ready for use. The image library object you will use to call all functions is: $this->image_lib
+Once the library is loaded it will be ready for use. The image library object you will use to call all functions is: $this->image_lib
Regardless of the type of processing you would like to perform (resizing, cropping, rotation, or watermarking), the general process is identical. You will set some preferences corresponding to the action you intend to perform, then -call one of four available processing functions. For example, to create an image thumbnail you'll do this:
+call one of four available processing functions. For example, to create an image thumbnail you'll do this:$config['image_library'] = 'gd2';
$config['source_image'] = '/path/to/image/mypic.jpg';
@@ -106,7 +106,7 @@ $this->image_lib->resize();
The above code tells the image_resize function to look for an image called mypic.jpg located in the source_image folder, then create a thumbnail that is 75 X 50 pixels using the GD2 image_library. Since the maintain_ratio option is enabled, the thumb will be as close to the target width and -height as possible while preserving the original aspect ratio. The thumbnail will be called mypic_thumb.jpg +height as possible while preserving the original aspect ratio. The thumbnail will be called mypic_thumb.jpg
Note: In order for the image class to be allowed to do any processing, the @@ -126,7 +126,7 @@ folder containing the image files must have write permissions.
These functions return boolean TRUE upon success and FALSE for failure. If they fail you can retrieve the +
These functions return boolean TRUE upon success and FALSE for failure. If they fail you can retrieve the error message using this function:
echo $this->image_lib->display_errors();
@@ -138,7 +138,7 @@ error message using this function:
echo $this->image_lib->display_errors();Note: You can optionally specify the HTML formatting to be applied to the errors, by submitting the opening/closing +
Note: You can optionally specify the HTML formatting to be applied to the errors, by submitting the opening/closing tags in the function, like this:
$this->image_lib->display_errors('<p>', '</p>');
@@ -146,11 +146,11 @@ tags in the function, like this:
The preferences described below allow you to tailor the image processing to suit your needs.
+The preferences described below allow you to tailor the image processing to suit your needs.
Note that not all preferences are available for every -function. For example, the x/y axis preferences are only available for image cropping. Likewise, the width and height -preferences have no effect on cropping. The "availability" column indicates which functions support a given preference.
+function. For example, the x/y axis preferences are only available for image cropping. Likewise, the width and height +preferences have no effect on cropping. The "availability" column indicates which functions support a given preference.Availability Legend:
@@ -187,7 +187,7 @@ preferences have no effect on cropping. The "availability" column indicates whiIf you prefer not to set preferences using the above method, you can instead put them into a config file. -Simply create a new file called image_lib.php, add the $config +Simply create a new file called image_lib.php, add the $config array in that file. Then save the file in: config/image_lib.php and it will be used automatically. You will NOT need to use the $this->image_lib->initialize function if you save your preferences in a config file.
@@ -319,7 +319,7 @@ or create a thumbnail image.For practical purposes there is no difference between creating a copy and creating a thumbnail except a thumb will have the thumbnail marker as part of the name (ie, mypic_thumb.jpg).
-All preferences listed in the table above are available for this function except these three: rotation_angle, x_axis, and y_axis.
+All preferences listed in the table above are available for this function except these three: rotation_angle, x_axis, and y_axis.
$config['x_axis'] = '100';
$config['y_axis'] = '40';
-All preferences listed in the table above are available for this function except these: rotation_angle, width, height, create_thumb, new_image.
+All preferences listed in the table above are available for this function except these: rotation_angle, width, height, create_thumb, new_image.
Here's an example showing how you might crop an image:
@@ -378,8 +378,8 @@ if ( ! $this->image_lib->crop())Note: Without a visual interface it is difficult to crop images, so this function is not very useful -unless you intend to build such an interface. That's exactly what we did using for the photo -gallery module in ExpressionEngine, the CMS we develop. We added a JavaScript UI that lets the cropping +unless you intend to build such an interface. That's exactly what we did using for the photo +gallery module in ExpressionEngine, the CMS we develop. We added a JavaScript UI that lets the cropping area be selected.
Just as with the other functions (resizing, cropping, and rotating) the general process for watermarking involves setting the preferences corresponding to the action you intend to perform, then -calling the watermark function. Here is an example:
+calling the watermark function. Here is an example:
$config['source_image'] = '/path/to/image/mypic.jpg';
@@ -452,9 +452,9 @@ $config['wm_type'] = 'text';
$config['wm_font_path'] = './system/fonts/texb.ttf';
$config['wm_font_size'] = '16';
$config['wm_font_color'] = 'ffffff';
-$config['wm_vrt_alignment'] = 'bottom';
-$config['wm_hor_alignment'] = 'center';
-$config['wm_padding'] = '20';
+$config['wm_vrt_alignment'] = 'bottom';
+$config['wm_hor_alignment'] = 'center';
+$config['wm_padding'] = '20';
$this->image_lib->initialize($config);
@@ -462,7 +462,7 @@ $this->image_lib->initialize($config);
$this->image_lib->watermark();
-The above example will use a 16 pixel True Type font to create the text "Copyright 2006 - John Doe". The watermark +
The above example will use a 16 pixel True Type font to create the text "Copyright 2006 - John Doe". The watermark will be positioned at the bottom/center of the image, 20 pixels from the bottom of the image.
Note: In order for the image class to be allowed to do any processing, the image file must have "write" file permissions. For example, 777.
@@ -491,14 +491,14 @@ will be positioned at the bottom/center of the image, 20 pixels from the bottom