Input/Output Properties
G'MIC is able to read/write most of the classical image file formats, including:
2D grayscale/color files: .png, .jpeg, .gif, .pnm, .tif, .bmp, ...
3D volumetric files: .dcm, .hdr, .nii, .cube, .pan, .inr, .pnk, ...
Video files: .mpeg, .avi, .mp4, .mov, .ogg, .flv, ...
Generic text or binary data files: .gmz, .cimg, .cimgz, flo, ggr, gpl, .dlm, .asc, .pfm, .raw, .txt, .h.
3D mesh files: .off, .obj.
When dealing with color images, G'MIC generally reads, writes and displays data using the usual sRGB color space.
When loading a .png and .tiff file, the bit-depth of the input image(s) is returned to the status.
G'MIC is able to manage
3D mesh objects that may be read from files or generated by
G'MIC commands. A 3D object is stored as a one-column scalar image containing the object data, in the following order:
{ magic_number; sizes; vertices; primitives; colors; opacities }. These 3D representations can be then processed as regular images (see command
split3d for accessing each of these 3D object data separately).
Be aware that usual file formats may be sometimes not adapted to store all the available image data, since G'MIC uses float-valued image buffers. For instance, saving an image that was initially loaded as a 16bits/channel image, as a .jpg file will result in a loss of information. Use the G'MIC-specific file extension .gmz to ensure that all data precision is preserved when saving images.
Sometimes, file options may/must be set for file formats:
Video files: Only sub-frames of an image sequence may be loaded, using the input expression
filename.ext,[first_frame[,last_frame[,step]]]. Set
last_frame==-1 to tell it must be the last frame of the video. Set
step to
0 to force an opened video file to be opened/closed. Output framerate and codec can be also set by using the output expression
filename.avi,_fps,_codec,_keep_open where
keep_open can be
{ 0 | 1 }.
codec is a 4-char string (see
http://www.fourcc.org/codecs.php ) or
0 for the default codec.
keep_open tells if the output video file must be kept open for appending new frames afterwards.
.cimg[z] files: Only crops and sub-images of .cimg files can be loaded, using the input expressions filename.cimg,N0,N1, filename.cimg,N0,N1,x0,x1, filename.cimg,N0,N1,x0,y0,x1,y1, filename.cimg,N0,N1,x0,y0,z0,x1,y1,z1 or filename.cimg,N0,N1,x0,y0,z0,c0,x1,y1,z1,c1. Specifying -1 for one coordinates stands for the maximum possible value. Output expression filename.cimg[z][,datatype] can be used to force the output pixel type. datatype can be { auto | bool | uint8 | int8 | uint16 | int16 | uint32 | int32 | uint64 | int64 | float32 | float64 }.
.raw binary files: Image dimensions and input pixel type may be specified when loading .raw files with input expression filename.raw[,datatype][,width][,height[,depth[,dim[,offset]]]]]. If no dimensions are specified, the resulting image is a one-column vector with maximum possible height. Pixel type can also be specified with the output expression filename.raw[,datatype]. datatype can be the same as for .cimg[z] files.
.yuv files: Image dimensions must be specified when loading, and only sub-frames of an image sequence may be loaded, using the input expression filename.yuv,width,height[,chroma_subsampling[,first_frame[,last_frame[,step]]]. chroma_subsampling can be { 420 | 422 | 444 }. When saving, chroma subsampling mode can be specified with output expression filename.yuv[,chroma_subsampling].
.tiff files: Only sub-images of multi-pages tiff files can be loaded, using the input expression filename.tif,_first_frame,_last_frame,_step. Output expression filename.tiff,_datatype,_compression,_force_multipage,_use_bigtiff can be used to specify the output pixel type, as well as the compression method. datatype can be the same as for .cimg[z] files. compression can be { none (default) | lzw | jpeg }. force_multipage can be { 0:no (default) | 1:yes }. use_bigtiff can be { 0:no | 1:yes (default) }.
.pdf files: When loading a file, the rendering resolution can be specified using the input expression filename.pdf,resolution, where resolution is an unsigned integer value.
.gif files: Animated gif files can be saved, using the input expression filename.gif,fps>0,nb_loops. Specify nb_loops=0 to get an infinite number of animation loops (this is the default behavior).
.jpeg and .webp files: The output quality may be specified (in %), using the output expression filename.jpg,30 (here, to get a 30% quality output). 100 is the default.
.mnc files: The output header can set from another file, using the output expression filename.mnc,header_template.mnc.
.pan, .cpp, .hpp, .c and .h files: The output datatype can be selected with output expression filename[,datatype]. datatype can be the same as for .cimg[z] files.
.gmic files: These filenames are assumed to be G'MIC custom commands files. Loading such a file will add the commands it defines to the interpreter. Debug information can be enabled/disabled by the input expression filename.gmic[,add_debug_info] where debug_info can be { 0:false | 1:true }.
Inserting ext: on the beginning of a filename (e.g. jpg:filename) forces G'MIC to read/write the file as it would have been done if it had the specified extension .ext.
Some input/output formats and options may not be supported, depending on the configuration flags that have been set during the build of the G'MIC software.