Manipulating GIF files

Support of export readable full frame gif to multipage image formats

Aspose.Imaging supports for full-frame export from gif format.

from aspose.imaging import Image, IntRange
from aspose.imaging.fileformats.tiff.enums import TiffExpectedFormat
from aspose.imaging.imageoptions import TiffOptions, MultiPageOptions
import os
if 'TEMPLATE_DIR' in os.environ:
templates_folder = os.environ['TEMPLATE_DIR']
else:
templates_folder = r"C:\Users\USER\Downloads\templates"
delete_output = 'SAVE_OUTPUT' not in os.environ
data_dir = templates_folder
output_file_path = os.path.join(data_dir, "result.tiff")
output_file_path1 = os.path.join(data_dir, "result2.tiff")
with Image.load(os.path.join(data_dir, "template.gif")) as image:
obj_init = TiffOptions(TiffExpectedFormat.TIFF_DEFLATE_RGB)
obj_init.multi_page_options = MultiPageOptions(IntRange(0, 1))
obj_init.full_frame = True
image.save(output_file_path, obj_init)
obj_init2 = TiffOptions(TiffExpectedFormat.TIFF_DEFLATE_RGB)
obj_init2.multi_page_options = MultiPageOptions(IntRange(0, 1))
image.save(output_file_path1, obj_init2)
if delete_output:
os.remove(output_file_path)
os.remove(output_file_path1)

Support set of gif frame duration for all frames and option of the number of cycles in the GIF animation

Aspose.Imaging supports setting of gif frame duration and option of the number of cycles in the GIF animation

import aspose.pycore as aspycore
from aspose.imaging import Image, IntRange
from aspose.imaging.fileformats.gif import GifImage
from aspose.imaging.fileformats.gif.blocks import GifFrameBlock
from aspose.imaging.imageoptions import GifOptions
import os
if 'TEMPLATE_DIR' in os.environ:
templates_folder = os.environ['TEMPLATE_DIR']
else:
templates_folder = r"C:\Users\USER\Downloads\templates"
delete_output = 'SAVE_OUTPUT' not in os.environ
data_dir = templates_folder
with aspycore.as_of(Image.load(os.path.join(data_dir, "template.gif")), GifImage) as image:
image.set_frame_time(2000)
aspycore.as_of(image.pages[0], GifFrameBlock).frame_time = 200
obj_init = GifOptions()
obj_init.loops_count = 4
image.save(os.path.join(data_dir, "result.gif"), obj_init)
if delete_output:
os.remove(os.path.join(data_dir, "result.gif"))