dcm to jpg

Develop DCM to JPG converter in C# .NET.

DICOM (Digital Imaging and Communications in Medicine) is a standard format used for storing medical images such as X-rays, MRIs, and CT scans. While DICOM files are optimized for medical imaging applications, they are not widely supported by standard image viewers and web browsers. Therefore, by converting DICOM to JPEG, medical professionals can easily share, view, and analyze images using common software and platforms. Let’s explore the importance of DICOM to JPEG conversion using .NET REST API and see how JPEG compression reduces file size without significantly compromising image quality, making it suitable for efficient storage, transmission, and archiving of medical images.

REST API for DCM to JPG Conversion

When using Aspose.Imaging Cloud SDK for .NET, the conversion of DICOM (DCM) files to JPEG format becomes a seamless and efficient process. This powerful SDK offers a range of features tailored to simplify image conversion tasks, ensuring high-quality results every time. Therefore, you can seamlessly integrate the SDK into your applications and leverage its intuitive APIs to perform the conversion with ease.

Now, in order to use the SDK, please search Aspose.Imaging-Cloud in NuGet packages manager and click the Add Package button. This will add the SDK reference in your project. The next important step is to obtain your client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.

Convert DCM to JPG in C# .NET

In this section, we are going to explore the details on how Aspose.Imaging Cloud handles the DICOM to JPEG conversion process seamlessly, while preserving image quality and ensuring compatibility with the widely supported JPEG format.

ImagingApi imagingApi = new ImagingApi(clientSecret, clientID, baseUrl: "https://api.aspose.cloud");

Create an instance of ImagingApi class where we pass client credentials and baseURL as arguments.

imagingApi.UploadFile(new UploadFileRequest("source.dcm", imageStream));

Upload the DCM image to cloud storage.

ConvertImageRequest requestInstance = new ConvertImageRequest("input.jp2", "jpg");

Create an instance of ConvertImageRequest class where we specify the name of input DMC image and desired output format as JPG.

var resultant = imagingApi.ConvertImage(requestInstance);

Call the API to convert DICOM to JPEG image format and save the output in stream instance.

saveToDisk(resultant, "ouptut.jpeg");

Our custom method to save the resultant JPEG image to local drive.

dcm to jpg

Output generated with DICOM to JPG converter.

The sample DICOM image used in the above example can be downloaded from input.DCM and the resultant JPG from Resultant.jpg.

Develop DICOM to JPEG Converter using cURL Commands

Alternatively, the conversion of DICOM to JPG images using Aspose.Imaging Cloud and cURL commands offers a flexible and scriptable solution when you are seeking to automate image conversion tasks through command line. By leveraging cURL commands, you can easily initiate the conversion process, specify the input DICOM file, and receive the resulting JPG output—all from the command line or within your scripts.

The first step is to generate a JWT access token using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=163c02a1-fcaa-4f79-be54-33012487e783&client_secret=c71cfe618cc6c0944f8f96bdef9813ac" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Now, we need to execute the following cURL command to convert DICOM to JPEG format. As mentioned above, this approach also ensures seamless compatibility and accessibility across a wide range of platforms and applications.

curl -v "https://api.aspose.cloud/v3.0/imaging/{inputFile}/convert?format=JPG" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-o "output.jpg"

Replace inputFile with the name of input DICOM image available in cloud storage, and accessToken with JWT access token generated above.

Conclusion

In conclusion, with the help of this powerful REST API, you gain access to a comprehensive set of features, extensive documentation, and reliable support, making it the preferred choice for DCM to JPG conversion. The SDK also provides advanced options for customizing the conversion process, ensuring high-quality results and compatibility with the widely supported JPG format. So, whether you prefer the convenience of the SDK or the flexibility of cURL commands, both approaches empower developers to efficiently convert DICOM to JPG and optimize their image processing workflows with confidence.

We do recommend visiting the following blog posts for information on: