Index: trunk/phase3/includes/media/Bitmap.php |
— | — | @@ -8,75 +8,8 @@ |
9 | 9 | * @ingroup Media |
10 | 10 | */ |
11 | 11 | class BitmapHandler extends ImageHandler { |
12 | | - /** |
13 | | - * Override parent method to add crop to param map. |
14 | | - */ |
15 | | - public function getParamMap() { |
16 | | - return array( |
17 | | - 'img_width' => 'width', |
18 | | - 'img_crop' => 'crop', |
19 | | - ); |
20 | | - } |
21 | | - |
22 | | - /** |
23 | | - * Override param map to validate the crop param. |
24 | | - */ |
25 | | - public function validateParam( $name, $value ) { |
26 | | - if ( $name == 'crop' ) { |
27 | | - return $this->splitCropParam( $value ) !== false; |
28 | | - } else { |
29 | | - return parent::validateParam( $name, $value ); |
30 | | - } |
31 | | - } |
32 | | - /** |
33 | | - * Split the crop param into up to 4 parts and convert them to integers. |
34 | | - * Returns false in case of malformed param. |
35 | | - */ |
36 | | - protected function splitCropParam( $value ) { |
37 | | - $parts = explode( 'x', $value ); |
38 | | - if ( count( $parts ) > 4 ) |
39 | | - return false; |
40 | | - foreach ( $parts as &$part ) { |
41 | | - $intVal = intval( $part ); |
42 | | - if ( $intVal === 0 && !( $part === '0' || $part === '' ) ) |
43 | | - return false; |
44 | | - if ( $intVal < 0 ) |
45 | | - return false; |
46 | | - |
47 | | - $part = $intVal; |
48 | | - } |
49 | | - |
50 | | - return $parts; |
51 | | - } |
52 | | - |
53 | | - /** |
54 | | - * Override parent method to check for optional crop parameter in param |
55 | | - * string. |
56 | | - */ |
57 | | - public function parseParamString( $str ) { |
58 | | - $res = parent::parseParamString( $str ); |
59 | | - if ( $res === false ) { |
60 | | - $m = false; |
61 | | - if ( preg_match( '/^(\d+)px-([x0-9])crop$/', $str, $m ) ) { |
62 | | - return array( 'width' => $m[1], 'crop' => $m[2] ); |
63 | | - } else { |
64 | | - return false; |
65 | | - } |
66 | | - } |
67 | | - } |
68 | | - /** |
69 | | - * Add the crop parameter the string generated by the parent. |
70 | | - */ |
71 | | - public function makeParamString( $params ) { |
72 | | - $res = parent::makeParamString( $params ); |
73 | | - if ( !empty( $params['crop'] ) ) |
74 | | - $res .= '-'.implode( 'x', $params['crop'] ).'crop'; |
75 | | - return $res; |
76 | | - } |
77 | | - |
78 | | - public function normaliseParams( $image, &$params ) { |
| 12 | + function normaliseParams( $image, &$params ) { |
79 | 13 | global $wgMaxImageArea; |
80 | | - # Parent fills in width, height and page and normalizes them. |
81 | 14 | if ( !parent::normaliseParams( $image, $params ) ) { |
82 | 15 | return false; |
83 | 16 | } |
— | — | @@ -103,58 +36,18 @@ |
104 | 37 | $params['physicalHeight'] = $srcHeight; |
105 | 38 | return true; |
106 | 39 | } |
107 | | - |
108 | | - # Validate crop params |
109 | | - if ( isset( $params['crop'] ) ) { |
110 | | - # $cropParams = array( x, y, width, height ); |
111 | | - $cropParams = $this->splitCropParam( $params['crop'] ); |
112 | | - # Fill up params |
113 | | - switch ( count( $cropParams ) ) { |
114 | | - # All fall through |
115 | | - case 1: |
116 | | - $cropParams[1] = 0; |
117 | | - case 2: |
118 | | - $cropParams[2] = $srcWidth - $cropParams[0]; |
119 | | - case 3: |
120 | | - $cropParams[3] = $srcHeight - $cropParams[1]; |
121 | | - } |
122 | | - $cx = $cropParams[0] + $cropParams[2]; |
123 | | - $cy = $cropParams[1] + $cropParams[3]; |
124 | | - $targetWidth = $cropParams[2]; |
125 | | - $targetHeight = $cropParams[3]; |
126 | | - # Can't go outside image |
127 | | - if ( $cx > $srcWidth || $cy > $srcHeight ) { |
128 | | - # TODO: Maybe should fail gracefully? |
129 | | - return false; |
130 | | - } |
131 | | - if ( $targetWidth == $srcWidth && $targetHeight == $srcHeight ) |
132 | | - { |
133 | | - # No need to crop |
134 | | - $params['crop'] = false; |
135 | | - } |
136 | | - else |
137 | | - { |
138 | | - $params['crop'] = $cropParams; |
139 | | - $params['height'] = $params['physicalHeight'] = File::scaleHeight( |
140 | | - $targetWidth, $targetHeight, $params['width'] ); |
141 | | - } |
142 | | - } else { |
143 | | - $params['crop'] = false; |
144 | | - } |
145 | 40 | |
146 | 41 | return true; |
147 | 42 | } |
148 | 43 | |
149 | 44 | |
150 | | - /** |
151 | | - * Function that returns the number of pixels to be thumbnailed. |
152 | | - * Intended for animated GIFs to multiply by the number of frames. |
153 | | - */ |
154 | | - protected function getImageArea( $image, $width, $height ) { |
| 45 | + // Function that returns the number of pixels to be thumbnailed. |
| 46 | + // Intended for animated GIFs to multiply by the number of frames. |
| 47 | + function getImageArea( $image, $width, $height ) { |
155 | 48 | return $width * $height; |
156 | 49 | } |
157 | 50 | |
158 | | - public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
| 51 | + function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
159 | 52 | global $wgUseImageMagick, $wgImageMagickConvertCommand, $wgImageMagickTempDir; |
160 | 53 | global $wgCustomConvertCommand, $wgUseImageResize; |
161 | 54 | global $wgSharpenParameter, $wgSharpenReductionThreshold; |
— | — | @@ -243,13 +136,6 @@ |
244 | 137 | } else { |
245 | 138 | $tempEnv = ''; |
246 | 139 | } |
247 | | - |
248 | | - if ( $params['crop'] ) { |
249 | | - $crop = $params['crop']; |
250 | | - $cropCmd = "-crop {$crop[2]}x{$crop[3]}+{$crop[0]}+{$crop[1]}"; |
251 | | - } |
252 | | - else |
253 | | - $cropCmd = ''; |
254 | 140 | |
255 | 141 | # Specify white background color, will be used for transparent images |
256 | 142 | # in Internet Explorer/Windows instead of default black. |
— | — | @@ -261,7 +147,7 @@ |
262 | 148 | $cmd = |
263 | 149 | $tempEnv . |
264 | 150 | wfEscapeShellArg($wgImageMagickConvertCommand) . |
265 | | - " {$cropCmd} {$quality} -background white -size {$physicalWidth} ". |
| 151 | + " {$quality} -background white -size {$physicalWidth} ". |
266 | 152 | wfEscapeShellArg($srcPath . $frame) . |
267 | 153 | $animation . |
268 | 154 | // For the -resize option a "!" is needed to force exact size, |
— | — | @@ -361,13 +247,13 @@ |
362 | 248 | } |
363 | 249 | } |
364 | 250 | |
365 | | - public static function imageJpegWrapper( $dst_image, $thumbPath ) { |
| 251 | + static function imageJpegWrapper( $dst_image, $thumbPath ) { |
366 | 252 | imageinterlace( $dst_image ); |
367 | 253 | imagejpeg( $dst_image, $thumbPath, 95 ); |
368 | 254 | } |
369 | 255 | |
370 | 256 | |
371 | | - public function getMetadata( $image, $filename ) { |
| 257 | + function getMetadata( $image, $filename ) { |
372 | 258 | global $wgShowEXIF; |
373 | 259 | if( $wgShowEXIF && file_exists( $filename ) ) { |
374 | 260 | $exif = new Exif( $filename ); |
— | — | @@ -383,11 +269,11 @@ |
384 | 270 | } |
385 | 271 | } |
386 | 272 | |
387 | | - public function getMetadataType( $image ) { |
| 273 | + function getMetadataType( $image ) { |
388 | 274 | return 'exif'; |
389 | 275 | } |
390 | 276 | |
391 | | - public function isMetadataValid( $image, $metadata ) { |
| 277 | + function isMetadataValid( $image, $metadata ) { |
392 | 278 | global $wgShowEXIF; |
393 | 279 | if ( !$wgShowEXIF ) { |
394 | 280 | # Metadata disabled and so an empty field is expected |
— | — | @@ -415,7 +301,7 @@ |
416 | 302 | * @return array of strings |
417 | 303 | * @access private |
418 | 304 | */ |
419 | | - public function visibleMetadataFields() { |
| 305 | + function visibleMetadataFields() { |
420 | 306 | $fields = array(); |
421 | 307 | $lines = explode( "\n", wfMsgForContent( 'metadata-fields' ) ); |
422 | 308 | foreach( $lines as $line ) { |
— | — | @@ -428,7 +314,7 @@ |
429 | 315 | return $fields; |
430 | 316 | } |
431 | 317 | |
432 | | - public function formatMetadata( $image ) { |
| 318 | + function formatMetadata( $image ) { |
433 | 319 | $result = array( |
434 | 320 | 'visible' => array(), |
435 | 321 | 'collapsed' => array() |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -288,7 +288,6 @@ |
289 | 289 | 'img_text_bottom' => array( 1, 'text-bottom' ), |
290 | 290 | 'img_link' => array( 1, 'link=$1' ), |
291 | 291 | 'img_alt' => array( 1, 'alt=$1' ), |
292 | | - 'img_crop' => array( 1, 'crop=$1' ), |
293 | 292 | 'int' => array( 0, 'INT:' ), |
294 | 293 | 'sitename' => array( 1, 'SITENAME' ), |
295 | 294 | 'ns' => array( 0, 'NS:' ), |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -195,7 +195,6 @@ |
196 | 196 | ** Unnecessary type="" attribute removed for CSS and JS. |
197 | 197 | ** If $wgWellFormedXml is set to false, some bytes will be shaved off of HTML |
198 | 198 | output by omitting some things like quotation marks where HTML 5 allows. |
199 | | -* Added crop for inline images. |
200 | 199 | * The description message in $wgExtensionCredits can be an array with parameters |
201 | 200 | * New hook SpecialRandomGetRandomTitle allows extensions to modify the selection |
202 | 201 | criteria used by Special:Random and subclasses, or substitute a custom result, |