xcf2pnm(1)
π xcf2pnm(1) β convert from GIMP xcf files to ppm/pgm/pbm format π
πΈ NAME πΈ
okay so bestie, meet xcf2pnm(1) β the command-line tool that converts image files in the XCF format used by gimp(1) into the generic image formats pbm(5), pgm(5), and ppm(5), flattening layers if necessary. The iconic part? It does not need the Gimp engine itself available. periodt.
β¨ SYNOPSIS β¨
xcf2pnm [ options ] filename [ layer names ]
π DESCRIPTION π
xcf2pnm is a command-line tool that converts image files in the XCF format used by gimp(1) to the generic image formats pbm(5), pgm(5), and ppm(5), flattening layers if necessary. It does not need to have the Gimp engine itself available. no cap, that's the whole vibe π
π GENERAL OPTIONS π
-a filename,--alpha filenameβ output a transparency mask for the flattened image tofilenameas apgm(5)file, in addition to the ordinary output. If the flattened image is completely opaque, this will produce an error message and exit status101; use-Ato suppress this.-A,--force-alphaβ invent a trivial alpha channel even if the flattened image is completely opaque.-b color,--background colorβ use this color for transparent pixels in the image. The color can be given as#rrggbbor#rgbhexadecimal values, or as an X11 color name (which will only work if a color name database can be found in one of a number of standard locations).-c,--color,--colourβ force the output to use RGB color space even if there are more compact alternatives. This will be selected automatically if the output file's name ends with.ppm.-C,--autocropβ set the converted part of the image such that it just includes the boundaries of the visible (or selected) layers. This may make it either smaller or larger than the canvas, depending on the position and size of the visible layers. (Note that the contents of the layers is not taken into account when autocropping).
In the absence of options that specify otherwise, the converted image will cover the entire XCF canvas.
-D,--dissolveβ do a "dissolve" step to eliminate partial transparency after flattening. If-bis also given, this happens before the background color is applied.-f,--full-imageβ first flatten the entire image to a memory buffer before writing output. Then analyse the image to decide on the details of the output format (e.g., whether a grayscale output is sufficient). Without this option, the program flattens only a single row of "tiles" (height64) at a time.-g,--gray,--greyβ force the output to be a grayscale image even if it may be monochrome. If any colored pixels are encountered, exit with status103. This will be selected automatically if the output file's name ends with.pgm.-G,--for-gifβ assert that the flattened image will have no partial transparency (allowing a more compact representation of the alpha output). Exit with status102if the flattened image has any partial transparency. If-bis also given, this tests whether there is partial transparency before applying the background color.-h,--helpβ print an option summary to standard output and exit with a return code of0.-j,--bzipβ equivalent to-Z bzcat. Default if the filename ends withbz2.-m,--monoβ force the output to be a monochrome image. If any colors except black and white are encountered, exit with status103. This will be selected automatically if the output file's name ends with.pbm.-n,--pnmβ suppress the automatic choice of-c,-g, or-mbased on output filename, and instead select the output format based on image contents. This is the default if the filename is not recognized, and when writing to stdout.-o filename,--output filenameβ write the converted picture tofilenameinstead of to standard output.-O x,y,--offset x,yβ offset the converted part of the image from the top-left corner of the XCF canvas. Usually used with-S.-S wxh,--size wxhβ crop the converted image to widthwand heighth.-T,--truecolorβ use standard RGB compositing for flattening indexed layers. Without this option,xcf2pnmwill mimic the Gimp's current strategy of rounding each alpha value to either full transparency or full opacity, and interpret all layer modes as Normal.-u,--utf8β use the raw UTF-8 representation from the XCF file to compare and display layer names. Ordinarily, layer names will be converted to the character set of the current locale.-v,--verboseβ print progress messages about the conversion to standard error.-V,--versionβ print the version number ofxcftoolsto standard output and exit with a return code of0.-z,--gzipβ equivalent to-Z zcat. Default if the filename ends withgz.-Z command,--unpack commandβ specify a command that the input file is filtered through before being interpreted as an XCF file. The command is invoked ascommand filenameand must produce output to its standard output. Note that it is not possible to specify arguments as part ofcommand. An uncompressor is selected automatically if the filename ends withgzorbz2; to suppress this, use-Z cat(which is implemented without actually starting acat(1)process).
Several groups of options are mutually incompatible; in each group the one given last will win:
-Aand-b.-c,-g,-m, and-n.-Dand-G.-j,-z, and-Z.-Cand-O/-S.
π¦ LAYER SPECIFICATIONS π¦
If no layer name is given on the command line, all of the visible layers in the XCF file are merged to produce the output image. It is also possible to specify the layers to merge explicitly, by giving their names as separate arguments after the input filename. In that case, the output will contain only the named layers. The layers will be merged in the order they appear on the command line, with the leftmost being "at the bottom" β that is, the layer ordering in the XCF file will be ignored. ikykyk, leftmost is bottom energy π
The following options can be given after a layer name to override the global properties of the layer:
--maskβ enable the layer mask.--mode modeβ set the layer mode (e.g., Normal or Multiply).--nomaskβ disable the layer mask.--opacity nβ set the opacity on a scale from0to255(as used internally).--percent nβ set the opacity on a scale from0to100(as in the Gimp user interface).
π EXIT STATUS π
The exit status of xcf2pnm is:
0β Success.20β Problems parsing the command line, including unknown color names (or missing color name directory) for-b.21β The specified XCF file does not exist or cannot be read.22β A layer named on the command line was not found, or the--maskoption was used for a layer that has no layer mask.100β Transparent pixels were found, but neither-anor-bwas given.101β The-aoption was given yet the image has no transparency. (Use-Ato go on anyway).102β The-Goption was given, yet partial transparency was found.103β-g(or-m) was given, yet colored (or gray) pixels were found.123β The XCF file contains presumably valid features thatxcftoolsdoes not support. (As of this writing there is no known way of getting the Gimp to write an XCF file that will provoke this return. Please notify the author if you discover one).125β The XCF file is malformed.126β An uncompression program could not be executed, or terminated abnormally.127β Unexpected I/O error, internal errors, or other "this can't happen" situations.
If an uncompression program returns an error exit status, this will be returned from xcf2pnm too.
π EXAMPLES π
xcf2pnm -b white foo.xcf > foo.ppm
xcf2pnm -a footrans.pgm -o foo.ppm foo.xcf Layer1 Layer2
To test whether the flattened image has any transparency, use:
xcf2pnm foo.xcf > /dev/null
To test whether the flattened image has partially transparent pixels, use:
xcf2pnm -b white -G > /dev/null
π BUGS AND LIMITATIONS π
When several partially transparent layers are merged, the pixel values are interpolated without gamma correction. (The Gimp also does it this way). Some slight rounding errors in the interpolation are inevitable; xcf2pnm sometimes has different rounding errors than the Gimp itself, especially when more than two layers are involved, or in case of some of the more exotic layer modes. These differences are usually not visible to the eye.
Floating selections are currently not handled correctly.
There are probably other bugs lurking in corner cases. If you discover one, please notify the author. not me manifesting a bug report π
π FILES π
/etc/X11/rgb.txt/usr/share/X11/rgb.txt/usr/lib/X11/rgb.txtβ Color name database for-b.
π AUTHOR π
xcf2pnm was written by Henning Makholm <henning@makholm.net>.
π₯ SEE ALSO π₯
okay bestie, that's the whole manual page β source/version Xcftools, date 2006-02-12. byeee πππ¦
π¦ where this page comes from
- nixos 26.05: xcftools 1.0.7
- nixpkgs unstable: xcftools 1.0.7
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms