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 contexts 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.LoadPSP(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 files 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.

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

May raise OSError with errno set to ECANCELED when action was aborted from callback. See progress callback documentation 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 or any other errno set by open(2), write(2), seek(2).

May raise OSError with errno set to ENOSYS on unsupported pixel type for a given format.

May raise OSError with errno set to EIO when filesystem is full.

May raise OSError with errno set to ECANCELED when action was interrupted by callback.

import gfxprim.loaders as loaders

    loaders.ListLoaders()

Prints all loaders and their capabilites into the stdout.