#include "image_pipeline.hpp" #include #include #include #include #include int main(int argc, char** argv) { if (argc != 3) return 2; try { std::ifstream input(argv[1], std::ios::binary); if (!input) return 1; const std::vector bytes((std::istreambuf_iterator(input)), {}); const auto variants = make_variants(bytes); std::filesystem::create_directories(argv[2]); nlohmann::json manifest; for (const auto& v : variants) { const auto path = std::filesystem::path(argv[2]) / (v.name + (v.content_type == "image/webp" ? ".webp" : ".jpg")); std::ofstream out(path, std::ios::binary); out.write(v.image.bytes.data(), v.image.bytes.size()); if (!out) return 1; manifest[v.name] = {{"width", v.image.width}, {"height", v.image.height}, {"size_bytes", v.image.bytes.size()}}; } std::cout << manifest.dump() << '\n'; return 0; } catch (const std::exception& e) { std::cerr << e.what() << '\n'; return 1; } }