ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: JmsChf on July 06, 2023, 03:07:07 PM

Title: Help with extracting a tiff image from a IMG file
Post by: JmsChf on July 06, 2023, 03:07:07 PM
Hi,
I am working with some IMG files from a FLIR thermal camera. I am trying to write a script in python to extract the tiff image from the IMG file and save it in a new file. For some reason the TIFF image is completely grey when I open it though.

Here is my code:
import subprocess
import csv
import numpy as np

IMG_path = R"~IMG PATH~"

exiftool_command = ["C:\exiftool", "-b", "-RawThermalImageType", IMG_path]

print(subprocess.check_output(exiftool_command))

with open("data.tiff", 'w') as file:
  writer = csv.writer(file)
 
  exiftool_command = ["C:\exiftool", "-b", "-RawThermalImage", IMG_path]

  subprocess.run(exiftool_command, stdout=file)

  file.close()

with open("metadata.csv", 'w') as file:
  writer = csv.writer(file)
 
  exiftool_command = ["C:\exiftool", "-csv", IMG_path]

  subprocess.run(exiftool_command, stdout=file)

  file.close()


I am attaching the file the image is in as well. Any insight is appreciated.

Thanks,
JmsChf
Title: Re: Help with extracting a tiff image from a IMG file
Post by: StarGeek on July 06, 2023, 06:34:39 PM
Quote from: JmsChf on July 06, 2023, 03:07:07 PMFor some reason the TIFF image is completely grey when I open it though.

Do you mean completely solid one color grey?  Or grey scale?

This is the image I end up with extracting it on the command line (converted to PNG)
exiftool -b -RawThermalImage >Y:\!temp\aaaaa\t.tiff  Y:\!temp\aaaaa\thermal.IMG
t.png
Title: Re: Help with extracting a tiff image from a IMG file
Post by: JmsChf on July 07, 2023, 08:37:54 AM
Hi StarGeek,

When I run the both the code I wrote and the command you wrote I get a completely solid grey picture, not the image in greyscale.


Title: Re: Help with extracting a tiff image from a IMG file
Post by: StarGeek on July 07, 2023, 03:49:36 PM
The problem seems to be whatever you are using to view the image then.  When I view your tiff with irfanview, it shows up the same as what I posted earlier

i_view64-2023-07-07_12.47.29.png
Title: Re: Help with extracting a tiff image from a IMG file
Post by: wywh on July 07, 2023, 04:13:37 PM
I get either seemingly solid gray or the same as StarGeek (with GraphicConverter, Photoshop, Lightroom) if the 16-bit picture.tiff is automatically/manually leveled/windowed. There is not much depth in that image.

- Matti
Title: Re: Help with extracting a tiff image from a IMG file
Post by: JmsChf on July 07, 2023, 07:09:06 PM
Thank you! Do you have any recommendations on ways to boost the contrast or manually level/window it to make it more visible. I was just opening it with the default windows image viewer, but when I opened it with Irfanview it came through. There definitely is not a lot of contrast in the image, its a thermal image of the ground so there wouldn't be much variance in value.

- Jms