3
$\begingroup$

I was given some PhaseOne iXM-100 .IIQ photos and I need to convert them into .jpg format. The iXM-100 was used with a DJI drone, though I am unsure if it was the M300 or M600. Due to have thousands of them, I'd like the conversion to happen programmatically (Python). I've tried a couple different methods, but both have failed.

First Code Block; works, but the output image is static. Seems that when I change the image mode, it changes the static color. Some modes work and some do not.

from PIL import Image
rawData = open("D:/Downloads/P0036906.IIQ", 'rb').read()
imgSize = (640,480)
img = Image.frombytes('RGB', imgSize, rawData)
img.save("D:/Downloads/P0036906.jpg")

Second Code Block; errors out. Seems that the library cannot read an .iiq format

import rawpy
import imageio

path = "D:/Downloads/P0036906.IIQ"

with rawpy.imread(path) as raw:
    rgb = raw.postprocess()
    imageio.imwrite('D:/Downloads/P0036906.jpg', rgb)

Traceback (most recent call last):
  File "iqq_jpg.py", line 23, in <module>
    rgb = raw.postprocess()
  File "rawpy\_rawpy.pyx", line 887, in rawpy._rawpy.RawPy.postprocess
  File "rawpy\_rawpy.pyx", line 790, in rawpy._rawpy.RawPy.dcraw_process
  File "rawpy\_rawpy.pyx", line 438, in rawpy._rawpy.RawPy.ensure_unpack
  File "rawpy\_rawpy.pyx", line 432, in rawpy._rawpy.RawPy.unpack
  File "rawpy\_rawpy.pyx", line 936, in rawpy._rawpy.RawPy.handle_error
rawpy._rawpy.LibRawIOError: b'Input/output error'

Any suggestions on how to convert IIQ to JPG?

Input: enter image description here

Output RGB: enter image description here

Output CMYK: enter image description here

$\endgroup$
2
  • $\begingroup$ I can convert an IIQ image using anonymous2♦'s code, but the jpg appears to have a greenish color layer, I think because the white balance is missing. Any suggestions on how to get the image with the right colors? $\endgroup$ Commented Sep 6, 2022 at 5:02
  • $\begingroup$ I have not attempted to use anonymouse2 code yet. I don't have a ton of experience using JS. You can download a free version of Capture One's software and convert them to JPEG. Take a look at the second answer. $\endgroup$
    – Binx
    Commented Sep 6, 2022 at 14:41

3 Answers 3

3
$\begingroup$

PhaseONE now provides an SDK to decode IIQ files into TIFF files only. Once it is in TIFF format however it can be converted to JPEG. I have used this SDK to write a simply binary which performs a conversion from IIQ files to TIFF, after which bulk conversion from TIFF to JPEG is straightforward since both are now standard file formats.

Note that each IIQ file is a TIFF file where a preview image (640x480) is stored where imagery data normally lives. The actual image data from the sensor is stored as a binary string in the Exif MakerNote tag.

$\endgroup$
1
$\begingroup$

It's not python, but there is a person on the libraw forum who shares C++ code to convert IIQ to tif. I haven't actually tested out their code, but from what I understand of your needs it should work. You can probably alter the code so that the output is jpg; alternatively you can re-convert afterwards to jpg.

Full attribution: this code was written and placed on libraw forums through this Google Drive link by t.sawka on 29 June, 2021. I'm including here in case the link breaks.

// IIQ2JPG.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <filesystem>
#include <optional>
#include <libraw/libraw.h>
#include <boost/algorithm/string.hpp>

using namespace std;

using std::filesystem::path;
using std::optional;
using boost::algorithm::to_lower;

bool convert(const path& in, const path& out, optional<path> out_thumb = nullopt);


int main()
{
    path in_dir = R"(...)";
    path out_dir = R"(...)";

    using di = std::filesystem::directory_iterator;
    for (di it = di{ in_dir }; it != di{}; it++)
    {
        if (!it->is_regular_file())
        {
            continue;
        }
    
        auto p = it->path();
        if (!p.has_extension())
        {
            continue;
        }

        auto ext = p.extension().string();
        to_lower(ext);
        if (ext.find("iiq") == std::string::npos)
        {
            continue;
        }

        auto name = p.filename().replace_extension();
        auto op = out_dir / (name.string() + ".tif");
        auto otp = out_dir / (name.string() + "_thumb.pnm");

        cout << "in: " << p << "\n";
        cout << "out: " << op << "\n";
    }
    


    return 0;
}

bool convert(const path& in, const path& out, optional<path> out_thumb)
{
    LibRaw proc;
    if (proc.open_file(in.c_str()) != LIBRAW_SUCCESS)
    {
        cerr << "open_file\n";
        return false;
    }

    if (out_thumb)
    {
        if (proc.unpack_thumb() != LIBRAW_SUCCESS)
        {
            cerr << "unpack_thumb\n";
            return false;
        }

        if (proc.dcraw_thumb_writer(out_thumb->string().c_str()) != LIBRAW_SUCCESS)
        {
            cerr << "dcraw_thumb_writer\n";
            return false;
        }
    }

    if (proc.unpack() != LIBRAW_SUCCESS)
    {
        cerr << "unpack\n";
        return false;
    }

    if (proc.dcraw_process() != LIBRAW_SUCCESS)
    {
        cerr << "dcraw_process\n";
        return false;
    }


    proc.output_params_ptr()->output_tiff = 1;
    if (proc.dcraw_ppm_tiff_writer(out.string().c_str()) != LIBRAW_SUCCESS)
    {
        cerr << "dcraw_ppm_tiff_writer\n";
        return false;
    }

    proc.recycle();
}
$\endgroup$
1
  • 1
    $\begingroup$ Thank you! I'll give this a try out. $\endgroup$
    – Binx
    Commented Jul 21, 2022 at 16:12
0
$\begingroup$

What I found is IIQ is a proprietary raw format that PhaseOne built/uses. I was unable to find any python tools that could convert into jpeg. I did find a discussion on using exiftool with IIQ if anyone finds that helpful. I evntually found that I needed to download a free trial version of Capture One in order to convert.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.