53 return [
'png',
'image/png' ];
69 # Forge a return array containing metadata information just like getimagesize()
70 # See PHP documentation at: https:
74 2 =>
null, # IMAGETYPE constant, none exist
for XCF.
75 3 =>
"height=\"{$header['height']}\" width=\"{$header['width']}\"",
76 'mime' =>
'image/x-xcf',
78 'bits' => 8, # Always 8-bits per color
93 # Decode master structure
94 $f = fopen( $filename,
'rb' );
98 # The image structure always starts at offset 0 in the XCF file.
99 # So we just read it :-)
100 $binaryHeader = fread( $f, 26 );
122 "A9magic" . # A: space padded
123 "/a5version" . # a: zero padded
125 "/Nheight" . # N:
unsigned long 32bit big endian
129 }
catch ( Exception $mwe ) {
134 if (
$header[
'magic'] !==
'gimp xcf' ) {
135 wfDebug( __METHOD__ .
" '$filename' has invalid magic signature.\n" );
139 # TODO: we might want to check for sane values of width and height
142 ": canvas size of '$filename' is {$header['width']} x {$header['height']} px\n" );
164 switch (
$header[
'base_type'] ) {
166 $metadata[
'colorType'] =
'truecolour-alpha';
169 $metadata[
'colorType'] =
'greyscale-alpha';
172 $metadata[
'colorType'] =
'index-coloured';
175 $metadata[
'colorType'] =
'unknown';
179 $metadata[
'error'] =
true;
220 Wikimedia\suppressWarnings();
222 Wikimedia\restoreWarnings();
223 if ( isset( $xcfMeta[
'colorType'] ) && $xcfMeta[
'colorType'] ===
'index-coloured' ) {
226 return parent::canRender(
$file );
unserialize( $serialized)
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfUnpack( $format, $data, $length=false)
Wrapper around php's unpack.
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?
getImageSize( $image, $filename)
Get width and height from the XCF header.
static getXCFMetaData( $filename)
Metadata for a given XCF file.
getThumbType( $ext, $mime, $params=null)
Render files as PNG.
isMetadataValid( $file, $metadata)
Should we refresh the metadata.
getScalerType( $dstPath, $checkDstPath=true)
Must use "im" for XCF.
getMetadata( $file, $filename)
Store the channel type.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!is_readable( $file)) $ext