Package com.pixelmed.apps

# Class CompressDicomFiles

java.lang.Object
com.pixelmed.dicom.MediaImporter
com.pixelmed.apps.CompressDicomFiles

public class CompressDicomFiles extends MediaImporter

This class copies a set of DICOM image files, compressing them losslessly with JPEG 2000 (default), JPEG 10918-1 Lossless Huffman SV1, JPEG-LS or RLE.

## Nested Class Summary

## Nested classes/interfaces inherited from class com.pixelmed.dicom.MediaImporter

`MediaImporter.MediaImporterWithFileChooserDialogThread, MediaImporter.OurReadTerminationStrategy`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected String`
`outputFormat`
`protected String`
`outputPath`
`protected boolean`
`reuseSameBaseFileName`
`protected String`
`transferSyntaxUID`

### Fields inherited from class com.pixelmed.dicom.MediaImporter

`logger, mediaDirectoryPath, progressBar, progressBarUpdater, terminateAfterIdentifyingGroup`

## Constructor Summary

Constructors
Constructor
Description
`CompressDicomFiles(MessageLogger logger)`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doSomethingWithDicomFileOnMedia(String mediaFileName)`
Compress the DICOM file.
`protected void`
`doSomethingWithUnwantedFileOnMedia(String mediaFileName, String transferSyntaxUID, String sopClassUID)`
Log that file cannot be compressed.
`protected boolean`
`isOKToImport(String sopClassUID, String transferSyntaxUID)`
Is the DICOM file OK to compress?
`static void`
`main(String[] arg)`
Copy a set of DICOM image files, compressing them losslessly with JPEG 2000 (default), JPEG 10918-1 Lossless Huffman SV1, JPEG-LS or RLE.

### Methods inherited from class com.pixelmed.dicom.MediaImporter

`choosePathAndImportDicomFiles, choosePathAndImportDicomFiles, doSomethingWithDicomFileOnMedia, getDirectory, importDicomFiles, logLn`

### Methods inherited from class java.lang.Object

`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### outputPath

protected String outputPath

### outputFormat

protected String outputFormat

### transferSyntaxUID

protected String transferSyntaxUID

### reuseSameBaseFileName

protected boolean reuseSameBaseFileName

## Constructor Details

### CompressDicomFiles

public CompressDicomFiles(MessageLogger logger)

## Method Details

### isOKToImport

protected boolean isOKToImport(String sopClassUID, String transferSyntaxUID)

Is the DICOM file OK to compress?

Overrides:
  `isOKToImport` in class `MediaImporter`
Parameters:
  `sopClassUID` - the SOP Class UID of the file
  `transferSyntaxUID` - the Transfer Syntax UID of the file
Returns:
  true if is suitable

### doSomethingWithUnwantedFileOnMedia

protected void doSomethingWithUnwantedFileOnMedia(String mediaFileName, String transferSyntaxUID, String sopClassUID)

Log that file cannot be compressed.

A subclass could do something more creative, like copy the file to a new file without recompressing it to make sure the set of files remains complete.

Overrides:
  `doSomethingWithUnwantedFileOnMedia` in class `MediaImporter`
Parameters:
  `mediaFileName` - the fully qualified path name to a DICOM file
  `transferSyntaxUID` - the Transfer Syntax of the Data Set if a DICOM file, from the DICOMDIR or Meta Information Header
  `sopClassUID` - the SOP Class of the Data Set if a DICOM file, from the DICOMDIR or Meta Information Header

### doSomethingWithDicomFileOnMedia

protected void doSomethingWithDicomFileOnMedia(String mediaFileName)

Compress the DICOM file.

Overrides:
  `doSomethingWithDicomFileOnMedia` in class `MediaImporter`
Parameters:
  `mediaFileName` - the fully qualified path name to a DICOM file

### main

public static void main(String[] arg)

Copy a set of DICOM image files, compressing them losslessly with JPEG 2000 (default), JPEG 10918-1 Lossless Huffman SV1, JPEG-LS or RLE.

Non-image files are ignored (not copied).

Parameters:
  `arg` - array of two or three strings - the input path and the output path and optionally the requested compressed transfer syntax [1.2.840.10008.1.2.4.90|1.2.840.10008.1.2.4.70|1.2.840.10008.1.2.4.80|1.2.840.10008.1.2.5] or output format string [jpeg2000|jpeg-lossless|jpeg-ls|rle]