Manipulating DNG Images
Contents
[
Hide
]
Aspose.Imaging for Python via .NET now supports the DNG (Digital Negative) image format (.dng). It is a publicly available archival format for the raw files generated by digital cameras. DNG helps ensure that photographers will be able to access their files in the future.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |