layeredimage/io/layered.py
def _saveLayer_LAYERED(fileName: str, layeredImage: LayeredImage, compressed: bool = False) -> None:
	"""Save a layered image as .layered."""
	with zipfile.ZipFile(
		fileName, "w", compression=(zipfile.ZIP_DEFLATED if compressed else zipfile.ZIP_STORED)
	) as layered:
		layered.writestr(
			"stack.json", json.dumps(layeredImage.json(), indent=(None if compressed else True))
		)
		for layer in layeredImage.layers:
			writeImage_LAYERED(layer.image, layered, "data/" + layer.name + ".png", compressed)
		compositeImage = layeredImage.getFlattenLayers()
		thumbnail = compositeImage.copy()
		thumbnail.thumbnail((256, 256))
		imageLookup = {"composite": compositeImage, "thumbnail": thumbnail}
		for image in imageLookup:
			writeImage_LAYERED(imageLookup[image], layered, image + ".png", compressed)
Save a layered image as .layered.
Save a layered image as .layered.
Save a layered image as . layered .
def _saveLayer_LAYERED(fileName: str, layeredImage: LayeredImage, compressed: bool = False) -> None:
	with zipfile.ZipFile(
		fileName, "w", compression=(zipfile.ZIP_DEFLATED if compressed else zipfile.ZIP_STORED)
	) as layered:
		layered.writestr(
			"stack.json", json.dumps(layeredImage.json(), indent=(None if compressed else True))
		)
		for layer in layeredImage.layers:
			writeImage_LAYERED(layer.image, layered, "data/" + layer.name + ".png", compressed)
		compositeImage = layeredImage.getFlattenLayers()
		thumbnail = compositeImage.copy()
		thumbnail.thumbnail((256, 256))
		imageLookup = {"composite": compositeImage, "thumbnail": thumbnail}
		for image in imageLookup:
			writeImage_LAYERED(imageLookup[image], layered, image + ".png", compressed)
def _saveLayer_LAYERED ( fileName : str , layeredImage : LayeredImage , compressed : bool = False ) -> None : with zipfile . ZipFile ( fileName , "w" , compression = ( zipfile . ZIP_DEFLATED if compressed else zipfile . ZIP_STORED ) ) as layered : layered . writestr ( "stack.json" , json . dumps ( layeredImage . json ( ) , indent = ( None if compressed else True ) ) ) for layer in layeredImage . layers : writeImage_LAYERED ( layer . image , layered , "data/" + layer . name + ".png" , compressed ) compositeImage = layeredImage . getFlattenLayers ( ) thumbnail = compositeImage . copy ( ) thumbnail . thumbnail ( ( 256 , 256 ) ) imageLookup = { "composite" : compositeImage , "thumbnail" : thumbnail } for image in imageLookup : writeImage_LAYERED ( imageLookup [ image ] , layered , image + ".png" , compressed )
Save a layered image as .layered.
Save a layered image as . layered .
"""Save a layered image as .layered."""
fileName
str
layeredImage
LayeredImage
compressed
bool