{"record":{"id":"fd0a9f6779d4f2a0","repo":"mudler/LocalAI","slug":"failed-to-load-image-from-s-n","errorCode":null,"errorMessage":"Failed to load image from '%s'\\n","messagePattern":"Failed to load image from '(.+?)'\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/go/stablediffusion-ggml/cpp/gosd.cpp","lineNumber":1123,"sourceCode":"void sd_vid_gen_params_set_seed(sd_vid_gen_params_t *params, int64_t seed) {\n    params->seed = seed;\n}\n\nvoid sd_vid_gen_params_set_video_frames(sd_vid_gen_params_t *params, int n) {\n    params->video_frames = n;\n}\n\n// Load an image file into an sd_image_t, resizing to target dims if needed.\n// Returns a heap-allocated buffer the caller must free (or nullptr on failure).\nstatic uint8_t* load_and_resize_image(const char* path, int target_width, int target_height, sd_image_t* out) {\n    if (!path || strlen(path) == 0) {\n        *out = {0, 0, 0, nullptr};\n        return nullptr;\n    }\n    int c = 0, img_w = 0, img_h = 0;\n    uint8_t* buf = stbi_load(path, &img_w, &img_h, &c, 3);\n    if (!buf) {\n        fprintf(stderr, \"Failed to load image from '%s'\\n\", path);\n        *out = {0, 0, 0, nullptr};\n        return nullptr;\n    }\n    if (img_w != target_width || img_h != target_height) {\n        fprintf(stderr, \"Resizing image from %dx%d to %dx%d\\n\", img_w, img_h, target_width, target_height);\n        uint8_t* resized = (uint8_t*)malloc((size_t)target_width * target_height * 3);\n        if (!resized) { free(buf); *out = {0, 0, 0, nullptr}; return nullptr; }\n        stbir_resize(buf, img_w, img_h, 0,\n                     resized, target_width, target_height, 0, STBIR_TYPE_UINT8,\n                     3, STBIR_ALPHA_CHANNEL_NONE, 0,\n                     STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP,\n                     STBIR_FILTER_BOX, STBIR_FILTER_BOX,\n                     STBIR_COLORSPACE_SRGB, nullptr);\n        free(buf);\n        buf = resized;\n    }\n    *out = {(uint32_t)target_width, (uint32_t)target_height, 3, buf};\n    return buf;","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/stablediffusion-ggml/cpp/gosd.cpp#L1105-L1141","documentation":"An input image could not be decoded from the given path. Guard: verify the file exists and is a supported image format before use; return an invalid-argument error naming the path.","triggerScenarios":"Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:1123 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the image path is correct and the file exists.","Confirm the file is a valid image in a supported format.","Check file permissions on the input image."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}