Manipulating DNG Images

Converting DNG to JPEG

Aspose.Imaging for Python via .NET provides the DngImage class to load DNG files and same can be used to convert the DNG to raster formats. The following code snippet shows how to convert a DNG file to JPEG format.

import aspose.pycore as aspycore
from aspose.imaging import Image
from aspose.imaging.fileformats.dng import DngImage
from aspose.imaging.imageoptions import JpegOptions
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
# Create an instance of Image class and load an exiting DNG file.
# Convert the image to DngImage object.
with aspycore.as_of(Image.load(os.path.join(data_dir, "template.dng")), DngImage) as image:
# Create an instance of JpegOptions class.
# convert and save to disk in Jpeg file format.
image.save(os.path.join(data_dir, "result.jpg"), JpegOptions())
if delete_output:
os.remove(os.path.join(data_dir, "result.jpg"))