{"record":{"id":"6e97b9ddd4d91e41","repo":"jackwener/OpenCLI","slug":"instagram-private-publish-failed-to-normalize-as","errorCode":null,"errorMessage":"Instagram private publish failed to normalize ${asset.fileName}","messagePattern":"Instagram private publish failed to normalize (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/_shared/private-publish.js","lineNumber":359,"sourceCode":"    const outputPath = buildPrivateNormalizedImagePath(filePath);\n    const result = spawnSync('sips', [\n        '--padToHeightWidth',\n        String(normalizedDimensions.height),\n        String(normalizedDimensions.width),\n        '--padColor',\n        INSTAGRAM_PRIVATE_PAD_COLOR,\n        filePath,\n        '--out',\n        outputPath,\n    ], {\n        encoding: 'utf8',\n    });\n    if (result.error || result.status !== 0 || !fs.existsSync(outputPath)) {\n        const detail = [result.error?.message, result.stderr, result.stdout]\n            .map((value) => String(value || '').trim())\n            .filter(Boolean)\n            .join(' ');\n        throw new CommandExecutionError(`Instagram private publish failed to normalize ${asset.fileName}`, detail || 'sips padToHeightWidth failed');\n    }\n    return {\n        ...readImageAsset(outputPath),\n        cleanupPath: outputPath,\n    };\n}\nexport function prepareImageAssetForPrivateStoryUpload(filePath) {\n    const asset = readImageAsset(filePath);\n    const normalizedDimensions = getInstagramStoryNormalizedDimensions(asset.width, asset.height);\n    if (!normalizedDimensions) {\n        return asset;\n    }\n    if (process.platform !== 'darwin') {\n        throw new CommandExecutionError(`Instagram private story publish does not support auto-normalizing ${asset.fileName} on ${process.platform}`, `Use images within ${INSTAGRAM_MIN_STORY_ASPECT_RATIO.toFixed(2)}-${INSTAGRAM_MAX_STORY_ASPECT_RATIO.toFixed(2)} aspect ratio, or use the UI route`);\n    }\n    const outputPath = buildPrivateNormalizedImagePath(filePath);\n    const result = spawnSync('sips', [\n        '--padToHeightWidth',","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/_shared/private-publish.js#L341-L377","documentation":"After spawning `sips --padToHeightWidth` on macOS to pad a feed image, the CLI checks for spawn errors, non-zero exit status, and existence of the output file; any of these failing raises this error with the collected stderr/stdout detail.","triggerScenarios":"prepareImageAssetForPrivateUpload runs sips and result.error is set, result.status !== 0, or the normalized output file does not exist afterwards.","commonSituations":"sips missing or broken on the macOS host, unreadable/corrupt source image, disk full or permission-denied output path, sips cannot handle very large images.","solutions":["Read the error detail (stderr/stdout appended as the second message) for the specific sips failure","Verify `sips --padToHeightWidth 1350 1080 input.png --out output.png` works manually","Check disk space and write permissions in the temp/output directory","Normalize the image beforehand with another tool and skip auto-normalization"],"exampleFix":"// before\nawait publish({ media: 'broken.png' });\n// after\n// fix the image first:\n// $ magick broken.png -background white -gravity center -extent 1080x1350 fixed.png\nawait publish({ media: 'fixed.png' });","handlingStrategy":"fallback","validationCode":"// verify sips works before relying on auto-normalization\nconst probe = spawnSync('sips', ['--version']);\nif (probe.error || probe.status !== 0) throw new Error('sips unavailable');","typeGuard":null,"tryCatchPattern":"try {\n  await publish(cfg);\n} catch (e) {\n  if (/failed to normalize/.test(e.message)) {\n    cfg.media = normalizeWithImageMagick(cfg.media); // fallback tool, retry\n  } else throw e;\n}","preventionTips":["Confirm `sips` runs on the macOS host before batch publishing","Check disk space and temp-directory write permissions","Validate source images are decodable (open or `sips -g pixelWidth` them)","Keep ImageMagick available as a fallback normalizer"],"tags":["instagram","image","macos","sips","process"],"backgroundTag":"image-normalization-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}