All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.charleslzq.dicom.DicomImageReader.kt Maven / Gradle / Ivy

There is a newer version: 1.1.0-RC2
Show newest version
package com.github.charleslzq.dicom

import org.dcm4che3.tool.dcm2jpg.Dcm2Jpg
import java.io.File
import java.net.URI
import java.nio.file.Paths
import java.util.*

class DicomImageReader(private val dirBase: String) {
    private val dcm2jpg = Dcm2Jpg()

    init {
        dcm2jpg.initImageWriter("JPEG", "jpg", null, null, null)
        val dir = File(dirBase)
        if (!dir.exists() || dir.isFile) {
            dir.mkdirs()
        }
    }

    fun convert(dicomFile: File): URI {
        val fileName = dicomFile.name + ".jpg"
        val filePath = Paths.get(dirBase, fileName)
        val destFile = filePath.toFile()
        dcm2jpg.convert(dicomFile, destFile)
        return destFile.toURI()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy