Index: trunk/extensions/VipsScaler/VipsScaler_body.php |
— | — | @@ -45,6 +45,11 @@ |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
| 49 | + # Set comment |
| 50 | + if ( !empty( $options['setcomment'] ) && isset( $params['comment'] ) ) { |
| 51 | + self::setJpegComment( $params['dstPath'], $params['comment'] ); |
| 52 | + } |
| 53 | + |
49 | 54 | # Set the output variable |
50 | 55 | $mto = new ThumbnailImage( $file, $params['dstUrl'], |
51 | 56 | $params['clientWidth'], $params['clientHeight'], $params['dstPath'] ); |
— | — | @@ -205,6 +210,22 @@ |
206 | 211 | } |
207 | 212 | |
208 | 213 | /** |
| 214 | + * Sets the JPEG comment on a file using exiv2. |
| 215 | + * Requires $wgExiv2Command to be setup properly. |
| 216 | + * |
| 217 | + * @param string $fileName File where the comment needs to be set |
| 218 | + * @param string $comment The comment |
| 219 | + */ |
| 220 | + public static function setJpegComment( $fileName, $comment ) { |
| 221 | + global $wgExiv2Command; |
| 222 | + |
| 223 | + wfShellExec( wfEscapeShellArg( $wgExiv2Command ) . ' mo -c ' |
| 224 | + . wfEscapeShellArg( $comment ) . ' ' |
| 225 | + . wfEscapeShellArg( $fileName ) |
| 226 | + ); |
| 227 | + } |
| 228 | + |
| 229 | + /** |
209 | 230 | * Return the appropriate im_XXX2vips handler for this file |
210 | 231 | * @param File $file |
211 | 232 | * @return mixed String or false |
Index: trunk/extensions/VipsScaler/VipsScaler.php |
— | — | @@ -36,7 +36,21 @@ |
37 | 37 | # Download vips from http://www.vips.ecs.soton.ac.uk/ |
38 | 38 | $wgVipsCommand = 'vips'; |
39 | 39 | |
40 | | -# Options and conditions for images to be scaled with this scaler |
| 40 | +/* Options and conditions for images to be scaled with this scaler. |
| 41 | + * Set to an array of arrays. The inner array contains a condition array, which |
| 42 | + * contains a list of conditions that the image should pass for it to be scaled |
| 43 | + * with vips. Conditions are mimeType, minArea, maxArea, minShrinkFactor, |
| 44 | + * maxShrinkFactor. The other items in the array are options. Options available |
| 45 | + * are: |
| 46 | + * - sharpen: Set to an array with keys 'radius' and 'sigma', which are |
| 47 | + * parameters to gaussian sharpen matrix. |
| 48 | + * - preconvert: Convert the file to a .v file first, which costs some space, |
| 49 | + * but saves memory on the actual downsize |
| 50 | + * - bilinear: Use im_resize_linear instead of im_shrink |
| 51 | + * - convolution: Apply specified convolution matrix |
| 52 | + * - setcomment: Add an exif comment specifying the source of the file. |
| 53 | + * Requires $wgExiv2Command to be set properly. |
| 54 | + */ |
41 | 55 | $wgVipsOptions = array( |
42 | 56 | # Sharpen jpeg files which are shrunk more than 1.2 |
43 | 57 | array( |
— | — | @@ -62,3 +76,8 @@ |
63 | 77 | ), |
64 | 78 | ); |
65 | 79 | |
| 80 | +# This scaler support rotation |
| 81 | +$wgEnableAutoRotation = true; |
| 82 | + |
| 83 | + |
| 84 | + |