Varien_File_Uploader_Image Class Reference

Inheritance diagram for Varien_File_Uploader_Image:

Varien_File_Uploader

List of all members.

Public Member Functions

 __construct ($file=null)
 resize ($width=null, $height=null)
 rotate ($degrees=null)
 flip ($type="h")
 crop ($crop=0)
 convert ($format="jpeg")
 addWatermark ($fileName=null, $position="BL", $absoluteX=null, $absoluteY=null)
 addReflection ($height="10%", $space=0, $color="#FFFFFF", $opacity=60)
 addText ($string="")
 setTextDirection ($direction)
 setTextColor ($color)
 setTextVisibilityPercent ($percent)
 setTextBackgroundColor ($color)
 setTextBackgroundVisPercent ($percent)
 setTextFont ($font)
 setTextPosition ($position="TR")
 setTextAbsoluteX ($absoluteX)
 setTextAbsoluteY ($absoluteY)
 setTextPadding ($padding)
 setTextPaddingX ($padding)
 setTextPaddingY ($padding)
 setTextAlignment ($alignment)
 setTextLineSpacing ($lineSpacing)
 convertToGreyscale ()
 colorInvert ()
 colorOverlay ($color="#FFFFFF", $percent=50)
 setContrast ($value=0)
 setBrightness ($value=0)
 setJpegQuality ($value=85)
 setBgColor ($color="#000000")
 __destruct ()


Detailed Description

Definition at line 33 of file Image.php.


Constructor & Destructor Documentation

__construct ( file = null  ) 

Reimplemented from Varien_File_Uploader.

Definition at line 36 of file Image.php.

00037     {
00038         $this->newUploader($file);
00039     }

__destruct (  ) 

Definition at line 355 of file Image.php.

00356     {
00357         $this->uploader->Clean();
00358     }


Member Function Documentation

addReflection ( height = "10%",
space = 0,
color = "#FFFFFF",
opacity = 60 
)

$height sets the height of the reflection

Value is an integer in pixels, or a string which format can be in pixels or percentage. For instance, values can be : 40, '40', '40px' or '40'

$space sets the space between the source image and its relection

Value is an integer in pixels, which can be negative

$color sets the color of the reflection background.

Value is an hexadecimal color, such as FFFFFF

$opacity sets the initial opacity of the reflection

Value is an integer between 0 (no opacity) and 100 (full opacity).

Definition at line 183 of file Image.php.

00184     {
00185         if( intval($height) == 0 ) {
00186             return;
00187         }
00188         
00189         $this->uploader->image_reflection_height = $height;
00190         $this->uploader->image_reflection_space = $space;
00191         $this->uploader->image_reflection_color = $color;
00192         $this->uploader->image_reflection_opacity = $opacity;
00193     }

addText ( string = ""  ) 

Adds a text label on the image

Value is a string, any text. Text will not word-wrap, although you can use breaklines in your text "\n"

Definition at line 200 of file Image.php.

00201     {
00202         if( trim($string) == "" ) {
00203             return;
00204         }
00205 
00206         $this->uploader->image_text = $string;
00207     }

addWatermark ( fileName = null,
position = "BL",
absoluteX = null,
absoluteY = null 
)

Adds a watermark on the image

$fileName is a local image filename, relative or absolute. GIF, JPG and PNG are supported, as well as PNG alpha. $position sets the watermarkposition within the image

Value of positions is one or two out of 'TBLR' (top, bottom, left, right)

The positions are as following: TL T TR L R BL B BR

Default value is "BL" (bottom left)

Note that is $absoluteX and $absoluteY are used, $position has no effect

$absoluteX sets the watermark absolute X position within the image

Value is in pixels, representing the distance between the top of the image and the watermark If a negative value is used, it will represent the distance between the bottom of the image and the watermark

$absoluteY sets the twatermark absolute Y position within the image

Value is in pixels, representing the distance between the left of the image and the watermark If a negative value is used, it will represent the distance between the right of the image and the watermark

Definition at line 152 of file Image.php.

00153     {
00154         if( !isset($fileName) ) {
00155             return;
00156         }
00157 
00158         $this->uploader->image_watermark = $fileName;
00159         $this->uploader->image_watermark_position = $position;
00160         $this->uploader->image_watermark_x = $absoluteX;
00161         $this->uploader->image_watermark_y = $absoluteY;
00162     }

colorInvert (  ) 

Inverts the color of an image

Definition at line 291 of file Image.php.

00292     {
00293         $this->uploader->image_negative = true;
00294     }

colorOverlay ( color = "#FFFFFF",
percent = 50 
)

Applies a colored overlay on the image

$color value is an hexadecimal color, such as FFFFFF

$percent value is a percentage, as an integer between 0 and 100

Definition at line 304 of file Image.php.

00305     {
00306         $this->uploader->image_overlay_color = $color;
00307         $this->uploader->image_overlay_percent = $percent;
00308     }

convert ( format = "jpeg"  ) 

Coverts an image

Possibles $color values are : ''; 'png'; 'jpeg'; 'gif'

Default value is 'jpeg'

Definition at line 120 of file Image.php.

00121     {
00122         $this->uploader->image_convert = $format;
00123     }

convertToGreyscale (  ) 

Turns the image into greyscale

Definition at line 282 of file Image.php.

00283     {
00284         $this->uploader->image_greyscale = true;
00285     }

crop ( crop = 0  ) 

Crops an image

$crop values are four dimensions, or two, or one (CSS style) They represent the amount cropped top, right, bottom and left. These values can either be in an array, or a space separated string. Each value can be in pixels (with or without 'px'), or percentage (of the source image)

For instance, are valid: $foo->crop(20) OR array(20); $foo->crop('20px') OR array('20px'); $foo->crop('20 40') OR array('20', 40); $foo->crop('-20 25') OR array(-20, '25'); $foo->crop('20px 25') OR array('20px', '25'); $foo->crop('20% 25') OR array('20', '25'); $foo->crop('20% 25% 10% 30') OR array('20', '25', '10', '30'); $foo->crop('20px 25px 2px 2px') OR array('20px', '25px', '2px', '2px'); $foo->crop('20 25% 40px 10') OR array(20, '25', '40px', '10');

If a value is negative, the image will be expanded, and the extra parts will be filled with black

Default value is NULL (no cropping)

Definition at line 107 of file Image.php.

00108     {
00109         $this->uploader->image_crop = $crop;
00110     }

flip ( type = "h"  ) 

Definition at line 79 of file Image.php.

00080     {
00081         $this->uploader->image_flip = $type;
00082     }

resize ( width = null,
height = null 
)

Resizes an image Set parameters to the wanted (or maximum/minimum) width for the processed image, in pixels

Definition at line 45 of file Image.php.

00046     {
00047         $this->uploader->image_resize = true;
00048 
00049         $this->uploader->image_ratio_x = ( $width == null ) ? true : false;
00050         $this->uploader->image_ratio_y = ( $height == null ) ? true : false;
00051 
00052         $this->uploader->image_x = $width;
00053         $this->uploader->image_y = $height;
00054     }

rotate ( degrees = null  ) 

Rotates the image by increments of 45 degrees

Value is either 90, 180 or 270

Default value is NULL (no rotation)

Definition at line 64 of file Image.php.

00065     {
00066         $this->uploader->image_rotate = intval($degrees);
00067     }

setBgColor ( color = "#000000"  ) 

Default color of the image background

Is generally used when cropping an image with negative margins

Definition at line 350 of file Image.php.

00351     {
00352         $this->uploader->image_background_color = $color;
00353     }

setBrightness ( value = 0  ) 

Corrects the image brightness

Value can range between -127 and 127

Definition at line 327 of file Image.php.

00328     {
00329         $this->uploader->image_brightness = $value;
00330     }

setContrast ( value = 0  ) 

Corrects the image contrast

Value can range between -127 and 127

Definition at line 316 of file Image.php.

00317     {
00318         $this->uploader->image_contrast = $value;
00319     }

setJpegQuality ( value = 85  ) 

Quality of JPEG created/converted destination image

Default value is 85

Definition at line 338 of file Image.php.

00339     {
00340         $this->uploader->jpeg_quality = $value;
00341         #
00342     }

setTextAbsoluteX ( absoluteX  ) 

Definition at line 244 of file Image.php.

00245     {
00246         $this->uploader->image_text_x = $absoluteX;
00247     }

setTextAbsoluteY ( absoluteY  ) 

Definition at line 249 of file Image.php.

00250     {
00251         $this->uploader->image_text_y = $absoluteY;
00252     }

setTextAlignment ( alignment  ) 

Definition at line 269 of file Image.php.

00270     {
00271         $this->uploader->image_text_alignment = $alignment;
00272     }

setTextBackgroundColor ( color  ) 

Definition at line 224 of file Image.php.

00225     {
00226         $this->uploader->image_text_background = $color;
00227     }

setTextBackgroundVisPercent ( percent  ) 

Definition at line 229 of file Image.php.

00230     {
00231         $this->uploader->image_text_background_percent = $percent;
00232     }

setTextColor ( color  ) 

Definition at line 214 of file Image.php.

00215     {
00216         $this->uploader->image_text_color = $color;
00217     }

setTextDirection ( direction  ) 

Definition at line 209 of file Image.php.

00210     {
00211         $this->uploader->image_text_direction = $direction;
00212     }

setTextFont ( font  ) 

Definition at line 234 of file Image.php.

00235     {
00236         $this->uploader->image_text_font = $font;
00237     }

setTextLineSpacing ( lineSpacing  ) 

Definition at line 274 of file Image.php.

00275     {
00276         $this->uploader->image_text_line_spacing = $lineSpacing;
00277     }

setTextPadding ( padding  ) 

Definition at line 254 of file Image.php.

00255     {
00256         $this->uploader->image_text_padding = $padding;
00257     }

setTextPaddingX ( padding  ) 

Definition at line 259 of file Image.php.

00260     {
00261         $this->uploader->image_text_padding_x = $padding;
00262     }

setTextPaddingY ( padding  ) 

Definition at line 264 of file Image.php.

00265     {
00266         $this->uploader->image_text_padding_y = $padding;
00267     }

setTextPosition ( position = "TR"  ) 

Definition at line 239 of file Image.php.

00240     {
00241         $this->uploader->image_text_position = $position;
00242     }

setTextVisibilityPercent ( percent  ) 

Definition at line 219 of file Image.php.

00220     {
00221         $this->uploader->image_text_percent = $visibilityPercent;
00222     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:25:02 2009 for Magento by  doxygen 1.5.8