068557b06c
- Added read_image_as_data_uri() function to base64_util for reading, validating, and base64-encoding image files - Added -i CLI flag to accept image file paths (multiple allowed) - Added -I debug flag for testing image file reading - Image files are validated at startup with clear error messages for missing or unreadable files - Updated help text and README.md documentation - Added test_image_flag.sh with tests for PNG, JPEG, GIF formats, error cases, and multiple -i flags
20 lines
698 B
C++
20 lines
698 B
C++
#pragma once
|
|
#include <string>
|
|
#include <expected>
|
|
#include <vector>
|
|
|
|
// Base64 encode binary data to base64 string
|
|
std::string base64_encode(const std::string& input);
|
|
|
|
// Base64 decode base64 string to binary data
|
|
std::expected<std::string, std::string> base64_decode(const std::string& input);
|
|
|
|
// Get MIME type from file extension
|
|
std::string get_mime_type_from_extension(const std::string& extension);
|
|
|
|
// Generate data URI prefix with base64 data
|
|
std::string generate_data_uri(const std::string& extension, const std::string& base64_data);
|
|
|
|
// Read an image file and return it as a base64 data URI
|
|
std::expected<std::string, std::string> read_image_as_data_uri(const std::string& file_path);
|