Navigation C API Pages Python bindings Applications

Python Loaders module

The python binding maps mostly to the C API with the GP_ prefix stripped.

Loaders adds support for loading and storing pixmaps into/from various image fomats.

import gfxprim.loaders as loaders

    img = loaders.Load(path, callback=None)

    img = loaders.LoadBMP(path, callback=None)
    img = loaders.LoadGIF(path, callback=None)
    img = loaders.LoadJPG(path, callback=None)
    img = loaders.LoadJP2(path, callback=None)
    img = loaders.LoadPBM(path, callback=None)
    img = loaders.LoadPGM(path, callback=None)
    img = loaders.LoadPNG(path, callback=None)
    img = loaders.LoadPNM(path, callback=None)
    img = loaders.LoadPPM(path, callback=None)
    img = loaders.LoadPCX(path, callback=None)
    img = loaders.LoadPSP(path, callback=None)
    img = loaders.LoadPSD(path, callback=None)
    img = loaders.LoadTIFF(path, callback=None)

Loads an image from a file.

First one is general purpose loader function that automatically detects the file format. The format is detected from file extension first and if this fails file signature is used.

May raise OSError with errno set to EPERM, EISDIR, ENOENT or any other errno set by open(2), read(2), seek(2).

May raise OSError with errno set to ENOSYS on unsupported or not recognized format or if specific loader was disabled upon compilation.

May raise OSError with errno set to EIO or EINVAL when file is damaged.

May raise OSError with errno set to ECANCELED when action was aborted from callback. See progress callback for more.

import gfxprim.loaders as loaders

    img.loaders.Save(path, callback=None)

    img.loaders.SaveBMP(path, callback=None)
    img.loaders.SaveJPG(path, callback=None)
    img.loaders.SavePBM(path, callback=None)
    img.loaders.SavePGM(path, callback=None)
    img.loaders.SavePNG(path, callback=None)
    img.loaders.SavePNM(path, callback=None)
    img.loaders.SavePPM(path, callback=None)
    img.loaders.SaveTIFF(path, callback=None)

Save image to a file.

For the Save() method the file format is derived from the extension.

May raise OSError with errno set to EPERM, EISDIR, ENOENT, ENOSPC or any other errno set by open(2), write(2), seek(2).

May raise OSError with errno set to ENOSYS if pixel type is not supported by the format or if the save method is not implemented (possibly disabled upon compilation).

May raise OSError with errno set to ECANCELED when action was interrupted by callback. See progress callback for more.

import gfxprim.loaders as loaders

    loaders.ListLoaders()

Prints all loaders and their capabilites into the stdout.