3. Load/export configuration#

The conversion configuration can be saved to a file, allowing for batch processing of images or the creation of template styles.

#include "P1Image.hpp"
#include <iostream>

using namespace P1::ImageSdk;

int main()
{
    try
    {
        // Save a convert configuration
        {
            ConvertConfig config_out;
            config_out.SetSharpening(1.8, 1.0, 1.0);
            config_out.SaveToFile("config.txt");
        }

        // Process image with saved configuration
        {
            // 1. Load IIQ image
            RawImage im("Sample.IIQ");

            // 2. Load convert config
            ConvertConfig config = ConvertConfig::LoadFromFile("config.txt");

            // 3. Convert
            BitmapImage bmp = im.Convert(config);

            // 4. Export to JPEG
            JpegConfig jpegConfig;
            JpegWriter("out.jpeg", bmp, im, jpegConfig);
        }

        return 0;
    }
    catch (const std::exception& e)
    {
        std::cerr << e.what();
        return -1;
    }
} 
using P1.ImageSdk;

// Save a convert configuration
{
    ConvertConfig config_out = new();
    config_out.SetSharpening(1.8f, 1.0f, 1.0f);
    config_out.SaveToFile("config.txt");
}

// Process image with saved configuration
{
    // 1. Load IIQ image
    RawImage im = new("Sample.IIQ");

    // 2. Load convert configuration
    ConvertConfig config = ConvertConfig.LoadFromFile("config.txt");

    // 3. Convert
    IBitmapImage bmp = im.Convert(config);

    // 4. Export to JPEG
    im.WriteAsJpeg("out.jpeg", bmp, new JpegConfig());
}

Below is an example of the configuration file. Notice the "sharpeningEnabled": true and other sharpening parameters.

{
    "aerialDehazingAdaptivity": 0,
    "aerialDehazingAmount": 0.0,
    "aerialDehazingEnabled": false,
    "autoExposureEnabled": false,
    "blackLevelBlue": 0.0,
    "blackLevelEnabled": false,
    "blackLevelGreen": 0.0,
    "blackLevelRed": 0.0,
    "blackLevelTargetBlue": 0.0,
    "blackLevelTargetEnabled": false,
    "blackLevelTargetGreen": 0.0,
    "blackLevelTargetRed": 0.0,
    "blueCurve": [],
    "brightness": 0.0,
    "brightnessEnabled": false,
    "canvasClip": 3,
    "chromaticAberrationCorrectionEnabled": false,
    "clarityEnabled": false,
    "clarityFactor": 0.0,
    "clarityMethod": 0,
    "clipWarningCount": -1,
    "clipWarningMaskEnabled": false,
    "colorAntiAliasingEnabled": false,
    "colorBalanceHighlightBlue": 1.0,
    "colorBalanceHighlightEnabled": false,
    "colorBalanceHighlightGreen": 1.0,
    "colorBalanceHighlightRed": 1.0,
    "colorBalanceMidtoneBlue": 1.0,
    "colorBalanceMidtoneEnabled": false,
    "colorBalanceMidtoneGreen": 1.0,
    "colorBalanceMidtoneRed": 1.0,
    "colorBalanceShadowBlue": 1.0,
    "colorBalanceShadowEnabled": false,
    "colorBalanceShadowGreen": 1.0,
    "colorBalanceShadowRed": 1.0,
    "colorNoiseReductionAmount": 0.0,
    "contrast": 0.0,
    "contrastEnabled": false,
    "crop": false,
    "dstHeight": 0,
    "dstWidth": 0,
    "dualExposureOutput": 0,
    "enableLinearPath": false,
    "exposure": 0.0,
    "exposureEnabled": false,
    "exposureWarningMaskEnabled": false,
    "exposureWarningThresholdOver": 1.0,
    "exposureWarningThresholdUnder": 0.0,
    "filmCurveFileName": "",
    "gain": 1.0,
    "gainEnabled": false,
    "geometricCompensationPressure": 0.0,
    "geometricCorrection": {
        "b1": 0.0,
        "b2": 0.0,
        "c": 0.0,
        "h": -1.0,
        "k1": 0.0,
        "k2": 0.0,
        "k3": 0.0,
        "orientation": 0,
        "p1": 0.0,
        "p2": 0.0,
        "xp": 0.0,
        "yp": 0.0
    },
    "geometricCorrectionCompensationEnabled": false,
    "geometricCorrectionEnabled": false,
    "greenCurve": [],
    "haloSuppressionAmount": 0.0,
    "height": 0,
    "highlightRecovery": 0.0,
    "highlightRecoveryEnabled": false,
    "iccProfileFileName": "",
    "lightFalloffCorrectionEnabled": false,
    "linearPathType": 0,
    "lumaCurve": [],
    "luminanceNoiseReductionAmount": 0.0,
    "midtoneLevelBlue": 0.0,
    "midtoneLevelEnabled": false,
    "midtoneLevelGreen": 0.0,
    "midtoneLevelRed": 0.0,
    "modelVersion": 1,
    "noiseReductionEnabled": false,
    "noiseReductionSinglePixelEnabled": false,
    "orientation": -2,
    "outputColorSpace": 1,
    "outputFormat": {
        "alignment": true,
        "bitDepth": 1,
        "channel0": 1,
        "channel1": 2,
        "channel2": 3,
        "channel3": 0,
        "channel4": 0,
        "pixelLayout": 1,
        "typeCode": 1
    },
    "polynomialTransformNormalized": false,
    "polynomialTransformStage": 0,
    "polynomial_ax": 0.0,
    "polynomial_ay": 0.0,
    "polynomial_bx": 0.0,
    "polynomial_by": 0.0,
    "polynomial_cx": 1.0,
    "polynomial_cy": 1.0,
    "redCurve": [],
    "rgbCurve": [],
    "saturation": 0.0,
    "saturationEnabled": false,
    "scale": false,
    "scaleFactor": 0.0,
    "shadowRecovery": 0.0,
    "shadowRecoveryEnabled": false,
    "sharpeningAmount": 1.7999999523162842,
    "sharpeningEnabled": true,
    "sharpeningRadius": 1.0,
    "sharpeningThreshold": 1.0,
    "whiteBalanceGainBlue": 0.0,
    "whiteBalanceGainEnabled": false,
    "whiteBalanceGainGreen": 0.0,
    "whiteBalanceGainRed": 0.0,
    "whiteBalanceMode": 1,
    "whiteLevelBlue": 1.0,
    "whiteLevelEnabled": false,
    "whiteLevelGreen": 1.0,
    "whiteLevelRed": 1.0,
    "whiteLevelTargetBlue": 1.0,
    "whiteLevelTargetEnabled": false,
    "whiteLevelTargetGreen": 1.0,
    "whiteLevelTargetRed": 1.0,
    "width": 0,
    "x": 0,
    "y": 0
}