JPEG I/O¶
-
inline Image<RGB> huira::read_image_jpeg(const fs::path &filepath)¶
Reads a JPEG file and returns linear RGB data.
Convenience overload that reads the file into memory and forwards to the buffer-based implementation.
- Parameters:
filepath – Path to the JPEG file to read
- Returns:
The linear RGB image.
-
inline Image<RGB> huira::read_image_jpeg(const unsigned char *data, std::size_t size)¶
Reads a JPEG from an in-memory buffer and returns linear RGB data.
Converts from sRGB to linear light. Grayscale JPEGs are promoted to RGB by TurboJPEG during decompression.
- Parameters:
data – Pointer to the JPEG data in memory
size – Size of the data in bytes
- Returns:
The linear RGB image.
-
inline Image<float> huira::read_image_jpeg_mono(const fs::path &filepath)¶
Reads a JPEG file and returns linear mono data.
Convenience overload that reads the file into memory and forwards to the buffer-based implementation.
- Parameters:
filepath – Path to the JPEG file to read
- Returns:
The linear mono image.
-
inline Image<float> huira::read_image_jpeg_mono(const unsigned char *data, std::size_t size)¶
Reads a JPEG from an in-memory buffer and returns linear mono data.
Converts from sRGB to linear light, then averages the RGB channels.
- Parameters:
data – Pointer to the JPEG data in memory
size – Size of the data in bytes
- Returns:
The linear mono image.
-
inline void huira::write_image_jpeg(const fs::path &filepath, const Image<float> &image, int quality)¶
Writes a linear mono image to a JPEG file (sRGB encoded).
Convenience overload that promotes a mono image to RGB before writing.
- Parameters:
filepath – Path where the JPEG file will be written
image – The linear mono image to write
quality – JPEG compression quality (1-100, default 95)
-
inline void huira::write_image_jpeg(const fs::path &filepath, const Image<RGB> &image, int quality)¶
Writes a linear RGB image to a JPEG file (sRGB encoded).
Converts the image from linear color space to sRGB and compresses it using TurboJPEG. The function automatically creates necessary directories.
- Parameters:
filepath – Path where the JPEG file will be written
image – The linear RGB image to write
quality – JPEG compression quality (1-100, default 95)
- Throws:
std::runtime_error – if the file cannot be created, the image is empty, quality is invalid, or if any error occurs during writing