55 return [
'png',
'image/png' ];
68 private static function getXCFMetaData( $filename ) {
69 # Decode master structure
70 $f = fopen( $filename,
'rb' );
74 # The image structure always starts at offset 0 in the XCF file.
75 # So we just read it :-)
76 $binaryHeader = fread( $f, 26 );
98 "A9magic" . # A: space padded
99 "/a5version" . # a: zero padded
101 "/Nheight" . # N: unsigned long 32bit big endian
110 if (
$header[
'magic'] !==
'gimp xcf' ) {
111 wfDebug( __METHOD__ .
" '$filename' has invalid magic signature." );
115 # TODO: we might want to check for correct values of width and height
118 ": canvas size of '$filename' is {$header['width']} x {$header['height']} px" );
124 $header = self::getXCFMetaData( $filename );
130 switch (
$header[
'base_type'] ) {
132 $metadata[
'colorType'] =
'truecolour-alpha';
135 $metadata[
'colorType'] =
'greyscale-alpha';
138 $metadata[
'colorType'] =
'index-coloured';
141 $metadata[
'colorType'] =
'unknown';
145 $metadata[
'error'] =
true;
148 'width' =>
$header[
'width'] ?? 0,
149 'height' =>
$header[
'height'] ?? 0,
151 'metadata' => $metadata
162 if ( !$file->getMetadataArray() ) {
183 $xcfMeta = $file->getMetadataArray();
184 if ( isset( $xcfMeta[
'colorType'] ) && $xcfMeta[
'colorType'] ===
'index-coloured' ) {
187 return parent::canRender( $file );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
array $params
The job parameters.
Generic handler for bitmap images.
static unpack(string $format, string $data, $length=false)
Wrapper around php's unpack.
Handler for the Gimp's native file format; getimagesize() doesn't support these files.
canRender( $file)
Can we render this file?
getThumbType( $ext, $mime, $params=null)
Render files as PNG.
isFileMetadataValid( $file)
Should we refresh the metadata.
hasGDSupport()
Whether the php-gd extension supports this type of file.
getSizeAndMetadata( $state, $filename)
Get image size information and metadata array.