Perfectly Clear SDK Documentation  10.7.1.1191
PFCImageFile Class Reference

PFCImageFile Class to encapsulate file handling. More...

#include <PFCImageFile.h>

Public Types

enum  PFC_FILETYPE
 Type for compressing/decomrpessing a buffer. More...
 

Public Member Functions

 PFCImageFile ()
 Constructs empty PFCImageFile, to be filled with LoadImageFile() More...
 
 PFCImageFile (int width, int height, const PFCImageFile &model)
 Constructs PFCImageFile with allocation for image of given size and format. More...
 
 PFCImageFile (int width, int height, int bytes_per_pixel, int stride)
 Constructs PFCImageFile with allocation for image of given size. More...
 
PFC_FILE_LOAD_STATUS LoadImageFile (const char *filename, bool bConvertToSRGB, const char *iccFolderPath)
 Load JPEG, PNG or RAW from file on disk. More...
 
PFC_FILE_LOAD_STATUS LoadImageFile (const char *filename, PFC_FILETYPE type, bool bConvertToSRGB, const char *iccFolderPath)
 Load JPEG, PNG or RAW from file on disk. More...
 
PFC_FILE_LOAD_STATUS ExpandImageBuffer (char *data, long size, PFC_FILETYPE type, bool bConvertToSRGB, const char *iccFolderPath)
 Expands the image file data provided in a buffer. More...
 
int CompressImageBuffer (unsigned char **destination, PFC_FILETYPE type, int quality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata)
 Compresses the image to the given type and writes compressed data to destination buffer. More...
 
bool SaveImageFile (const char *filename, int quality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata)
 Write image data to file - specify file type with filename extension. More...
 
bool SaveImageFile (const char *filename, PFC_FILETYPE type, int quality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata)
 Write image data to file - specify file type with PFC_FILETYPE. More...
 
bool SetOutputIccProfile (const char *filename)
 loads the desired ICC profile from the given path for the output image More...
 
int exifOrientation ()
 
int iISO ()
 
const char * cameraModel ()
 
const char * exifSoftware ()
 

Data Fields

unsigned char * raw_image
 
int width
 
int height
 
int bytes_per_pixel
 
int stride
 
bool sourceSRGB
 
PFC_FLASH_STATUS flashStatus
 flash status from the exif section if present
 
bool expandThumbnailImage
 expand the thumbnailImage to get thumbnail dimensions and check validity.
 
bool hasSourceThumbnail
 set to true after loading an image and it has a valid jpeg thumbnail
 
int sourceThumbnailWidth
 width of the loaded image thumbnail
 
int sourceThumbnailHeight
 height of the loaded image thumnail
 
void * outputThumbnailBuffer
 sets the jpeg compressed image content for the thumbnail to embed when saving the image. The buffer is not copied or checked and will be read at saving time. The class does not take ownership of the buffer. If set the original thumbnail data from the image will be discarded and will use the passed buffer data, the original thumbnail data will be embeded.
 
int outputThumbnailBufferSize
 size of the compressed image content
 

Detailed Description

PFCImageFile Class to encapsulate file handling.

This is an optional class you can use to read and write JPEG, PNG and WebP files, manage EXIF metadata and perform color space conversion (to / from sRGB). At this time, only RGB formatted images are supported. Basic usage:

PFCImageFile originalImageFile;
bool bConvertToSRGB = true;
const char* pathToSupportFilesFolder = NULL;
PFC_FILE_LOAD_STATUS st = originalImageFile.LoadImageFile(inname, bConvertToSRGB, pathToSupportFilesFolder);

Then, load PFCIMAGE with this data:

im.width = originalImageFile.width;
im.height = originalImageFile.height;
im.stride = originalImageFile.stride;
im.data = originalImageFile.raw_image;

Correct the image:

Then write image back to disk:

bool bConvertToOriginalColorSpace = true;
bool bPreserveOriginalMetadata = true;
originalImageFile.SaveImageFile(outname, 90, bConvertToOriginalColorSpace, bPreserveOriginalMetadata);

Definition at line 71 of file PFCImageFile.h.

Member Function Documentation

◆ cameraModel()

const char* cameraModel ( )

Holds the contents of the EXIF ISO tag

Returns
Contents of EXIF ISO tag

◆ CompressImageBuffer()

int CompressImageBuffer ( unsigned char **  destination,
PFC_FILETYPE  type,
int  quality,
bool  bConvertToOriginalColorSpace,
bool  bEmbedOriginalMetadata 
)

Compresses the image to the given type and writes compressed data to destination buffer.

Parameters
destination[out] - pointer to the compressed buffer. Create this buffer through malloc, and disposed through free().
type[in] - filetype of the file to create.
quality[in] - Sets the output quality for the compression. Ignored for PNGs. We recomend 92.
bConvertToOriginalColorSpace[in] - Convert the file back to the input colorspace. If false, the resutling file will be in sRGB. Ignored if the user has called SetOutputIccProfile.
bEmbedOriginalMetadata[in] - Set to true to copy EXIF data from original to output. This can be critical for images with EXIF rotation flag.
Returns
size of destination buffer

◆ exifOrientation()

int exifOrientation ( )

Holds the contents of the EXIF Software tag

Returns
Contents of EXIF Software tag

◆ exifSoftware()

const char* exifSoftware ( )

Holds the contents of the EXIF Camera Model tag

Returns
Contents of EXIF Camera Model tag

◆ ExpandImageBuffer()

PFC_FILE_LOAD_STATUS ExpandImageBuffer ( char *  data,
long  size,
PFC_FILETYPE  type,
bool  bConvertToSRGB,
const char *  iccFolderPath 
)

Expands the image file data provided in a buffer.

Parameters
data[in] - pointer to compressed image data in a buffer. Its contets are examined but PFCImageFile does not take ownership.
size[in] - size of the data buffer.
type[in] - filetype of the buffer contents.
bConvertToSRGB[in] - Bool to control conversion to sRGB, usually should be set to true.
iccFolderPath[in] - Some JPEGs may be in AdobeRGB without AdobeRGB being actually embedded. Path to folder containing AdobeRGB1998.icc should be passed here
Returns
Status of the decomrpession

◆ iISO()

int iISO ( )

Holds the contents of the EXIF Orientation tag

Returns
Contents of EXIF Orientation tag

◆ LoadImageFile() [1/2]

PFC_FILE_LOAD_STATUS LoadImageFile ( const char *  filename,
bool  bConvertToSRGB,
const char *  iccFolderPath 
)

Load JPEG, PNG or RAW from file on disk.

Parameters
filename[in] - path to file to load
bConvertToSRGB[in] - Bool to control conversion to sRGB, usually should be set to true
iccFolderPath[in] - Some JPEGs may be in AdobeRGB without AdobeRGB being actually embedded. Path to folder containing AdobeRGB1998.icc should be passed here
Returns
Returns enum PFC_FILE_LOAD_STATUS showing file read status

◆ LoadImageFile() [2/2]

PFC_FILE_LOAD_STATUS LoadImageFile ( const char *  filename,
PFC_FILETYPE  type,
bool  bConvertToSRGB,
const char *  iccFolderPath 
)

Load JPEG, PNG or RAW from file on disk.

Parameters
filename[in] - path to file to load
type[in] - filetype of the file to create.
bConvertToSRGB[in] - Bool to control conversion to sRGB, usually should be set to true
iccFolderPath[in] - Some JPEGs may be in AdobeRGB without AdobeRGB being actually embedded. Path to folder containing AdobeRGB1998.icc should be passed here
Returns
Returns enum PFC_FILE_LOAD_STATUS showing file read status

◆ SaveImageFile() [1/2]

bool SaveImageFile ( const char *  filename,
int  quality,
bool  bConvertToOriginalColorSpace,
bool  bEmbedOriginalMetadata 
)

Write image data to file - specify file type with filename extension.

Parameters
filename[in] - filename to write to. The filename determines the type of file created, and must end in .jpg or .png
quality[in] - Sets the output quality for the compression. Ignored for PNGs. We recomend 92.
bConvertToOriginalColorSpace[in] - Convert the file back to the input colorspace. If false, the resutling file will be in sRGB. Ignored if the user has called SetOutputIccProfile.
bEmbedOriginalMetadata[in] - Set to true to copy EXIF data from original to output. This can be critical for images with EXIF rotation flag.
Returns
True if image was successfully saved to disk

◆ SaveImageFile() [2/2]

bool SaveImageFile ( const char *  filename,
PFC_FILETYPE  type,
int  quality,
bool  bConvertToOriginalColorSpace,
bool  bEmbedOriginalMetadata 
)

Write image data to file - specify file type with PFC_FILETYPE.

Parameters
filename[in] - filename to write to.
type[in] - filetype of the file to create.
quality[in] - Sets the output quality for the compression. Ignored for PNGs. We recomend 92.
bConvertToOriginalColorSpace[in] - Convert the file back to the input colorspace. If false, the resutling file will be in sRGB. Ignored if the user has called SetOutputIccProfile.
bEmbedOriginalMetadata[in] - Set to true to copy EXIF data from original to output. This can be critical for images with EXIF rotation flag.
Returns
True if image was successfully saved to disk

◆ SetOutputIccProfile()

bool SetOutputIccProfile ( const char *  filename)

loads the desired ICC profile from the given path for the output image

Parameters
filename[in] - filename to load.
Returns
True if the ICC file was properly open, parsed and accepted for file saving

Member Enumeration Documentation

◆ PFC_FILETYPE

Type for compressing/decomrpessing a buffer.

Enumerator
PFC_JPEG 

JPEG.

PFC_PNG 

PNG.

PFC_WEBP 

WEPB.

Definition at line 76 of file PFCImageFile.h.

Constructor & Destructor Documentation

◆ PFCImageFile() [1/3]

Constructs empty PFCImageFile, to be filled with LoadImageFile()

◆ PFCImageFile() [2/3]

PFCImageFile ( int  width,
int  height,
const PFCImageFile model 
)

Constructs PFCImageFile with allocation for image of given size and format.

Parameters
width[in] - width
height[in] - height
model[in] - already loaded PFCImageFile, new image will inherit pixel format and original metadata from the model

◆ PFCImageFile() [3/3]

PFCImageFile ( int  width,
int  height,
int  bytes_per_pixel,
int  stride 
)

Constructs PFCImageFile with allocation for image of given size.

Parameters
width[in] - width
height[in] - height
bytes_per_pixel[in] - bytes per pixel
stride[in] - stride

Field Documentation

◆ bytes_per_pixel

int bytes_per_pixel

bytes per pixel

Definition at line 195 of file PFCImageFile.h.

◆ height

int height

image height

Definition at line 193 of file PFCImageFile.h.

◆ raw_image

unsigned char* raw_image

image data. Can be loaded directly into PFCIMAGE

im.data = myPFCImagFile.raw_image

Definition at line 189 of file PFCImageFile.h.

◆ sourceSRGB

bool sourceSRGB

Set to true if the input image is tagged as being in sRGB. All images with embedded color profiles will be false, regardless of the profile's contents.

Definition at line 199 of file PFCImageFile.h.

◆ stride

int stride

image stride

Definition at line 197 of file PFCImageFile.h.

◆ width

int width

image width

Definition at line 191 of file PFCImageFile.h.


The documentation for this class was generated from the following file:
PFCIMAGE::height
int height
Pixel height of image.
Definition: PerfectlyClearPro.h:258
PRESET_IAUTO_PEOPLE
@ PRESET_IAUTO_PEOPLE
New default preset for 2023 - same corrections as iAuto People from the Universal AI Preset Selection...
Definition: PerfectlyClearPro.h:191
PFC_FILE_LOAD_STATUS
PFC_FILE_LOAD_STATUS
Return status values.
Definition: PFCImageFile.h:22
PFCIMAGE::stride
int stride
Byte width of each scanline.
Definition: PerfectlyClearPro.h:259
PFCImageFile::raw_image
unsigned char * raw_image
Definition: PFCImageFile.h:189
PFCIMAGE::width
int width
Pixel width of image.
Definition: PerfectlyClearPro.h:257
PFCIMAGE::data
unsigned char * data
Pointer pointing to the first byte of image data buffer.
Definition: PerfectlyClearPro.h:261
PFC_PixelFormat24bppBGR
@ PFC_PixelFormat24bppBGR
Definition: PerfectlyClearPro.h:65
PFCIMAGE
Struct defining an image to be used in PFC library.
Definition: PerfectlyClearPro.h:256
PFC_AutoCorrect
int PFC_AutoCorrect(PFCIMAGE *pImage, PFCIMAGE *pImageds, PFCPARAM &param, int iISO=-1, char *pCameraModel=NULL, BOOL bFastFAE=FALSE, PFC_PROGRESS progfn=NULL, PFCENGINE *pEngineAI=NULL, BOOL bUseAutoSDPreset=FALSE)
Single function to perform Perfectly Clear correction.
PFCImageFile::stride
int stride
Definition: PFCImageFile.h:197
PFCIMAGE::format
PFCPIXELFORMAT format
Defines byte order of input buffer.
Definition: PerfectlyClearPro.h:260
PFCImageFile::height
int height
Definition: PFCImageFile.h:193
PFCImageFile::width
int width
Definition: PFCImageFile.h:191
PFCImageFile::SaveImageFile
bool SaveImageFile(const char *filename, int quality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata)
Write image data to file - specify file type with filename extension.
PFCImageFile
PFCImageFile Class to encapsulate file handling.
Definition: PFCImageFile.h:72
PFCImageFile::LoadImageFile
PFC_FILE_LOAD_STATUS LoadImageFile(const char *filename, bool bConvertToSRGB, const char *iccFolderPath)
Load JPEG, PNG or RAW from file on disk.