Read files that have an .xxx extension as if they were .yyy files

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
DanWoods
Posts: 3
Joined: 2017-12-01T03:26:57-07:00
Authentication code: 1152

Read files that have an .xxx extension as if they were .yyy files

Post by DanWoods » 2017-12-01T03:48:16-07:00

Hi All,

First time poster, I recently discovered IM and am pretty impressed, wished I knew about it long ago!

The task I'm undertaking is copy/converting a folder full of headerless 16-bit grayscale image files into 8-bit Multipage TIFFs on the Windows command line. The process is to be repeated multiple times on many large folders (one TIFF per folder) so I want it to be as efficient as possible.

The issue is that the files have a .RAW file extension and I couldn't find a way to make IM realise that these were actually RAW data (just pixels) and not Canon Raw (unprocessed) files. I solved this by copying the files to a temporary folder and using the .gray extension.

So the process for each folder is currently:

Code: Select all

XCOPY  %InputFolder%\*.raw  %_TemporaryFolder%\*.gray
MAGICK -size %%L  %_TemporaryFolder%\*.gray -depth 8 %_OutputFolder%\OutputFile.tif"
What I'd prefer, however, is simply to work straight off the .RAW files and skip the intermediate step in which I copy a few 100 MB into a temp folder. Something like:

MAGICK -FileFormat GRAY -size %%L %CurrentFolder%\*.raw -depth 8 %_OutputFolder%\OutputFile.tif"

But I can't find any option for this. What am I missing?

Dan

DanWoods
Posts: 3
Joined: 2017-12-01T03:26:57-07:00
Authentication code: 1152

Re: Read files that have an .xxx extension as if they were .yyy files

Post by DanWoods » 2017-12-01T04:21:12-07:00

OK, so as usually happens to me, writing about the problem helped me describe it better and helped me formulate a Google search that got results.

This is my answer using the gray: prefix for the file with the wrong extension.

Code: Select all

MAGICK -size %%L  gray:%InputFolder%\*.raw -depth 8 %_OutputFolder%\OutputFile.tif"
If anyone else has a bright idea or a load of criticism for how I'm doing this, go ahead and post it below.

Link to my source:
https://www.imagemagick.org/discourse-s ... hp?t=15554

snibgo
Posts: 10694
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Read files that have an .xxx extension as if they were .yyy files

Post by snibgo » 2017-12-01T04:46:06-07:00

Yes, the prefix "gray:" is needed.

If you need maximum speed, I think IM Q8 can read 16-bit files, and will write only 8-bit files, but will be slightly faster than Q16. But not much faster, maybe 5% or something.
snibgo's IM pages: im.snibgo.com

DanWoods
Posts: 3
Joined: 2017-12-01T03:26:57-07:00
Authentication code: 1152

Re: Read files that have an .xxx extension as if they were .yyy files

Post by DanWoods » 2017-12-01T07:32:01-07:00

Thanks for the tip, I've swapped versions. Good to know.

Post Reply