| 31 | } |
| 32 | |
| 33 | bytes Gemma3::load_image_base64(const std::string& base64_string) { |
| 34 | constexpr int target_width = 896; |
| 35 | constexpr int target_height = 896; |
| 36 | |
| 37 | image_data_t decoded; |
| 38 | image_data_t resized; |
| 39 | |
| 40 | if (!image_reader_.load_image_base64(base64_string, decoded)) { |
| 41 | return bytes(); |
| 42 | } |
| 43 | |
| 44 | if (!image_reader_.resize_image(decoded, target_width, target_height, resized)) { |
| 45 | image_reader_.recycle(decoded); |
| 46 | return bytes(); |
| 47 | } |
| 48 | |
| 49 | image_reader_.recycle(decoded); |
| 50 | bytes result = std::move(resized.pixels); |
| 51 | resized.width = 0; |
| 52 | resized.height = 0; |
| 53 | return result; |
| 54 | } |
| 55 | |
| 56 | ///@brief: preprocess the image for gemma3 model |
| 57 | ///@note: 1. Reorder: 896x896x3 -> 3x896x896 |
nothing calls this directly
no test coverage detected