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
|
|
|
|
|
*/
|
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
|
|
|
|
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" );
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
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
|
|
|
/**
|
|
|
|
|
* @param $file File
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2010-11-04 00:35:29 +00:00
|
|
|
function isAnimatedImage( $file ) {
|
2010-11-01 23:57:09 +00:00
|
|
|
# TODO: detect animated SVGs
|
2010-11-04 00:35:29 +00:00
|
|
|
$metadata = $file->getMetadata();
|
|
|
|
|
if ( $metadata ) {
|
|
|
|
|
$metadata = $this->unpackMetadata( $metadata );
|
|
|
|
|
if( isset( $metadata['animated'] ) ) {
|
|
|
|
|
return $metadata['animated'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-01 23:57:09 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
|
|
|
|
* @param $image File
|
|
|
|
|
* @param $params
|
|
|
|
|
* @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
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
|
|
|
|
* @param $image File
|
|
|
|
|
* @param $dstPath
|
|
|
|
|
* @param $dstUrl
|
|
|
|
|
* @param $params
|
|
|
|
|
* @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'];
|
2011-12-20 03:52:06 +00:00
|
|
|
$srcPath = $image->getLocalRefPath();
|
2007-04-20 12:31:36 +00:00
|
|
|
|
|
|
|
|
if ( $flags & self::TRANSFORM_LATER ) {
|
2007-08-31 02:51:23 +00:00
|
|
|
return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
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,
|
2007-04-20 12:31:36 +00:00
|
|
|
wfMsg( 'thumbnail_dest_directory' ) );
|
|
|
|
|
}
|
2010-11-04 00:35:29 +00:00
|
|
|
|
2008-11-25 18:26:21 +00:00
|
|
|
$status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight );
|
2008-11-18 01:18:12 +00:00
|
|
|
if( $status === true ) {
|
|
|
|
|
return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
|
|
|
|
|
} else {
|
|
|
|
|
return $status; // MediaTransformError
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-04 00:35:29 +00:00
|
|
|
|
2011-05-21 19:35:16 +00:00
|
|
|
/**
|
2008-11-18 01:18:12 +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
|
2012-02-09 17:41:50 +00:00
|
|
|
* @return bool|MediaTransformError
|
2008-11-18 01:18:12 +00:00
|
|
|
*/
|
2008-11-18 01:24:56 +00:00
|
|
|
public function rasterize( $srcPath, $dstPath, $width, $height ) {
|
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];
|
2011-07-25 22:01:19 +00:00
|
|
|
$args = array_merge( array( $srcPath, $dstPath, $width, $height ),
|
2011-03-12 19:59:41 +00:00
|
|
|
array_slice( $wgSVGConverters[$wgSVGConverter], 1 ) );
|
|
|
|
|
if ( !is_callable( $func ) ) {
|
|
|
|
|
throw new MWException( "$func is not callable" );
|
|
|
|
|
}
|
|
|
|
|
$err = call_user_func_array( $func, $args );
|
|
|
|
|
$retval = (bool)$err;
|
|
|
|
|
} else {
|
|
|
|
|
// External command
|
|
|
|
|
$cmd = str_replace(
|
|
|
|
|
array( '$path/', '$width', '$height', '$input', '$output' ),
|
|
|
|
|
array( $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "",
|
|
|
|
|
intval( $width ),
|
|
|
|
|
intval( $height ),
|
|
|
|
|
wfEscapeShellArg( $srcPath ),
|
|
|
|
|
wfEscapeShellArg( $dstPath ) ),
|
|
|
|
|
$wgSVGConverters[$wgSVGConverter]
|
|
|
|
|
) . " 2>&1";
|
|
|
|
|
wfProfileIn( 'rsvg' );
|
|
|
|
|
wfDebug( __METHOD__.": $cmd\n" );
|
|
|
|
|
$err = wfShellExec( $cmd, $retval );
|
|
|
|
|
wfProfileOut( 'rsvg' );
|
|
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
|
|
|
|
$removed = $this->removeBadFile( $dstPath, $retval );
|
|
|
|
|
if ( $retval != 0 || $removed ) {
|
2008-11-18 01:18:12 +00:00
|
|
|
wfDebugLog( 'thumbnail', sprintf( 'thumbnail failed on %s: error %d "%s" from "%s"',
|
2007-04-20 12:31:36 +00:00
|
|
|
wfHostname(), $retval, trim($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
|
|
|
}
|
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
|
|
|
/**
|
|
|
|
|
* @param $file File
|
|
|
|
|
* @param $path
|
|
|
|
|
* @param bool $metadata
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2010-11-01 23:57:09 +00:00
|
|
|
function getImageSize( $file, $path, $metadata = false ) {
|
|
|
|
|
if ( $metadata === false ) {
|
|
|
|
|
$metadata = $file->getMetaData();
|
|
|
|
|
}
|
|
|
|
|
$metadata = $this->unpackMetaData( $metadata );
|
|
|
|
|
|
|
|
|
|
if ( isset( $metadata['width'] ) && isset( $metadata['height'] ) ) {
|
|
|
|
|
return array( $metadata['width'], $metadata['height'], 'SVG',
|
|
|
|
|
"width=\"{$metadata['width']}\" height=\"{$metadata['height']}\"" );
|
|
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-23 18:18:14 +00:00
|
|
|
function getThumbType( $ext, $mime, $params = null ) {
|
2007-04-20 12:31:36 +00:00
|
|
|
return array( 'png', 'image/png' );
|
|
|
|
|
}
|
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
|
|
|
/**
|
|
|
|
|
* @param $file File
|
|
|
|
|
* @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;
|
2008-07-16 08:48:53 +00:00
|
|
|
return wfMsgExt( 'svg-long-desc', 'parseinline',
|
|
|
|
|
$wgLang->formatNum( $file->getWidth() ),
|
|
|
|
|
$wgLang->formatNum( $file->getHeight() ),
|
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
|
|
|
$wgLang->formatSize( $file->getSize() ) );
|
|
|
|
|
}
|
2010-11-01 23:57:09 +00:00
|
|
|
|
|
|
|
|
function getMetadata( $file, $filename ) {
|
|
|
|
|
try {
|
|
|
|
|
$metadata = SVGMetadataExtractor::getMetadata( $filename );
|
|
|
|
|
} catch( Exception $e ) {
|
|
|
|
|
// Broken file?
|
|
|
|
|
wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
|
|
|
|
|
return '0';
|
|
|
|
|
}
|
|
|
|
|
$metadata['version'] = self::SVG_METADATA_VERSION;
|
|
|
|
|
return serialize( $metadata );
|
|
|
|
|
}
|
2010-11-04 00:35:29 +00:00
|
|
|
|
2010-11-01 23:57:09 +00:00
|
|
|
function unpackMetadata( $metadata ) {
|
2011-05-25 00:25:29 +00:00
|
|
|
wfSuppressWarnings();
|
2011-05-25 05:26:54 +00:00
|
|
|
$unser = unserialize( $metadata );
|
2011-05-25 00:25:29 +00:00
|
|
|
wfRestoreWarnings();
|
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 ) {
|
|
|
|
|
return $this->unpackMetadata( $metadata ) !== false;
|
|
|
|
|
}
|
2010-11-04 00:35:29 +00:00
|
|
|
|
|
|
|
|
function visibleMetadataFields() {
|
|
|
|
|
$fields = array( 'title', 'description', 'animated' );
|
|
|
|
|
return $fields;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 23:34:24 +00:00
|
|
|
/**
|
|
|
|
|
* @param $file File
|
|
|
|
|
* @return array|bool
|
|
|
|
|
*/
|
2010-11-04 00:35:29 +00:00
|
|
|
function formatMetadata( $file ) {
|
|
|
|
|
$result = array(
|
|
|
|
|
'visible' => array(),
|
|
|
|
|
'collapsed' => array()
|
|
|
|
|
);
|
|
|
|
|
$metadata = $file->getMetadata();
|
|
|
|
|
if ( !$metadata ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$metadata = $this->unpackMetadata( $metadata );
|
|
|
|
|
if ( !$metadata ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
unset( $metadata['version'] );
|
|
|
|
|
unset( $metadata['metadata'] ); /* non-formatted XML */
|
|
|
|
|
|
|
|
|
|
/* TODO: add a formatter
|
|
|
|
|
$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
|
|
|
|
|
|
|
|
// Rename fields to be compatible with exif, so that
|
|
|
|
|
// the labels for these fields work.
|
|
|
|
|
$conversion = array( 'width' => 'imagewidth',
|
|
|
|
|
'height' => 'imagelength',
|
|
|
|
|
'description' => 'imagedescription',
|
|
|
|
|
'title' => 'objectname',
|
|
|
|
|
);
|
2010-11-04 00:35:29 +00:00
|
|
|
foreach ( $metadata as $name => $value ) {
|
|
|
|
|
$tag = strtolower( $name );
|
(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
|
|
|
if ( isset( $conversion[$tag] ) ) {
|
|
|
|
|
$tag = $conversion[$tag];
|
|
|
|
|
}
|
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
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|