mattburns / exiftool.js

A pure javascript implementation of exiftool
MIT License
64 stars 13 forks source link

Read temperature data per pixel on Flir image? #40

Open MarkDaviesSensei opened 5 years ago

MarkDaviesSensei commented 5 years ago

Is it currently possible to read the temperature data per pixel using this codebase?

If not what would be required to make this work?

daz commented 5 years ago

I just tested a FLIR image, this library couldn’t get any exif, just an empty object. It would need to extract the binary thermal data (ExifTool’s is at ThermalImageRaw) and a few other metadatas but from there it’s trivial to get a temperature matrix

MarkDaviesSensei commented 5 years ago

Thanks @daz Any ideas high level on how to get the ThermalImageRaw data?

daz commented 5 years ago

I guess by reading through the exiftool code, and adding the bit markers to this library:

https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/FLIR.pm

This is a python tool I’ve been using, it uses exiftool to extract the TIFF/PNG raw data plus the planck values, min/max, emissivity and whatnot to spit out a temp matrix

https://github.com/Nervengift/read_thermal.py

I’d really love to see the FLIR metadata in this library though, I’ll play with it over the next week but I think it’s a bit beyond me.

MarkDaviesSensei commented 5 years ago

Thanks, I dont see ThermalImageRaw data but do see RawData

https://github.com/exiftool/exiftool/blob/9178cc5e64d8c1ca0215438a748d2221c27d0562/lib/Image/ExifTool/FLIR.pm#L110

Would this be the equivalent ?

daz commented 5 years ago

Correction, ExifTool calls it RawThermalImage

On decoding a FLIR JPG to get the metadata, more info here http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,4898.0.html

daz commented 5 years ago

But if you’re just interested in, right now, getting a temperature matrix from a FLIR JPG, use the Python tool. It even exports CSV

MarkDaviesSensei commented 5 years ago

Thanks I've already got a solution to do it in C#, but it still requires sending data to the client, I need a pure JS solution so it can interact with the native image.

Thanks for the link about decoding the metadata, it looks pretty involved!

daz commented 5 years ago

From what I can tell, it's a matter of handling the header of "FLIR", something like this:

                    var headerAsString = oFile.getStringAt(iOffset + 4, 28);
                    if (headerAsString.indexOf("FLIR") != -1) {
                      // readEXIFData(oFile, ..., ...)
                    } else if (headerAsString.indexOf("http://ns.adobe.com/xap/1.0/") != -1) {

Implementing the ProcessFLIR function from here:

https://github.com/exiftool/exiftool/blob/ef6107edcf2c47e5190754540e15ea27c020233e/lib/Image/ExifTool/FLIR.pm#L1455

It's certainly doable, I don't have the programming chops unfortunately. I need a pure JS implementation as well

ericoporto commented 3 years ago

Just adding that I also need this, I lack the perl understanding to read original code.

daz commented 3 years ago

I see ExifReader extracts binary thumbnails, maybe it can get the FLIR binary too?

https://github.com/mattiasw/ExifReader