'metadata' => $this->metadata,
'size' => $this->size );
- $wgMemc->set( $keys[0], $cachedValues );
+ $wgMemc->set( $keys[0], $cachedValues, 60 * 60 * 24 * 7 ); // A week
} else {
// However we should clear them, so they aren't leftover
// if we've deleted the file.
if (!$mime || $mime==='unknown' || $mime==='unknown/unknown') return false;
- #if it's SVG, check if ther's a converter enabled
+ #if it's SVG, check if there's a converter enabled
if ($mime === 'image/svg') {
global $wgSVGConverters, $wgSVGConverter;
return null;
}
- if( $width >= $this->width && !$this->mustRender() ) {
+ global $wgSVGMaxSize;
+ $maxsize = $this->mustRender()
+ ? max( $this->width, $wgSVGMaxSize )
+ : $this->width - 1;
+ if( $width > $maxsize ) {
# Don't make an image bigger than the source
$thumb = new ThumbnailImage( $this->getViewURL(), $this->getWidth(), $this->getHeight() );
wfProfileOut( $fname );
if( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
global $wgSVGConverterPath;
$cmd = str_replace(
- array( '$path/', '$width', '$input', '$output' ),
- array( $wgSVGConverterPath,
- $width,
+ array( '$path/', '$width', '$height', '$input', '$output' ),
+ array( $wgSVGConverterPath ? "$wgSVGConverterPath/" : "",
+ intval( $width ),
+ intval( $height ),
wfEscapeShellArg( $this->imagePath ),
wfEscapeShellArg( $thumbPath ) ),
$wgSVGConverters[$wgSVGConverter] );
+ wfDebug( "reallyRenderThumb SVG: $cmd\n" );
$conv = shell_exec( $cmd );
} else {
$conv = false;
# Specify white background color, will be used for transparent images
# in Internet Explorer/Windows instead of default black.
$cmd = $wgImageMagickConvertCommand .
- " -quality 85 -background white -geometry {$width} ".
- wfEscapeShellArg($this->imagePath) . " " .
+ " -quality 85 -background white -size {$width}x{$height} ".
+ wfEscapeShellArg($this->imagePath) . " -resize {$width}x{$height} " .
wfEscapeShellArg($thumbPath);
- wfDebug("reallyRenderThumb: running ImageMagick: $cmd");
+ wfDebug("reallyRenderThumb: running ImageMagick: $cmd\n");
$conv = shell_exec( $cmd );
} else {
# Use PHP's builtin GD library functions.
/**
* Record an image upload in the upload log and the image table
*/
- function recordUpload( $oldver, $desc, $license, $copyStatus = '', $source = '' ) {
+ function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '' ) {
global $wgUser, $wgLang, $wgTitle, $wgDeferredUpdateList;
global $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList;
}
}
$db->freeResult( $res );
+ wfProfileOut( $fname );
return $retVal;
}
/**
*
* @return array
*/
- function retrieveExifData () {
- if ( $this->getMimeType() !== "image/jpeg" ) return array ();
+ function retrieveExifData() {
+ if ( $this->getMimeType() !== "image/jpeg" )
+ return array();
$exif = new Exif( $this->imagePath );
return $exif->getFilteredData();
}
- function getExifData () {
+ function getExifData() {
global $wgRequest;
if ( $this->metadata === '0' )
return array();
$purge = $wgRequest->getVal( 'action' ) == 'purge';
- $ret = unserialize ( $this->metadata );
+ $ret = unserialize( $this->metadata );
$oldver = isset( $ret['MEDIAWIKI_EXIF_VERSION'] ) ? $ret['MEDIAWIKI_EXIF_VERSION'] : 0;
$newver = Exif::version();
if ( !count( $ret ) || $purge || $oldver != $newver ) {
+ $this->purgeCache();
$this->updateExifData( $newver );
}
if ( isset( $ret['MEDIAWIKI_EXIF_VERSION'] ) )
unset( $ret['MEDIAWIKI_EXIF_VERSION'] );
$format = new FormatExif( $ret );
+
return $format->getFormattedData();
}
$fname
);
}
+
+ /**
+ * Returns true if the image does not come from the shared
+ * image repository.
+ *
+ * @return bool
+ */
+ function isLocal() {
+ return !$this->fromSharedDirectory;
+ }
} //class
'' => 1.0, // "User units" pixels by default
'%' => 2.0, // Fake it!
);
- if( preg_match( '/^(\d+)(em|ex|px|pt|pc|cm|mm|in|%|)$/', $length, $matches ) ) {
+ if( preg_match( '/^(\d+(?:\.\d+)?)(em|ex|px|pt|pc|cm|mm|in|%|)$/', $length, $matches ) ) {
$length = floatval( $matches[1] );
$unit = $matches[2];
return round( $length * $unitLength[$unit] );