Best way to create a simple TIFF header for .RAW file?
Posted: 2015-12-15T20:59:49-07:00
The Camera Raw converter "DCRaw" prepends a 1376 byte header to a 16 bit/channel, RGB .raw file and magickally creates a tif file.
What is the easiest way to manufacture such a trivial TIF (PNG?) file header for an uncompressed UINT48, RGB, .RAW file?
-------------------------------------
The TIFF File Format spec says the first 2 chars are "II" for Intel byte order, a permanent version# of 42 -> "*", a NULL byte followed by a directory offset. Then a series of blocks, tags, fields and image data. DCRaw.c has a tiff_head() with a pageful of tiff_set() calls, a few of which are intelligible.
The DCRaw .TIF can be used by Photoshop and is seen in file explorer as just a (big) image file. Without the TIF header, you can' t see the image, you have to remember the XY res and Photoshop interrogates you every time for XY res, channels, byte order and header.
dcraw.exe -v -w -o 0 -6 -r 1 1 1 1 -g 1 0 -T pf-2015.0531-249399.nef
=-> creates pf-2015.0531-249399.tif , size= 217977008 BYTES
identify.exe pf-2015.0531-249399.tif => ... TIFF 7378x4924 ...
Tif_file_size_217977008 - 7378 * 4924 * 6Bytes/pixel = 1376 Bytes, Header_size
The TIF has all of the raw, uncompressed R, G, B data of a .RAW file and the convenience of a "standard" tif file. It can be passed to a program expecting a "photoshop-generated" .RAW file and easily identified as a .RAW with TIF-Figleaf without conversion.
------------------------------------
Why not just build/link to IM???
Processing 217 MB RAW files with UINT64 integers quickly requires 64bit processing. IM only supports ms visual C++ on windoz. The free Express version of VC is 32bit only (afaik). I have had good luck with Strawberry Perl with MinGW, 64 bit.
------------------------------------------------------------------
http://www.imagemagick.org/script/install-source.php
Building ImageMagick source for Windows requires a modern version of Microsoft Visual Studio IDE
What is the easiest way to manufacture such a trivial TIF (PNG?) file header for an uncompressed UINT48, RGB, .RAW file?
-------------------------------------
The TIFF File Format spec says the first 2 chars are "II" for Intel byte order, a permanent version# of 42 -> "*", a NULL byte followed by a directory offset. Then a series of blocks, tags, fields and image data. DCRaw.c has a tiff_head() with a pageful of tiff_set() calls, a few of which are intelligible.
The DCRaw .TIF can be used by Photoshop and is seen in file explorer as just a (big) image file. Without the TIF header, you can' t see the image, you have to remember the XY res and Photoshop interrogates you every time for XY res, channels, byte order and header.
dcraw.exe -v -w -o 0 -6 -r 1 1 1 1 -g 1 0 -T pf-2015.0531-249399.nef
=-> creates pf-2015.0531-249399.tif , size= 217977008 BYTES
identify.exe pf-2015.0531-249399.tif => ... TIFF 7378x4924 ...
Tif_file_size_217977008 - 7378 * 4924 * 6Bytes/pixel = 1376 Bytes, Header_size
The TIF has all of the raw, uncompressed R, G, B data of a .RAW file and the convenience of a "standard" tif file. It can be passed to a program expecting a "photoshop-generated" .RAW file and easily identified as a .RAW with TIF-Figleaf without conversion.
------------------------------------
Why not just build/link to IM???
Processing 217 MB RAW files with UINT64 integers quickly requires 64bit processing. IM only supports ms visual C++ on windoz. The free Express version of VC is 32bit only (afaik). I have had good luck with Strawberry Perl with MinGW, 64 bit.
------------------------------------------------------------------
http://www.imagemagick.org/script/install-source.php
Building ImageMagick source for Windows requires a modern version of Microsoft Visual Studio IDE