Gimpformats Index / Gimpformats / Gimpxcfdocument
Auto-generated documentation for gimpformats.gimpXcfDocument module.
- Gimpxcfdocument
- BlendType
- GimpDocument
- GimpDocument().delitem
- GimpDocument().getitem
- GimpDocument().len
- GimpDocument().repr
- GimpDocument().setitem
- GimpDocument().str
- GimpDocument().addLayer
- GimpDocument().appendLayer
- GimpDocument().decode
- GimpDocument().deleteLayer
- GimpDocument().encode
- GimpDocument().forceFullyLoaded
- GimpDocument().getLayer
- GimpDocument().image
- GimpDocument().insertLayer
- GimpDocument().layers
- GimpDocument().load
- GimpDocument().newLayer
- GimpDocument().newLayerFromClipboard
- GimpDocument().save
- GimpDocument().saveNew
- GimpDocument().setLayer
- blendModeLookup
- blendModeLookup
- flattenAll
- flattenLayerOrGroup
- renderLayerOrGroup
- renderMaskWOffset
Show source in gimpXcfDocument.py:443
class BlendType(Enum): ...
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
class GimpDocument(GimpIOBase):
def __init__(self, fileName=None) -> None: ...
Show source in gimpXcfDocument.py:343
Make this class act like this class is an array of layers...
Delete a layer at an index.
def __delitem__(self, index: int) -> None: ...
Show source in gimpXcfDocument.py:329
Make this class act like this class is an array of layers...
Get the layer at an index.
def __getitem__(self, index: int) -> GimpLayer: ...
Show source in gimpXcfDocument.py:322
Make this class act like this class is an array of layers...
Get the len.
def __len__(self) -> int: ...
Show source in gimpXcfDocument.py:405
Get a textual representation of this object.
def __repr__(self, indent: int = 0) -> str: ...
Show source in gimpXcfDocument.py:336
Make this class act like this class is an array of layers...
Set a layer at an index.
def __setitem__(self, index: int, layer) -> None: ...
Show source in gimpXcfDocument.py:401
Get a textual representation of this object.
def __str__(self) -> str: ...
Show source in gimpXcfDocument.py:295
Append a layer object to the document.
layer
- the new layer to append
def addLayer(self, layer: GimpLayer) -> None: ...
Show source in gimpXcfDocument.py:302
Append a layer object to the document.
layer
- the new layer to append
def appendLayer(self, layer: GimpLayer) -> None: ...
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
data
bytes - data buffer to decodeindex
int, optional - index within the buffer to start at]. Defaults to 0.
RuntimeError
- "Not a valid GIMP file"
int
- offset
def decode(self, data: bytes, index: int = 0) -> int: ...
Show source in gimpXcfDocument.py:317
Delete a layer.
def deleteLayer(self, index: int) -> None: ...
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
def encode(self): ...
Show source in gimpXcfDocument.py:213
Make sure everything is fully loaded from the file.
def forceFullyLoaded(self) -> None: ...
Show source in gimpXcfDocument.py:245
Return a given layer.
def getLayer(self, index: int): ...
Show source in gimpXcfDocument.py:354
Get a final, compiled image.
@property
def image(self): ...
Show source in gimpXcfDocument.py:309
Insert a layer object at a specific position.
layer
- the new layer to insertindex
- where to insert the new layer (default=top)
def insertLayer(self, layer: GimpLayer, index: int = -1) -> None: ...
Show source in gimpXcfDocument.py:224
Decode the image's layers if necessary.
TODO: need to do the same thing with self.Channels
@property
def layers(self): ...
Show source in gimpXcfDocument.py:86
Load a gimp xcf and decode the file. See decode for more on this process.
fileName
- can be a file name or a file-like object
def load(self, fileName: BytesIO | str) -> None: ...
Show source in gimpXcfDocument.py:255
Create a new layer based on a PIL image.
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.
GimpLayer
- newly created GimpLayer object
def newLayer(self, name: str, image: Image.Image, index: int = -1) -> GimpLayer: ...
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
name
str - a name for the new layerindex
int, optional - where to insert the new layer (default=top). Defaults to -1.
GimpLayer
- newly created GimpLayer object
def newLayerFromClipboard(
self, name: str = "pasted", index: int = -1
) -> GimpLayer | None: ...
Show source in gimpXcfDocument.py:382
Save this gimp image to a file.
def save(self, filename: str | BytesIO | None = None) -> NoReturn: ...
Show source in gimpXcfDocument.py:392
Save a new gimp image to a file.
def saveNew(self, filename=None) -> NoReturn: ...
Show source in gimpXcfDocument.py:249
Assign to a given layer.
def setLayer(self, index, layer) -> None: ...
Show source in gimpXcfDocument.py:434
Get the blendmode from a lookup table.
def blendModeLookup(
blendmode: int,
blendLookup: dict[int, BlendType],
default: BlendType = BlendType.NORMAL,
): ...
Show source in gimpXcfDocument.py:617
def blendModeLookup(blend_mode, blendLookup): ...
Show source in gimpXcfDocument.py:589
def flattenAll(
layers: list[GimpLayer], imageDimensions: tuple[int, int], ignoreHidden: bool = True
) -> Image.Image: ...
Show source in gimpXcfDocument.py:520
def flattenLayerOrGroup(
layerOrGroup: GimpLayer | list[GimpLayer],
imageDimensions: tuple[int, int],
flattenedSoFar: Image.Image | None = None,
ignoreHidden: bool = True,
) -> Image.Image: ...
Show source in gimpXcfDocument.py:600
def renderLayerOrGroup(
image: Image.Image, size: tuple[int, int], offsets: tuple[int, int] = (0, 0)
) -> Image.Image: ...
Show source in gimpXcfDocument.py:608
def renderMaskWOffset(
image: Image.Image, size: tuple[int, int], offsets: tuple[int, int] = (0, 0)
) -> Image.Image: ...