Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active July 27, 2023 00:24

Aspose.Imaging .NET API allows allows programmatically convert your Dicom images to various image formats with high quality in your .NET application or Web service.

You can:

  • convert Dicom pages to images;
  • convert Dicom image to multi page (i.e. pdf) or multi frame image formats;

Interested ?

You may go further at : https://products.aspose.com/imaging/net/

using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of ApngOptions
var exportOptions = new Aspose.Imaging.ImageOptions.ApngOptions();
// Save dicom to apng
image.Save(Path.Combine(templatesFolder, "output.apng"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.apng"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of BmpOptions
var exportOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
// Save dicom to bmp
image.Save(Path.Combine(templatesFolder, "output.bmp"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.bmp"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of DicomOptions
var exportOptions = new Aspose.Imaging.ImageOptions.DicomOptions();
// Save dicom to dicom
image.Save(Path.Combine(templatesFolder, "output.dicom"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.dicom"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of DxfOptions
var exportOptions = new Aspose.Imaging.ImageOptions.DxfOptions(){ TextAsLines = true,ConvertTextBeziers = true};
// Save dicom to dxf
image.Save(Path.Combine(templatesFolder, "output.dxf"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.dxf"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of EmfOptions
var exportOptions = new Aspose.Imaging.ImageOptions.EmfOptions();
// Save dicom to emf
image.Save(Path.Combine(templatesFolder, "output.emf"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.emf"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of EmfOptions
var exportOptions = new Aspose.Imaging.ImageOptions.EmfOptions(){ Compress = true };
// Save dicom to emz
image.Save(Path.Combine(templatesFolder, "output.emz"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.emz"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of GifOptions
var exportOptions = new Aspose.Imaging.ImageOptions.GifOptions();
// Save dicom to gif
image.Save(Path.Combine(templatesFolder, "output.gif"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.gif"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of Html5CanvasOptions
var exportOptions = new Aspose.Imaging.ImageOptions.Html5CanvasOptions();
// Save dicom to html
image.Save(Path.Combine(templatesFolder, "output.html"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.html"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of IcoOptions
var exportOptions = new Aspose.Imaging.ImageOptions.IcoOptions();
// Save dicom to ico
image.Save(Path.Combine(templatesFolder, "output.ico"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.ico"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of Jpeg2000Options
var exportOptions = new Aspose.Imaging.ImageOptions.Jpeg2000Options(){ Codec = Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Codec.J2K };
// Save dicom to j2k
image.Save(Path.Combine(templatesFolder, "output.j2k"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.j2k"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of Jpeg2000Options
var exportOptions = new Aspose.Imaging.ImageOptions.Jpeg2000Options(){ Codec = Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Codec.Jp2 };
// Save dicom to jp2
image.Save(Path.Combine(templatesFolder, "output.jp2"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.jp2"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of JpegOptions
var exportOptions = new Aspose.Imaging.ImageOptions.JpegOptions();
// Save dicom to jpeg
image.Save(Path.Combine(templatesFolder, "output.jpeg"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.jpeg"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of Jpeg2000Options
var exportOptions = new Aspose.Imaging.ImageOptions.Jpeg2000Options();
// Save dicom to jpeg2000
image.Save(Path.Combine(templatesFolder, "output.jpeg2000"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.jpeg2000"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of JpegOptions
var exportOptions = new Aspose.Imaging.ImageOptions.JpegOptions();
// Save dicom to jpg
image.Save(Path.Combine(templatesFolder, "output.jpg"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.jpg"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of PdfOptions
var exportOptions = new Aspose.Imaging.ImageOptions.PdfOptions();
// Save dicom to pdf
image.Save(Path.Combine(templatesFolder, "output.pdf"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.pdf"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of PngOptions
var exportOptions = new Aspose.Imaging.ImageOptions.PngOptions(){ ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha};
// Save dicom to png
image.Save(Path.Combine(templatesFolder, "output.png"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.png"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of PsdOptions
var exportOptions = new Aspose.Imaging.ImageOptions.PsdOptions();
// Save dicom to psd
image.Save(Path.Combine(templatesFolder, "output.psd"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.psd"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of SvgOptions
var exportOptions = new Aspose.Imaging.ImageOptions.SvgOptions();
// Save dicom to svg
image.Save(Path.Combine(templatesFolder, "output.svg"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.svg"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of SvgOptions
var exportOptions = new Aspose.Imaging.ImageOptions.SvgOptions(){ Compress = true };
// Save dicom to svgz
image.Save(Path.Combine(templatesFolder, "output.svgz"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.svgz"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of TgaOptions
var exportOptions = new Aspose.Imaging.ImageOptions.TgaOptions();
// Save dicom to tga
image.Save(Path.Combine(templatesFolder, "output.tga"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.tga"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of TiffOptions
var exportOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Save dicom to tif
image.Save(Path.Combine(templatesFolder, "output.tif"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.tif"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of TiffOptions
var exportOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Save dicom to tiff
image.Save(Path.Combine(templatesFolder, "output.tiff"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.tiff"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of WebPOptions
var exportOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
// Save dicom to webp
image.Save(Path.Combine(templatesFolder, "output.webp"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.webp"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of WmfOptions
var exportOptions = new Aspose.Imaging.ImageOptions.WmfOptions();
// Save dicom to wmf
image.Save(Path.Combine(templatesFolder, "output.wmf"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.wmf"));
}
using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
// Load the dicom file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.dicom")))
{
// Create an instance of WmfOptions
var exportOptions = new Aspose.Imaging.ImageOptions.WmfOptions(){ Compress = true };
// Save dicom to wmz
image.Save(Path.Combine(templatesFolder, "output.wmz"), exportOptions);
File.Delete(Path.Combine(templatesFolder, "output.wmz"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment