2007-04-20 12:31:36 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2010-08-15 17:27:41 +00:00
|
|
|
* Handler for SVG images.
|
|
|
|
|
*
|
2012-05-03 20:13:10 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Media
|
|
|
|
|
*/
|
2016-10-12 05:36:03 +00:00
|
|
|
use Wikimedia\ScopedCallback;
|
2007-04-20 12:31:36 +00:00
|
|
|
|
2007-04-24 06:53:31 +00:00
|
|
|
/**
|
2010-08-15 17:27:41 +00:00
|
|
|
* Handler for SVG images.
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Media
|
2007-04-24 06:53:31 +00:00
|
|
|
*/
|
2007-04-20 12:31:36 +00:00
|
|
|
class SvgHandler extends ImageHandler {
|
2010-11-04 00:35:29 +00:00
|
|
|
const SVG_METADATA_VERSION = 2;
|
2010-11-01 23:57:09 +00:00
|
|
|
|
2013-12-05 19:27:27 +00:00
|
|
|
/** @var array A list of metadata tags that can be converted
|
|
|
|
|
* to the commonly used exif tags. This allows messages
|
|
|
|
|
* to be reused, and consistent tag names for {{#formatmetadata:..}}
|
2013-08-28 23:09:07 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
private static $metaConversion = [
|
2013-08-28 23:09:07 +00:00
|
|
|
'originalwidth' => 'ImageWidth',
|
|
|
|
|
'originalheight' => 'ImageLength',
|
|
|
|
|
'description' => 'ImageDescription',
|
|
|
|
|
'title' => 'ObjectName',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2013-08-28 23:09:07 +00:00
|
|
|
|
2007-04-20 12:31:36 +00:00
|
|
|
function isEnabled() {
|
|
|
|
|
global $wgSVGConverters, $wgSVGConverter;
|
|
|
|
|
if ( !isset( $wgSVGConverters[$wgSVGConverter] ) ) {
|
|
|
|
|
wfDebug( "\$wgSVGConverter is invalid, disabling SVG rendering.\n" );
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2007-04-20 12:31:36 +00:00
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 23:47:02 +00:00
|
|
|
public function mustRender( $file ) {
|
2007-04-20 12:31:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-31 21:49:25 +00:00
|
|
|
function isVectorized( $file ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $file
|
2011-02-18 23:34:24 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2010-11-04 00:35:29 +00:00
|
|
|
function isAnimatedImage( $file ) {
|
2013-12-05 19:27:27 +00:00
|
|
|
# @todo Detect animated SVGs
|
2010-11-04 00:35:29 +00:00
|
|
|
$metadata = $file->getMetadata();
|
|
|
|
|
if ( $metadata ) {
|
|
|
|
|
$metadata = $this->unpackMetadata( $metadata );
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( isset( $metadata['animated'] ) ) {
|
2010-11-04 00:35:29 +00:00
|
|
|
return $metadata['animated'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2010-11-01 23:57:09 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-16 01:47:51 +00:00
|
|
|
/**
|
|
|
|
|
* Which languages (systemLanguage attribute) is supported.
|
|
|
|
|
*
|
|
|
|
|
* @note This list is not guaranteed to be exhaustive.
|
|
|
|
|
* To avoid OOM errors, we only look at first bit of a file.
|
|
|
|
|
* Thus all languages on this list are present in the file,
|
|
|
|
|
* but its possible for the file to have a language not on
|
|
|
|
|
* this list.
|
|
|
|
|
*
|
|
|
|
|
* @param File $file
|
2014-04-20 19:16:57 +00:00
|
|
|
* @return array Array of language codes, or empty if no language switching supported.
|
2013-11-16 01:47:51 +00:00
|
|
|
*/
|
|
|
|
|
public function getAvailableLanguages( File $file ) {
|
|
|
|
|
$metadata = $file->getMetadata();
|
2016-02-17 09:09:32 +00:00
|
|
|
$langList = [];
|
2013-11-16 01:47:51 +00:00
|
|
|
if ( $metadata ) {
|
|
|
|
|
$metadata = $this->unpackMetadata( $metadata );
|
|
|
|
|
if ( isset( $metadata['translations'] ) ) {
|
2013-12-08 19:31:47 +00:00
|
|
|
foreach ( $metadata['translations'] as $lang => $langType ) {
|
2015-04-29 12:46:32 +00:00
|
|
|
if ( $langType === SVGReader::LANG_FULL_MATCH ) {
|
2017-10-18 12:38:48 +00:00
|
|
|
$langList[] = strtolower( $lang );
|
2013-11-16 01:47:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-18 12:38:48 +00:00
|
|
|
return array_unique( $langList );
|
2013-11-16 01:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-10-18 12:38:48 +00:00
|
|
|
* SVG's systemLanguage matching rules state:
|
|
|
|
|
* 'The `systemLanguage` attribute ... [e]valuates to "true" if one of the languages indicated
|
|
|
|
|
* by user preferences exactly equals one of the languages given in the value of this parameter,
|
|
|
|
|
* or if one of the languages indicated by user preferences exactly equals a prefix of one of
|
|
|
|
|
* the languages given in the value of this parameter such that the first tag character
|
|
|
|
|
* following the prefix is "-".'
|
2013-11-16 01:47:51 +00:00
|
|
|
*
|
2017-10-18 12:38:48 +00:00
|
|
|
* Return the first element of $svgLanguages that matches $userPreferredLanguage
|
|
|
|
|
*
|
|
|
|
|
* @see https://www.w3.org/TR/SVG/struct.html#SystemLanguageAttribute
|
|
|
|
|
* @param string $userPreferredLanguage
|
|
|
|
|
* @param array $svgLanguages
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
|
|
|
|
public function getMatchedLanguage( $userPreferredLanguage, array $svgLanguages ) {
|
|
|
|
|
foreach ( $svgLanguages as $svgLang ) {
|
|
|
|
|
if ( strcasecmp( $svgLang, $userPreferredLanguage ) === 0 ) {
|
|
|
|
|
return $svgLang;
|
|
|
|
|
}
|
|
|
|
|
$trimmedSvgLang = $svgLang;
|
|
|
|
|
while ( strpos( $trimmedSvgLang, '-' ) !== false ) {
|
|
|
|
|
$trimmedSvgLang = substr( $trimmedSvgLang, 0, strrpos( $trimmedSvgLang, '-' ) );
|
|
|
|
|
if ( strcasecmp( $trimmedSvgLang, $userPreferredLanguage ) === 0 ) {
|
|
|
|
|
return $svgLang;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* What language to render file in if none selected
|
|
|
|
|
*
|
|
|
|
|
* @param File $file Language code
|
|
|
|
|
* @return string
|
2013-11-16 01:47:51 +00:00
|
|
|
*/
|
|
|
|
|
public function getDefaultRenderLanguage( File $file ) {
|
|
|
|
|
return 'en';
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-19 01:19:53 +00:00
|
|
|
/**
|
|
|
|
|
* We do not support making animated svg thumbnails
|
2014-08-14 19:34:55 +00:00
|
|
|
* @param File $file
|
|
|
|
|
* @return bool
|
2012-08-19 01:19:53 +00:00
|
|
|
*/
|
2014-06-11 00:15:53 +00:00
|
|
|
function canAnimateThumbnail( $file ) {
|
2012-08-19 01:19:53 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $image
|
2017-08-11 00:23:16 +00:00
|
|
|
* @param array &$params
|
2011-02-18 23:34:24 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2007-04-20 12:31:36 +00:00
|
|
|
function normaliseParams( $image, &$params ) {
|
|
|
|
|
global $wgSVGMaxSize;
|
|
|
|
|
if ( !parent::normaliseParams( $image, $params ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-08-02 14:13:51 +00:00
|
|
|
# Don't make an image bigger than wgMaxSVGSize on the smaller side
|
|
|
|
|
if ( $params['physicalWidth'] <= $params['physicalHeight'] ) {
|
|
|
|
|
if ( $params['physicalWidth'] > $wgSVGMaxSize ) {
|
|
|
|
|
$srcWidth = $image->getWidth( $params['page'] );
|
|
|
|
|
$srcHeight = $image->getHeight( $params['page'] );
|
|
|
|
|
$params['physicalWidth'] = $wgSVGMaxSize;
|
|
|
|
|
$params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ( $params['physicalHeight'] > $wgSVGMaxSize ) {
|
|
|
|
|
$srcWidth = $image->getWidth( $params['page'] );
|
|
|
|
|
$srcHeight = $image->getHeight( $params['page'] );
|
|
|
|
|
$params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
|
|
|
|
|
$params['physicalHeight'] = $wgSVGMaxSize;
|
|
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2007-04-20 12:31:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $image
|
|
|
|
|
* @param string $dstPath
|
|
|
|
|
* @param string $dstUrl
|
|
|
|
|
* @param array $params
|
2011-02-18 23:34:24 +00:00
|
|
|
* @param int $flags
|
|
|
|
|
* @return bool|MediaTransformError|ThumbnailImage|TransformParameterError
|
|
|
|
|
*/
|
2007-04-20 12:31:36 +00:00
|
|
|
function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
|
|
|
|
|
if ( !$this->normaliseParams( $image, $params ) ) {
|
|
|
|
|
return new TransformParameterError( $params );
|
|
|
|
|
}
|
|
|
|
|
$clientWidth = $params['width'];
|
|
|
|
|
$clientHeight = $params['height'];
|
|
|
|
|
$physicalWidth = $params['physicalWidth'];
|
|
|
|
|
$physicalHeight = $params['physicalHeight'];
|
2017-10-06 22:17:58 +00:00
|
|
|
$lang = $params['lang'] ?? $this->getDefaultRenderLanguage( $image );
|
2007-04-20 12:31:36 +00:00
|
|
|
|
|
|
|
|
if ( $flags & self::TRANSFORM_LATER ) {
|
2012-09-01 16:12:48 +00:00
|
|
|
return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-26 21:17:41 +00:00
|
|
|
$metadata = $this->unpackMetadata( $image->getMetadata() );
|
|
|
|
|
if ( isset( $metadata['error'] ) ) { // sanity check
|
2016-11-01 19:08:38 +00:00
|
|
|
$err = wfMessage( 'svg-long-error', $metadata['error']['message'] );
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2012-11-26 21:17:41 +00:00
|
|
|
return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err );
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-25 22:01:19 +00:00
|
|
|
if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight,
|
2016-11-01 19:08:38 +00:00
|
|
|
wfMessage( 'thumbnail_dest_directory' ) );
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2010-11-04 00:35:29 +00:00
|
|
|
|
2012-08-17 03:23:37 +00:00
|
|
|
$srcPath = $image->getLocalRefPath();
|
2014-07-10 07:14:45 +00:00
|
|
|
if ( $srcPath === false ) { // Failed to get local copy
|
|
|
|
|
wfDebugLog( 'thumbnail',
|
|
|
|
|
sprintf( 'Thumbnail failed on %s: could not get local copy of "%s"',
|
|
|
|
|
wfHostname(), $image->getName() ) );
|
|
|
|
|
|
|
|
|
|
return new MediaTransformError( 'thumbnail_error',
|
|
|
|
|
$params['width'], $params['height'],
|
2016-11-01 19:08:38 +00:00
|
|
|
wfMessage( 'filemissing' )
|
2014-07-10 07:14:45 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make a temp dir with a symlink to the local copy in it.
|
|
|
|
|
// This plays well with rsvg-convert policy for external entities.
|
|
|
|
|
// https://git.gnome.org/browse/librsvg/commit/?id=f01aded72c38f0e18bc7ff67dee800e380251c8e
|
|
|
|
|
$tmpDir = wfTempDir() . '/svg_' . wfRandomString( 24 );
|
|
|
|
|
$lnPath = "$tmpDir/" . basename( $srcPath );
|
2016-02-04 04:21:22 +00:00
|
|
|
$ok = mkdir( $tmpDir, 0771 );
|
|
|
|
|
if ( !$ok ) {
|
|
|
|
|
wfDebugLog( 'thumbnail',
|
|
|
|
|
sprintf( 'Thumbnail failed on %s: could not create temporary directory %s',
|
|
|
|
|
wfHostname(), $tmpDir ) );
|
|
|
|
|
return new MediaTransformError( 'thumbnail_error',
|
|
|
|
|
$params['width'], $params['height'],
|
|
|
|
|
wfMessage( 'thumbnail-temp-create' )->text()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$ok = symlink( $srcPath, $lnPath );
|
2015-07-15 01:01:11 +00:00
|
|
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
2014-08-04 09:51:22 +00:00
|
|
|
$cleaner = new ScopedCallback( function () use ( $tmpDir, $lnPath ) {
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\suppressWarnings();
|
2014-07-10 07:14:45 +00:00
|
|
|
unlink( $lnPath );
|
|
|
|
|
rmdir( $tmpDir );
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\restoreWarnings();
|
2014-07-10 07:14:45 +00:00
|
|
|
} );
|
|
|
|
|
if ( !$ok ) {
|
|
|
|
|
wfDebugLog( 'thumbnail',
|
|
|
|
|
sprintf( 'Thumbnail failed on %s: could not link %s to %s',
|
|
|
|
|
wfHostname(), $lnPath, $srcPath ) );
|
|
|
|
|
return new MediaTransformError( 'thumbnail_error',
|
|
|
|
|
$params['width'], $params['height'],
|
2016-11-01 19:08:38 +00:00
|
|
|
wfMessage( 'thumbnail-temp-create' )
|
2014-07-10 07:14:45 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$status = $this->rasterize( $lnPath, $dstPath, $physicalWidth, $physicalHeight, $lang );
|
2012-11-26 21:17:41 +00:00
|
|
|
if ( $status === true ) {
|
2012-09-01 16:12:48 +00:00
|
|
|
return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
|
2008-11-18 01:18:12 +00:00
|
|
|
} else {
|
|
|
|
|
return $status; // MediaTransformError
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-04 00:35:29 +00:00
|
|
|
|
2011-05-21 19:35:16 +00:00
|
|
|
/**
|
2012-10-07 23:35:26 +00:00
|
|
|
* Transform an SVG file to PNG
|
|
|
|
|
* This function can be called outside of thumbnail contexts
|
|
|
|
|
* @param string $srcPath
|
|
|
|
|
* @param string $dstPath
|
|
|
|
|
* @param string $width
|
|
|
|
|
* @param string $height
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param bool|string $lang Language code of the language to render the SVG in
|
2012-10-07 23:35:26 +00:00
|
|
|
* @throws MWException
|
|
|
|
|
* @return bool|MediaTransformError
|
|
|
|
|
*/
|
2013-05-24 12:56:06 +00:00
|
|
|
public function rasterize( $srcPath, $dstPath, $width, $height, $lang = false ) {
|
2008-11-18 01:18:12 +00:00
|
|
|
global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
|
2007-04-20 12:31:36 +00:00
|
|
|
$err = false;
|
2010-09-02 22:15:20 +00:00
|
|
|
$retval = '';
|
2008-11-18 01:18:12 +00:00
|
|
|
if ( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
|
2011-03-12 19:59:41 +00:00
|
|
|
if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) {
|
|
|
|
|
// This is a PHP callable
|
|
|
|
|
$func = $wgSVGConverters[$wgSVGConverter][0];
|
|
|
|
|
if ( !is_callable( $func ) ) {
|
|
|
|
|
throw new MWException( "$func is not callable" );
|
|
|
|
|
}
|
2018-06-09 23:26:32 +00:00
|
|
|
$err = $func( $srcPath,
|
|
|
|
|
$dstPath,
|
|
|
|
|
$width,
|
|
|
|
|
$height,
|
|
|
|
|
$lang,
|
|
|
|
|
...array_slice( $wgSVGConverters[$wgSVGConverter], 1 )
|
|
|
|
|
);
|
2011-03-12 19:59:41 +00:00
|
|
|
$retval = (bool)$err;
|
|
|
|
|
} else {
|
|
|
|
|
// External command
|
|
|
|
|
$cmd = str_replace(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ '$path/', '$width', '$height', '$input', '$output' ],
|
|
|
|
|
[ $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "",
|
2013-02-03 19:42:08 +00:00
|
|
|
intval( $width ),
|
|
|
|
|
intval( $height ),
|
|
|
|
|
wfEscapeShellArg( $srcPath ),
|
2016-02-17 09:09:32 +00:00
|
|
|
wfEscapeShellArg( $dstPath ) ],
|
2011-03-12 19:59:41 +00:00
|
|
|
$wgSVGConverters[$wgSVGConverter]
|
2013-09-12 01:40:56 +00:00
|
|
|
);
|
2013-05-24 12:56:06 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$env = [];
|
2013-08-24 15:06:25 +00:00
|
|
|
if ( $lang !== false ) {
|
2013-05-24 12:56:06 +00:00
|
|
|
$env['LANG'] = $lang;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-03 19:42:08 +00:00
|
|
|
wfDebug( __METHOD__ . ": $cmd\n" );
|
2013-09-12 01:40:56 +00:00
|
|
|
$err = wfShellExecWithStderr( $cmd, $retval, $env );
|
2011-03-12 19:59:41 +00:00
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
|
|
|
|
$removed = $this->removeBadFile( $dstPath, $retval );
|
|
|
|
|
if ( $retval != 0 || $removed ) {
|
2013-12-04 16:28:12 +00:00
|
|
|
$this->logErrorForExternalProcess( $retval, $err, $cmd );
|
2008-11-25 18:26:21 +00:00
|
|
|
return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2008-11-18 01:18:12 +00:00
|
|
|
return true;
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2011-07-25 22:01:19 +00:00
|
|
|
|
2011-03-12 19:59:41 +00:00
|
|
|
public static function rasterizeImagickExt( $srcPath, $dstPath, $width, $height ) {
|
|
|
|
|
$im = new Imagick( $srcPath );
|
|
|
|
|
$im->setImageFormat( 'png' );
|
|
|
|
|
$im->setBackgroundColor( 'transparent' );
|
|
|
|
|
$im->setImageDepth( 8 );
|
2011-07-25 22:01:19 +00:00
|
|
|
|
2011-03-12 19:59:41 +00:00
|
|
|
if ( !$im->thumbnailImage( intval( $width ), intval( $height ), /* fit */ false ) ) {
|
|
|
|
|
return 'Could not resize image';
|
|
|
|
|
}
|
|
|
|
|
if ( !$im->writeImage( $dstPath ) ) {
|
|
|
|
|
return "Could not write to $dstPath";
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
2016-09-19 01:39:59 +00:00
|
|
|
* @param File|FSFile $file
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param string $path Unused
|
|
|
|
|
* @param bool|array $metadata
|
2011-02-18 23:34:24 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
2010-11-01 23:57:09 +00:00
|
|
|
function getImageSize( $file, $path, $metadata = false ) {
|
2016-09-19 01:39:59 +00:00
|
|
|
if ( $metadata === false && $file instanceof File ) {
|
2015-04-13 04:43:36 +00:00
|
|
|
$metadata = $file->getMetadata();
|
2010-11-01 23:57:09 +00:00
|
|
|
}
|
2015-04-13 04:43:36 +00:00
|
|
|
$metadata = $this->unpackMetadata( $metadata );
|
2010-11-01 23:57:09 +00:00
|
|
|
|
|
|
|
|
if ( isset( $metadata['width'] ) && isset( $metadata['height'] ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ $metadata['width'], $metadata['height'], 'SVG',
|
|
|
|
|
"width=\"{$metadata['width']}\" height=\"{$metadata['height']}\"" ];
|
2012-11-26 21:17:41 +00:00
|
|
|
} else { // error
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ 0, 0, 'SVG', "width=\"0\" height=\"0\"" ];
|
2010-11-01 23:57:09 +00:00
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-23 18:18:14 +00:00
|
|
|
function getThumbType( $ext, $mime, $params = null ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ 'png', 'image/png' ];
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
2012-08-17 02:18:39 +00:00
|
|
|
* Subtitle for the image. Different from the base
|
|
|
|
|
* class so it can be denoted that SVG's have
|
|
|
|
|
* a "nominal" resolution, and not a fixed one,
|
|
|
|
|
* as well as so animation can be denoted.
|
|
|
|
|
*
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $file
|
2011-02-18 23:34:24 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-12-15 22:22:21 +00:00
|
|
|
function getLongDesc( $file ) {
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
global $wgLang;
|
2012-11-26 21:17:41 +00:00
|
|
|
|
|
|
|
|
$metadata = $this->unpackMetadata( $file->getMetadata() );
|
|
|
|
|
if ( isset( $metadata['error'] ) ) {
|
|
|
|
|
return wfMessage( 'svg-long-error', $metadata['error']['message'] )->text();
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 02:18:39 +00:00
|
|
|
$size = $wgLang->formatSize( $file->getSize() );
|
|
|
|
|
|
|
|
|
|
if ( $this->isAnimatedImage( $file ) ) {
|
|
|
|
|
$msg = wfMessage( 'svg-long-desc-animated' );
|
|
|
|
|
} else {
|
|
|
|
|
$msg = wfMessage( 'svg-long-desc' );
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-26 21:17:41 +00:00
|
|
|
$msg->numParams( $file->getWidth(), $file->getHeight() )->params( $size );
|
|
|
|
|
|
2012-08-17 02:18:39 +00:00
|
|
|
return $msg->parse();
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
}
|
2010-11-01 23:57:09 +00:00
|
|
|
|
2013-12-05 19:27:27 +00:00
|
|
|
/**
|
2016-09-19 01:39:59 +00:00
|
|
|
* @param File|FSFile $file
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param string $filename
|
|
|
|
|
* @return string Serialised metadata
|
|
|
|
|
*/
|
2010-11-01 23:57:09 +00:00
|
|
|
function getMetadata( $file, $filename ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$metadata = [ 'version' => self::SVG_METADATA_VERSION ];
|
2010-11-01 23:57:09 +00:00
|
|
|
try {
|
2012-11-26 21:17:41 +00:00
|
|
|
$metadata += SVGMetadataExtractor::getMetadata( $filename );
|
2015-01-09 23:44:47 +00:00
|
|
|
} catch ( Exception $e ) { // @todo SVG specific exceptions
|
2012-11-26 21:17:41 +00:00
|
|
|
// File not found, broken, etc.
|
2016-02-17 09:09:32 +00:00
|
|
|
$metadata['error'] = [
|
2012-11-26 21:17:41 +00:00
|
|
|
'message' => $e->getMessage(),
|
2013-04-20 21:11:46 +00:00
|
|
|
'code' => $e->getCode()
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-11-01 23:57:09 +00:00
|
|
|
wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2010-11-01 23:57:09 +00:00
|
|
|
return serialize( $metadata );
|
|
|
|
|
}
|
2010-11-04 00:35:29 +00:00
|
|
|
|
2010-11-01 23:57:09 +00:00
|
|
|
function unpackMetadata( $metadata ) {
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\suppressWarnings();
|
2011-05-25 05:26:54 +00:00
|
|
|
$unser = unserialize( $metadata );
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\restoreWarnings();
|
2010-11-01 23:57:09 +00:00
|
|
|
if ( isset( $unser['version'] ) && $unser['version'] == self::SVG_METADATA_VERSION ) {
|
|
|
|
|
return $unser;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getMetadataType( $image ) {
|
|
|
|
|
return 'parsed-svg';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isMetadataValid( $image, $metadata ) {
|
2012-08-19 18:18:50 +00:00
|
|
|
$meta = $this->unpackMetadata( $metadata );
|
|
|
|
|
if ( $meta === false ) {
|
|
|
|
|
return self::METADATA_BAD;
|
|
|
|
|
}
|
|
|
|
|
if ( !isset( $meta['originalWidth'] ) ) {
|
|
|
|
|
// Old but compatible
|
|
|
|
|
return self::METADATA_COMPATIBLE;
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2012-08-19 18:18:50 +00:00
|
|
|
return self::METADATA_GOOD;
|
2010-11-01 23:57:09 +00:00
|
|
|
}
|
2010-11-04 00:35:29 +00:00
|
|
|
|
2013-12-05 19:40:38 +00:00
|
|
|
protected function visibleMetadataFields() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$fields = [ 'objectname', 'imagedescription' ];
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2010-11-04 00:35:29 +00:00
|
|
|
return $fields;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $file
|
2014-12-28 20:31:34 +00:00
|
|
|
* @param bool|IContextSource $context Context to use (optional)
|
2011-02-18 23:34:24 +00:00
|
|
|
* @return array|bool
|
|
|
|
|
*/
|
2014-12-28 20:31:34 +00:00
|
|
|
function formatMetadata( $file, $context = false ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$result = [
|
|
|
|
|
'visible' => [],
|
|
|
|
|
'collapsed' => []
|
|
|
|
|
];
|
2010-11-04 00:35:29 +00:00
|
|
|
$metadata = $file->getMetadata();
|
|
|
|
|
if ( !$metadata ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$metadata = $this->unpackMetadata( $metadata );
|
2012-11-26 21:17:41 +00:00
|
|
|
if ( !$metadata || isset( $metadata['error'] ) ) {
|
2010-11-04 00:35:29 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 19:27:27 +00:00
|
|
|
/* @todo Add a formatter
|
2010-11-04 00:35:29 +00:00
|
|
|
$format = new FormatSVG( $metadata );
|
|
|
|
|
$formatted = $format->getFormattedData();
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Sort fields into visible and collapsed
|
|
|
|
|
$visibleFields = $this->visibleMetadataFields();
|
(Follow-up r75968) r75968 started extracting and displaying some svg metadata, but didn't add the messages it used.
It started to use the messages svg-description, svg-title, svg-width, and svg-height in the metadata table, without
defining those messages. I changed it to use the same messages as are used when displaying the same table on
the image description pages of jpeg files. ( exif-imagewidth and friends ). Personally I feel the metadata
should be about the image, not what format the metadata was stored in (a description of an image is still a
description of the image, regardless of the format of that image. JPEG images for example can have image descriptions in
3 different metadata formats [exif, iptc, xmp], it would be insane to make different messages for them). Furthermore,
I think we should rename all the exif-* messages to something like filemeta-property (but thats an issue for later).
I added one message, 'exif-objectname', since the svg title property didn't really correspond to anything in exif.
However, it does correspond very well to IPTC's object name property, which i hope we will start supporting in 1.18,
so I used that message for that.
2011-02-13 04:55:35 +00:00
|
|
|
|
2013-08-24 17:51:07 +00:00
|
|
|
$showMeta = false;
|
2010-11-04 00:35:29 +00:00
|
|
|
foreach ( $metadata as $name => $value ) {
|
|
|
|
|
$tag = strtolower( $name );
|
2013-08-28 23:09:07 +00:00
|
|
|
if ( isset( self::$metaConversion[$tag] ) ) {
|
|
|
|
|
$tag = strtolower( self::$metaConversion[$tag] );
|
2012-08-17 02:18:39 +00:00
|
|
|
} else {
|
|
|
|
|
// Do not output other metadata not in list
|
|
|
|
|
continue;
|
(Follow-up r75968) r75968 started extracting and displaying some svg metadata, but didn't add the messages it used.
It started to use the messages svg-description, svg-title, svg-width, and svg-height in the metadata table, without
defining those messages. I changed it to use the same messages as are used when displaying the same table on
the image description pages of jpeg files. ( exif-imagewidth and friends ). Personally I feel the metadata
should be about the image, not what format the metadata was stored in (a description of an image is still a
description of the image, regardless of the format of that image. JPEG images for example can have image descriptions in
3 different metadata formats [exif, iptc, xmp], it would be insane to make different messages for them). Furthermore,
I think we should rename all the exif-* messages to something like filemeta-property (but thats an issue for later).
I added one message, 'exif-objectname', since the svg title property didn't really correspond to anything in exif.
However, it does correspond very well to IPTC's object name property, which i hope we will start supporting in 1.18,
so I used that message for that.
2011-02-13 04:55:35 +00:00
|
|
|
}
|
2013-08-24 17:51:07 +00:00
|
|
|
$showMeta = true;
|
2010-11-04 00:35:29 +00:00
|
|
|
self::addMeta( $result,
|
|
|
|
|
in_array( $tag, $visibleFields ) ? 'visible' : 'collapsed',
|
(Follow-up r75968) r75968 started extracting and displaying some svg metadata, but didn't add the messages it used.
It started to use the messages svg-description, svg-title, svg-width, and svg-height in the metadata table, without
defining those messages. I changed it to use the same messages as are used when displaying the same table on
the image description pages of jpeg files. ( exif-imagewidth and friends ). Personally I feel the metadata
should be about the image, not what format the metadata was stored in (a description of an image is still a
description of the image, regardless of the format of that image. JPEG images for example can have image descriptions in
3 different metadata formats [exif, iptc, xmp], it would be insane to make different messages for them). Furthermore,
I think we should rename all the exif-* messages to something like filemeta-property (but thats an issue for later).
I added one message, 'exif-objectname', since the svg title property didn't really correspond to anything in exif.
However, it does correspond very well to IPTC's object name property, which i hope we will start supporting in 1.18,
so I used that message for that.
2011-02-13 04:55:35 +00:00
|
|
|
'exif',
|
2010-11-04 00:35:29 +00:00
|
|
|
$tag,
|
|
|
|
|
$value
|
|
|
|
|
);
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-08-24 17:51:07 +00:00
|
|
|
return $showMeta ? $result : false;
|
2010-11-04 00:35:29 +00:00
|
|
|
}
|
2013-05-24 12:56:06 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $name Parameter name
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param mixed $value Parameter value
|
2013-05-24 12:56:06 +00:00
|
|
|
* @return bool Validity
|
|
|
|
|
*/
|
2016-02-23 23:47:02 +00:00
|
|
|
public function validateParam( $name, $value ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
if ( in_array( $name, [ 'width', 'height' ] ) ) {
|
2013-05-24 12:56:06 +00:00
|
|
|
// Reject negative heights, widths
|
|
|
|
|
return ( $value > 0 );
|
2013-08-24 15:06:25 +00:00
|
|
|
} elseif ( $name == 'lang' ) {
|
2013-05-24 12:56:06 +00:00
|
|
|
// Validate $code
|
2017-10-18 12:38:48 +00:00
|
|
|
if ( $value === '' || !Language::isValidCode( $value ) ) {
|
2013-05-24 12:56:06 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-05-24 12:56:06 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-05-24 12:56:06 +00:00
|
|
|
// Only lang, width and height are acceptable keys
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-07-24 17:43:25 +00:00
|
|
|
* @param array $params Name=>value pairs of parameters
|
2013-05-24 12:56:06 +00:00
|
|
|
* @return string Filename to use
|
|
|
|
|
*/
|
2016-02-23 23:47:02 +00:00
|
|
|
public function makeParamString( $params ) {
|
2013-05-24 12:56:06 +00:00
|
|
|
$lang = '';
|
2013-08-24 15:06:25 +00:00
|
|
|
if ( isset( $params['lang'] ) && $params['lang'] !== 'en' ) {
|
2017-10-18 12:38:48 +00:00
|
|
|
$lang = 'lang' . strtolower( $params['lang'] ) . '-';
|
2013-05-24 12:56:06 +00:00
|
|
|
}
|
|
|
|
|
if ( !isset( $params['width'] ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-05-24 12:56:06 +00:00
|
|
|
return "$lang{$params['width']}px";
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 23:47:02 +00:00
|
|
|
public function parseParamString( $str ) {
|
2013-05-24 12:56:06 +00:00
|
|
|
$m = false;
|
2017-10-18 12:38:48 +00:00
|
|
|
if ( preg_match( '/^lang([a-z]+(?:-[a-z]+)*)-(\d+)px$/i', $str, $m ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ 'width' => array_pop( $m ), 'lang' => $m[1] ];
|
2013-08-24 15:06:25 +00:00
|
|
|
} elseif ( preg_match( '/^(\d+)px$/', $str, $m ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ 'width' => $m[1], 'lang' => 'en' ];
|
2013-05-24 12:56:06 +00:00
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 23:47:02 +00:00
|
|
|
public function getParamMap() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ 'img_lang' => 'lang', 'img_width' => 'width' ];
|
2013-05-24 12:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param array $params
|
2013-05-24 12:56:06 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
function getScriptParams( $params ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$scriptParams = [ 'width' => $params['width'] ];
|
2013-12-06 23:45:15 +00:00
|
|
|
if ( isset( $params['lang'] ) ) {
|
|
|
|
|
$scriptParams['lang'] = $params['lang'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $scriptParams;
|
2013-05-24 12:56:06 +00:00
|
|
|
}
|
2013-08-28 23:09:07 +00:00
|
|
|
|
|
|
|
|
public function getCommonMetaArray( File $file ) {
|
|
|
|
|
$metadata = $file->getMetadata();
|
|
|
|
|
if ( !$metadata ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [];
|
2013-08-28 23:09:07 +00:00
|
|
|
}
|
|
|
|
|
$metadata = $this->unpackMetadata( $metadata );
|
|
|
|
|
if ( !$metadata || isset( $metadata['error'] ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [];
|
2013-08-28 23:09:07 +00:00
|
|
|
}
|
2016-02-17 09:09:32 +00:00
|
|
|
$stdMetadata = [];
|
2013-08-28 23:09:07 +00:00
|
|
|
foreach ( $metadata as $name => $value ) {
|
|
|
|
|
$tag = strtolower( $name );
|
|
|
|
|
if ( $tag === 'originalwidth' || $tag === 'originalheight' ) {
|
|
|
|
|
// Skip these. In the exif metadata stuff, it is assumed these
|
|
|
|
|
// are measured in px, which is not the case here.
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ( isset( self::$metaConversion[$tag] ) ) {
|
|
|
|
|
$tag = self::$metaConversion[$tag];
|
|
|
|
|
$stdMetadata[$tag] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-08-28 23:09:07 +00:00
|
|
|
return $stdMetadata;
|
|
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|