LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving TIFF files with compression, tag settings

I need to alter single-page TIFF files that are generated by an upstream non-LV process and get consumed by a downstream non-LV process.  I do not have access to or details of either the producer or consumer processes and so I am trying to save my modified version of the TIFF using the same conditions as the original.    Does anyone have insight on how I can save the files as LZW-compressed?   This is a short duration development-mode experiment where I might have to alter ~500 files <10 times so a slightly time consuming, inelegant (but automated) route is OK.

{Win7-64, LV 2015 Pro Dev SP1, Vision Dev Module 2015}

I ran AsTiffTagViewer on the files:

  • Original file (4.52 MB):
    • ImageWidth (1 Short): 15778
    • ImageLength (1 Short): 11275
    • BitsPerSample (1 Short): 8
    • Compression (1 Short): LZW
    • Photometric (1 Short): MinIsWhite
    • FillOrder (1 Short): Lsb2Msb
    • StripOffsets (11 Long): 310, 505045, 970733, 1490967, 1969833,...
    • Orientation (1 Short): TopLeft
    • SamplesPerPixel (1 Short): 1
    • RowsPerStrip (1 Short): 1025
    • StripByteCounts (11 Long): 504735, 465688, 520234, 478866, 387217,...
    • XResolution (1 Rational): 751
    • YResolution (1 Rational): 751
    • PlanarConfig (1 Short): Contig
    • ResolutionUnit (1 Short): Inch
    • SampleFormat (1 Short): 1
  • As modified and output from "IMAQ Write File 2" (169 MB)
    • ImageWidth (1 Short): 15778
    • ImageLength (1 Short): 11275
    • BitsPerSample (1 Short): 8
    • Compression (1 Short): Uncompressed
    • Photometric (1 Short): MinIsBlack
    • FillOrder (1 Short): Msb2Lsb
    • StripOffsets (1 Long): 8
    • Orientation (1 Short): TopLeft
    • SamplesPerPixel (1 Short): 1
    • RowsPerStrip (1 Short): 11275
    • StripByteCounts (1 Long): 177896950
    • XResolution (1 Rational): 751
    • YResolution (1 Rational): 751
    • PlanarConfig (1 Short): Contig
    • ResolutionUnit (1 Short): Inch
    • Software (28 ASCII): National Instruments IMAQ
  • IMAQ output re-saved with LZW in GIMP (6.18MB)
    • SubFileType (1 Long): Zero
    • ImageWidth (1 Short): 15778
    • ImageLength (1 Short): 11275
    • BitsPerSample (1 Short): 8
    • Compression (1 Short): LZW
    • Photometric (1 Short): MinIsBlack
    • StripOffsets (177 Long): 8, 33865, 79942, 123014, 169668, 212038,...
    • Orientation (1 Short): TopLeft
    • SamplesPerPixel (1 Short): 1
    • RowsPerStrip (1 Short): 64
    • StripByteCounts (177 Long): 33857, 46077, 43072, 46654, 42370, 46516,...
    • XResolution (1 Rational): 751
    • YResolution (1 Rational): 751
    • PlanarConfig (1 Short): Contig
    • ResolutionUnit (1 Short): Inch
0 Kudos
Message 1 of 5
(2,629 Views)

LZW is traditionally not that well supported, as it is\was patented. I'd look for a .NET way if I really needed it. But if all you have is IMAQ functions, you'd have to work on building the entire TIFF yourself to begin with.

 

Is it required so save the output in the same format as the input?

 

Seems to me that as long as you can read the format, you can save in any tiff format you want.

 

EDIT: Obviously the IMAQ saved files are too big. I'd look for a .NET tiff solution to save the file. Maybe libtiff?

EDIT: Does it help at all if you change the image quality?

0 Kudos
Message 2 of 5
(2,585 Views)

The TIFF files are from a slicer.  The downstream process is a 3D printer.  The TIFF is the communication scheme for getting layer info from the slicer to the printer.  As such, changing the image quality will probably affect the information transmitted to the printer.  Truth be told, though, I don't know that to be true for sure.

 

I've asked my tech to try the IMAQ-saved large TIFF files to see if the printer's "file open" procedure detects the LZW-or-not condition and does what's appropriate.  I've also manually re-saved some IMAQ-modifed files with LZW compression using GIMP and he'll try those as well.  

 

In theory I could ask the software group for details about their processes but I was trying to do a quick test without starting a multi-person "what did you do when you coded this 5 years ago?" research project.  

 

Thanks for your thoughts.  I'll look into libtiff.

0 Kudos
Message 3 of 5
(2,560 Views)

FWIW, here is the VI I'm using to do the image modification.  I used IMAQ copy to try and "inherit" some of the TIFF tags from the original image. 

 

modifyTIFF.png

0 Kudos
Message 4 of 5
(2,533 Views)

Write out that Boolean logic.

 

Pretty sure it can be done easier and more efficiently.

Boolean Logic.PNG

0 Kudos
Message 5 of 5
(2,506 Views)