39 return (
$file->getWidth() &&
$file->getHeight() );
48 return [
'img_width' =>
'width' ];
56 if ( in_array( $name, [
'width',
'height' ] ) ) {
72 if ( isset( $params[
'physicalWidth'] ) ) {
73 $width = $params[
'physicalWidth'];
74 } elseif ( isset( $params[
'width'] ) ) {
75 $width = $params[
'width'];
80 # Removed for ProofreadPage
81 # $width = intval( $width );
91 if ( preg_match(
'/^(\d+)px$/', $str, $m ) ) {
92 return [
'width' => $m[1] ];
103 return [
'width' => $params[
'width'] ];
114 $mimeType = $image->getMimeType();
116 if ( !isset( $params[
'width'] ) ) {
120 if ( !isset( $params[
'page'] ) ) {
123 $params[
'page'] = intval( $params[
'page'] );
124 if ( $params[
'page'] > $image->pageCount() ) {
125 $params[
'page'] = $image->pageCount();
128 if ( $params[
'page'] < 1 ) {
133 $srcWidth = $image->getWidth( $params[
'page'] );
134 $srcHeight = $image->getHeight( $params[
'page'] );
136 if ( isset( $params[
'height'] ) && $params[
'height'] != -1 ) {
137 # Height & width were both set
138 if ( $params[
'width'] * $srcHeight > $params[
'height'] * $srcWidth ) {
139 # Height is the relative smaller dimension, so scale width accordingly
140 $params[
'width'] =
self::fitBoxWidth( $srcWidth, $srcHeight, $params[
'height'] );
142 if ( $params[
'width'] == 0 ) {
143 # Very small image, so we need to rely on client side scaling :(
144 $params[
'width'] = 1;
147 $params[
'physicalWidth'] = $params[
'width'];
149 # Height was crap, unset it so that it will be calculated later
150 unset( $params[
'height'] );
154 if ( !isset( $params[
'physicalWidth'] ) ) {
155 # Passed all validations, so set the physicalWidth
156 $params[
'physicalWidth'] = $params[
'width'];
159 # Because thumbs are only referred to by width, the height always needs
160 # to be scaled by the width to keep the thumbnail sizes consistent,
161 # even if it was set inside the if block above
162 $params[
'physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight,
163 $params[
'physicalWidth'] );
165 # Set the height if it was not validated in the if block higher up
166 if ( !isset( $params[
'height'] ) || $params[
'height'] == -1 ) {
167 $params[
'height'] = $params[
'physicalHeight'];
171 $params[
'physicalHeight'], $srcWidth, $srcHeight, $mimeType )
190 $width = intval( $width );
192 # Sanity check $width
194 wfDebug( __METHOD__ .
": Invalid destination width: $width" );
198 if ( $srcWidth <= 0 ) {
199 wfDebug( __METHOD__ .
": Invalid source width: $srcWidth" );
204 $height = File::scaleHeight( $srcWidth, $srcHeight, $width );
205 if ( $height == 0 ) {
206 # Force height to be at least 1 pixel
227 if ( $image->mustRender() || $params[
'width'] < $image->getWidth() ) {
237 Wikimedia\suppressWarnings();
238 $gis = getimagesize(
$path );
239 Wikimedia\restoreWarnings();
255 return $image->getWidth() * $image->getHeight();
266 $nbytes = htmlspecialchars(
$wgLang->formatSize(
$file->getSize() ) );
267 $widthheight =
wfMessage(
'widthheight' )
268 ->numParams(
$file->getWidth(),
$file->getHeight() )->escaped();
270 return "$widthheight ($nbytes)";
281 $pages =
$file->pageCount();
282 $size = htmlspecialchars(
$wgLang->formatSize(
$file->getSize() ) );
283 if ( $pages ===
false || $pages <= 1 ) {
284 $msg =
wfMessage(
'file-info-size' )->numParams(
$file->getWidth(),
285 $file->getHeight() )->params( $size,
286 '<span class="mime-type">' .
$file->getMimeType() .
'</span>' )->parse();
288 $msg =
wfMessage(
'file-info-size-pages' )->numParams(
$file->getWidth(),
289 $file->getHeight() )->params( $size,
290 '<span class="mime-type">' .
$file->getMimeType() .
'</span>' )->numParams( $pages )->parse();
303 $pages =
$file->pageCount();
306 ->numParams(
$file->getWidth(),
$file->getHeight(), $pages )->text();
309 ->numParams(
$file->getWidth(),
$file->getHeight() )->text();
318 $params = parent::sanitizeParamsForBucketing( $params );
322 if ( isset( $params[
'height'] ) ) {
323 unset( $params[
'height'] );
326 if ( isset( $params[
'physicalHeight'] ) ) {
327 unset( $params[
'physicalHeight'] );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Media handler abstract base class for images.
canRender( $file)
True if the handled types can be transformed.Stable to overridebool Stable to override
getImageSize( $image, $path)
Get an image size array like that returned by getimagesize(), or false if it can't be determined....
sanitizeParamsForBucketing( $params)
Returns a normalised params array for which parameters have been cleaned up for bucketing purposes St...
getImageArea( $image)
Function that returns the number of pixels to be thumbnailed.
validateThumbParams(&$width, &$height, $srcWidth, $srcHeight, $mimeType)
Validate thumbnail parameters and fill in the correct height.
getParamMap()
Get an associative array mapping magic word IDs to parameter names.Will be used by the parser to iden...
normaliseParams( $image, &$params)
Changes the parameter array as necessary, ready for transformation.Should be idempotent....
parseParamString( $str)
Parse a param string made with makeParamString back into an array.array|bool Array of parameters or f...
makeParamString( $params)
Merge a parameter array into a string appropriate for inclusion in filenames.string Stable to overrid...
getLongDesc( $file)
Long description.Shown under image on image description page surounded by ().Stable to overridestring...
validateParam( $name, $value)
Validate a thumbnail parameter at parse time.Return true to accept the parameter, and false to reject...
getScriptedTransform( $image, $script, $params)
Get a MediaTransformOutput object representing an alternate of the transformed output which will call...
getScriptParams( $params)
Stable to override
getDimensionsString( $file)
Shown in file history box on image description page.Stable to overridestring Dimensions Stable to ove...
getShortDesc( $file)
Short description.Shown on Special:Search results.Stable to overridestring Stable to override
Media transform output for images.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.