EyeQ Docs

Image resizing

Resize images during or after correction

The resize samples demonstrate how to scale images to specific dimensions after applying corrections. This is useful for generating thumbnails, web-optimized images, or standardized output sizes.

What these samples demonstrate

The ResizeSample (Linux/macOS) and Sample-Resize (Windows) projects show how to correct an image and then resize it to target dimensions using the SDK's built-in resize function.

Key functions

Key functions used for image resizing:

FunctionPurpose
PFC_ResizeResize image to new dimensions
PFCImageFile constructorAllocate destination buffer with target dimensions

C/C++ implementation

The following excerpts are from ResizeAndCorrect.cpp.

Allocate destination image

Before resizing, allocate a destination image buffer with your target dimensions. The PFCImageFile helper class simplifies buffer management.

// Target dimensions: 800x600 pixels
// Parameters: width, height, bytes per pixel, stride
PFCImageFile fileResized(800, 600, 3, 3 * 800);

// Populate PFCIMAGE struct for the destination
PFCIMAGE imageResized;
imageResized.width = fileResized.width;
imageResized.height = fileResized.height;
imageResized.format = im.format;  // Same format as source
imageResized.stride = fileResized.stride;
imageResized.data = fileResized.raw_image;

Perform resize

Call PFC_Resize with the corrected source image and the destination buffer.

// Resize the corrected image
int status = PFC_Resize(&im, &imageResized);

if (status == APPLY_SUCCESS) {
    // Save resized image
    char outputPath[1000];
    sprintf(outputPath, "%s.%dx%d.jpg", inputPath, imageResized.width, imageResized.height);
    fileResized.SaveImageFile(outputPath, 90, false, false);
} else {
    printf("Resize failed with code: %d\n", status);
}

Complete workflow

The typical workflow is: load → correct → resize → save.

// 1. Load image
PFCImageFile originalImageFile;
originalImageFile.LoadImageFile(inputPath, true, NULL);

// 2. Set up PFCIMAGE struct for source
PFCIMAGE im;
im.width = originalImageFile.width;
im.height = originalImageFile.height;
im.stride = originalImageFile.stride;
im.format = (PFCPIXELFORMAT)originalImageFile.pfcImageFormat();
im.data = originalImageFile.raw_image;

// 3. Apply corrections
PFCPARAM param;
PFC_SetParam(param);
PFC_AutoCorrect(&im, NULL, param, -1, NULL, false, NULL);

// 4. Resize
PFCImageFile fileResized(800, 600, 3, 3 * 800);
PFCIMAGE imageResized;
imageResized.width = fileResized.width;
imageResized.height = fileResized.height;
imageResized.format = im.format;
imageResized.stride = fileResized.stride;
imageResized.data = fileResized.raw_image;

PFC_Resize(&im, &imageResized);

// 5. Save
fileResized.SaveImageFile("output_800x600.jpg", 90, false, false);

Calculating dimensions

To maintain aspect ratio, calculate the target dimensions based on the original image.

// Resize to fit within max 1200 pixels on longest edge
int maxDimension = 1200;
int newWidth, newHeight;

if (originalImageFile.width > originalImageFile.height) {
    // Landscape
    newWidth = maxDimension;
    newHeight = (originalImageFile.height * maxDimension) / originalImageFile.width;
} else {
    // Portrait
    newHeight = maxDimension;
    newWidth = (originalImageFile.width * maxDimension) / originalImageFile.height;
}

// Ensure stride is properly aligned (multiple of 4 bytes is common)
int bytesPerPixel = 3;
int stride = ((newWidth * bytesPerPixel + 3) / 4) * 4;

PFCImageFile fileResized(newWidth, newHeight, bytesPerPixel, stride);

Source files

You can find the code snippets in the following files:

PlatformSamplePath
Linux/macOSResizeSampleLinux/ResizeSample/ResizeAndCorrect.cpp
WindowsSample-ResizeWin/Sample-Resize/Sample-Resize.cpp

The C# samples do not include a dedicated resize example. For .NET applications, you can use System.Drawing methods to resize the corrected bitmap before saving.

PFC-SDK Version 10.7.2.1269 built from 4fa849d8101945eea725a08dd0dae5101f090fa0 on 11-10-2025.

Copyright © 2026 EyeQ Imaging Inc. All rights reserved.

On this page