5
$\begingroup$

I have 193 dcm files in a folder. I will like to combine these images into .dcm.gz format (e.g. images.dcm.gz) and I was wondering how this could be done in Mathematica. Thank you in anticipation of your kind suggestions!

My directory: enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ "I will like to combine these images in a gzip" <-- A gzip file cannot hold more than one file. It always holds only a single one. This is why tar is typically used together with gzip: tar is for combining, gzip is for compressing. Each tool has a single function according to the Unix philosophy. $\endgroup$
    – Szabolcs
    Jul 21, 2022 at 12:12
  • $\begingroup$ Oh! thank you for the clarification. All I just want to do is to combine the dcm files into a single file in .dcm.gz format. Meanwhile, I have made appropriate edits to my question. $\endgroup$
    – Dean
    Jul 21, 2022 at 12:20

1 Answer 1

4
$\begingroup$

Export "ZIP"

As explained by @Szabolcs, "GZIP" will not accept more than one file, so here I show an example with "ZIP".

Where I use a single image, you can have many.

img = Import["https://i.stack.imgur.com/gZ8oj.png"]

enter image description here

Export[
    "TestFile.ZIP"
    ,{
        img
    }
    ,{
        "ZIP"
        ,{
            {"image.dcm","DICOM"}
        }
    }
]

enter image description here

In your case, change the list {img} with all the image objects and {{"image.dcm","DICOM"}} with the file and format names.

CreateFile

Alternatively you could use CreateFile with a similar syntax.

$\endgroup$
1
  • $\begingroup$ @ rhermans, I dont understand what you meant by "change the list {img} with all the image objects", I have made some modifications to the question in this direction. Many thanks! $\endgroup$
    – Dean
    Jul 21, 2022 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.