00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class Varien_File_Uploader_Image extends Varien_File_Uploader
00034 {
00035
00036 function __construct($file=null)
00037 {
00038 $this->newUploader($file);
00039 }
00040
00041
00042
00043
00044
00045 public function resize($width=null, $height=null)
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 }
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 public function rotate($degrees=null)
00065 {
00066 $this->uploader->image_rotate = intval($degrees);
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 public function flip($type="h")
00080 {
00081 $this->uploader->image_flip = $type;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 public function crop($crop=0)
00108 {
00109 $this->uploader->image_crop = $crop;
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 public function convert($format="jpeg")
00121 {
00122 $this->uploader->image_convert = $format;
00123 }
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 public function addWatermark($fileName=null, $position="BL", $absoluteX=null, $absoluteY=null)
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 }
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 public function addReflection($height="10%", $space=0, $color="#FFFFFF", $opacity=60)
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 }
00194
00195
00196
00197
00198
00199
00200 public function addText($string="")
00201 {
00202 if( trim($string) == "" ) {
00203 return;
00204 }
00205
00206 $this->uploader->image_text = $string;
00207 }
00208
00209 public function setTextDirection($direction)
00210 {
00211 $this->uploader->image_text_direction = $direction;
00212 }
00213
00214 public function setTextColor($color)
00215 {
00216 $this->uploader->image_text_color = $color;
00217 }
00218
00219 public function setTextVisibilityPercent($percent)
00220 {
00221 $this->uploader->image_text_percent = $visibilityPercent;
00222 }
00223
00224 public function setTextBackgroundColor($color)
00225 {
00226 $this->uploader->image_text_background = $color;
00227 }
00228
00229 public function setTextBackgroundVisPercent($percent)
00230 {
00231 $this->uploader->image_text_background_percent = $percent;
00232 }
00233
00234 public function setTextFont($font)
00235 {
00236 $this->uploader->image_text_font = $font;
00237 }
00238
00239 public function setTextPosition($position="TR")
00240 {
00241 $this->uploader->image_text_position = $position;
00242 }
00243
00244 public function setTextAbsoluteX($absoluteX)
00245 {
00246 $this->uploader->image_text_x = $absoluteX;
00247 }
00248
00249 public function setTextAbsoluteY($absoluteY)
00250 {
00251 $this->uploader->image_text_y = $absoluteY;
00252 }
00253
00254 public function setTextPadding($padding)
00255 {
00256 $this->uploader->image_text_padding = $padding;
00257 }
00258
00259 public function setTextPaddingX($padding)
00260 {
00261 $this->uploader->image_text_padding_x = $padding;
00262 }
00263
00264 public function setTextPaddingY($padding)
00265 {
00266 $this->uploader->image_text_padding_y = $padding;
00267 }
00268
00269 public function setTextAlignment($alignment)
00270 {
00271 $this->uploader->image_text_alignment = $alignment;
00272 }
00273
00274 public function setTextLineSpacing($lineSpacing)
00275 {
00276 $this->uploader->image_text_line_spacing = $lineSpacing;
00277 }
00278
00279
00280
00281
00282 public function convertToGreyscale()
00283 {
00284 $this->uploader->image_greyscale = true;
00285 }
00286
00287
00288
00289
00290
00291 public function colorInvert()
00292 {
00293 $this->uploader->image_negative = true;
00294 }
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 public function colorOverlay($color="#FFFFFF", $percent=50)
00305 {
00306 $this->uploader->image_overlay_color = $color;
00307 $this->uploader->image_overlay_percent = $percent;
00308 }
00309
00310
00311
00312
00313
00314
00315
00316 public function setContrast($value=0)
00317 {
00318 $this->uploader->image_contrast = $value;
00319 }
00320
00321
00322
00323
00324
00325
00326
00327 public function setBrightness($value=0)
00328 {
00329 $this->uploader->image_brightness = $value;
00330 }
00331
00332
00333
00334
00335
00336
00337
00338 public function setJpegQuality($value=85)
00339 {
00340 $this->uploader->jpeg_quality = $value;
00341 #
00342 }
00343
00344
00345
00346
00347
00348
00349
00350 public function setBgColor($color="#000000")
00351 {
00352 $this->uploader->image_background_color = $color;
00353 }
00354
00355 function __destruct()
00356 {
00357 $this->uploader->Clean();
00358 }
00359 }
00360
00361
00362
00363
00364 ?>