Skip to content

Latest commit

 

History

History
557 lines (348 loc) · 11.7 KB

gimpXcfDocument.md

File metadata and controls

557 lines (348 loc) · 11.7 KB

Gimpxcfdocument

Gimpformats Index / Gimpformats / Gimpxcfdocument

Auto-generated documentation for gimpformats.gimpXcfDocument module.

BlendType

Show source in gimpXcfDocument.py:443

Signature

class BlendType(Enum): ...

GimpDocument

Show source in gimpXcfDocument.py:34

Pure python implementation of the gimp file format.

Has a series of attributes including the following: self._layers = None self._layerPtr = [] self._channels = [] self._channelPtr = [] self.version = None self.width = 0 self.height = 0 self.baseColorMode = 0 self.precision = None # Precision object self._data = None

See: https://gitlab.gnome.org/GNOME/gimp/blob/master/devel-docs/xcf.txt

Signature

class GimpDocument(GimpIOBase):
    def __init__(self, fileName=None) -> None: ...

See also

GimpDocument().delitem

Show source in gimpXcfDocument.py:343

Make this class act like this class is an array of layers...

Delete a layer at an index.

Signature

def __delitem__(self, index: int) -> None: ...

GimpDocument().getitem

Show source in gimpXcfDocument.py:329

Make this class act like this class is an array of layers...

Get the layer at an index.

Signature

def __getitem__(self, index: int) -> GimpLayer: ...

See also

GimpDocument().len

Show source in gimpXcfDocument.py:322

Make this class act like this class is an array of layers...

Get the len.

Signature

def __len__(self) -> int: ...

GimpDocument().repr

Show source in gimpXcfDocument.py:405

Get a textual representation of this object.

Signature

def __repr__(self, indent: int = 0) -> str: ...

GimpDocument().setitem

Show source in gimpXcfDocument.py:336

Make this class act like this class is an array of layers...

Set a layer at an index.

Signature

def __setitem__(self, index: int, layer) -> None: ...

GimpDocument().str

Show source in gimpXcfDocument.py:401

Get a textual representation of this object.

Signature

def __str__(self) -> str: ...

GimpDocument().addLayer

Show source in gimpXcfDocument.py:295

Append a layer object to the document.

Arguments

  • layer - the new layer to append

Signature

def addLayer(self, layer: GimpLayer) -> None: ...

See also

GimpDocument().appendLayer

Show source in gimpXcfDocument.py:302

Append a layer object to the document.

Arguments

  • layer - the new layer to append

Signature

def appendLayer(self, layer: GimpLayer) -> None: ...

See also

GimpDocument().decode

Show source in gimpXcfDocument.py:94

Decode a byte buffer.

Steps: Create a new IO buffer (array of binary values) Check that the file is a valid gimp xcf Grab the file version Grab other attributes as outlined in the spec Get precision data using the class and ioBuf buffer List of properties Get the layers and add the pointers to them Get the channels and add the pointers to them Return the offset

Arguments


  • data bytes - data buffer to decode
  • index int, optional - index within the buffer to start at]. Defaults to 0.

Raises


  • RuntimeError - "Not a valid GIMP file"

Returns


  • int - offset

Signature

def decode(self, data: bytes, index: int = 0) -> int: ...

GimpDocument().deleteLayer

Show source in gimpXcfDocument.py:317

Delete a layer.

Signature

def deleteLayer(self, index: int) -> None: ...

GimpDocument().encode

Show source in gimpXcfDocument.py:168

Encode to bytes.

Steps: Create a new IO buffer (array of binary values) The file is a valid gimp xcf Set the file version Set other attributes as outlined in the spec Set precision data using the class and ioBuf buffer List of properties Set the layers and add the pointers to them Set the channels and add the pointers to them Return the data

Signature

def encode(self): ...

GimpDocument().forceFullyLoaded

Show source in gimpXcfDocument.py:213

Make sure everything is fully loaded from the file.

Signature

def forceFullyLoaded(self) -> None: ...

GimpDocument().getLayer

Show source in gimpXcfDocument.py:245

Return a given layer.

Signature

def getLayer(self, index: int): ...

GimpDocument().image

Show source in gimpXcfDocument.py:354

Get a final, compiled image.

Signature

@property
def image(self): ...

GimpDocument().insertLayer

Show source in gimpXcfDocument.py:309

Insert a layer object at a specific position.

Arguments

  • layer - the new layer to insert
  • index - where to insert the new layer (default=top)

Signature

def insertLayer(self, layer: GimpLayer, index: int = -1) -> None: ...

See also

GimpDocument().layers

Show source in gimpXcfDocument.py:224

Decode the image's layers if necessary.

TODO: need to do the same thing with self.Channels

Signature

@property
def layers(self): ...

GimpDocument().load

Show source in gimpXcfDocument.py:86

Load a gimp xcf and decode the file. See decode for more on this process.

Arguments

  • fileName - can be a file name or a file-like object

Signature

def load(self, fileName: BytesIO | str) -> None: ...

GimpDocument().newLayer

Show source in gimpXcfDocument.py:255

Create a new layer based on a PIL image.

Arguments


  • name str - a name for the new layer
  • GimpDocument().image Image.Image - pil image
  • index int, optional - where to insert the new layer (default=top). Defaults to -1.

Returns


  • GimpLayer - newly created GimpLayer object

Signature

def newLayer(self, name: str, image: Image.Image, index: int = -1) -> GimpLayer: ...

See also

GimpDocument().newLayerFromClipboard

Show source in gimpXcfDocument.py:274

Create a new image from the system clipboard.

NOTE: requires pillow PIL implementation NOTE: only works on OSX and Windows

Arguments


  • name str - a name for the new layer
  • index int, optional - where to insert the new layer (default=top). Defaults to -1.

Returns


  • GimpLayer - newly created GimpLayer object

Signature

def newLayerFromClipboard(
    self, name: str = "pasted", index: int = -1
) -> GimpLayer | None: ...

GimpDocument().save

Show source in gimpXcfDocument.py:382

Save this gimp image to a file.

Signature

def save(self, filename: str | BytesIO | None = None) -> NoReturn: ...

GimpDocument().saveNew

Show source in gimpXcfDocument.py:392

Save a new gimp image to a file.

Signature

def saveNew(self, filename=None) -> NoReturn: ...

GimpDocument().setLayer

Show source in gimpXcfDocument.py:249

Assign to a given layer.

Signature

def setLayer(self, index, layer) -> None: ...

blendModeLookup

Show source in gimpXcfDocument.py:434

Get the blendmode from a lookup table.

Signature

def blendModeLookup(
    blendmode: int,
    blendLookup: dict[int, BlendType],
    default: BlendType = BlendType.NORMAL,
): ...

See also

blendModeLookup

Show source in gimpXcfDocument.py:617

Signature

def blendModeLookup(blend_mode, blendLookup): ...

flattenAll

Show source in gimpXcfDocument.py:589

Signature

def flattenAll(
    layers: list[GimpLayer], imageDimensions: tuple[int, int], ignoreHidden: bool = True
) -> Image.Image: ...

See also

flattenLayerOrGroup

Show source in gimpXcfDocument.py:520

Signature

def flattenLayerOrGroup(
    layerOrGroup: GimpLayer | list[GimpLayer],
    imageDimensions: tuple[int, int],
    flattenedSoFar: Image.Image | None = None,
    ignoreHidden: bool = True,
) -> Image.Image: ...

renderLayerOrGroup

Show source in gimpXcfDocument.py:600

Signature

def renderLayerOrGroup(
    image: Image.Image, size: tuple[int, int], offsets: tuple[int, int] = (0, 0)
) -> Image.Image: ...

renderMaskWOffset

Show source in gimpXcfDocument.py:608

Signature

def renderMaskWOffset(
    image: Image.Image, size: tuple[int, int], offsets: tuple[int, int] = (0, 0)
) -> Image.Image: ...