57 return [
'png',
'image/png' ];
70 private static function getXCFMetaData( $filename ) {
71 # Decode master structure
72 $f = fopen( $filename,
'rb' );
76 # The image structure always starts at offset 0 in the XCF file.
77 # So we just read it :-)
78 $binaryHeader = fread( $f, 26 );
99 $header = StringUtils::unpack(
100 "A9magic" . # A: space padded
101 "/a5version" . # a: zero padded
103 "/Nheight" . # N: unsigned long 32bit big endian
112 if ( $header[
'magic'] !==
'gimp xcf' ) {
113 wfDebug( __METHOD__ .
" '$filename' has invalid magic signature." );
117 # TODO: we might want to check for correct values of width and height
120 ": canvas size of '$filename' is {$header['width']} x {$header['height']} px" );
126 $header = self::getXCFMetaData( $filename );
132 switch ( $header[
'base_type'] ) {
134 $metadata[
'colorType'] =
'truecolour-alpha';
137 $metadata[
'colorType'] =
'greyscale-alpha';
140 $metadata[
'colorType'] =
'index-coloured';
143 $metadata[
'colorType'] =
'unknown';
147 $metadata[
'error'] =
true;
150 'width' => $header[
'width'] ?? 0,
151 'height' => $header[
'height'] ?? 0,
153 'metadata' => $metadata
164 if ( !$file->getMetadataArray() ) {
185 $xcfMeta = $file->getMetadataArray();
186 if ( isset( $xcfMeta[
'colorType'] ) && $xcfMeta[
'colorType'] ===
'index-coloured' ) {
189 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.
Generic handler for bitmap images.
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.