{
 "id": 69787,
 "slug": "fixing-nodejs-image-processing-memory-problems-with-external-tools",
 "url": "https://agents.willem.com/en/snippets/fixing-nodejs-image-processing-memory-problems-with-external-tools/",
 "language": "en",
 "title": "Fixing NodeJS image processing memory problems with external tools",
 "subtitle": "Extract the bottleneck instead of feeding it more RAM.",
 "summary": "Rotating photos inside a single NodeJS process with the lwip module turned my backend into a memory hog as megapixels grew. I fixed it by extracting the work to an external tool that NodeJS calls and awaits.",
 "topics": [
  "AI",
  "cloud",
  "data",
  "programming",
  "server",
  "work"
 ],
 "date": "2023-05-03",
 "published": "2023-05-03T00:00:00+02:00",
 "created": "2026-08-30T07:13:30.190000+02:00",
 "updated": "2026-08-30T07:16:54.622000+02:00",
 "full_article_url": "https://willem.com/en/2023-05-03_using-ai-to-generate-code/",
 "author": {
  "name": "Willem L. Middelkoop",
  "url": "https://willem.com"
 },
 "note": "A short distillation of a longer willem.com post. Not currently published on willem.com itself.",
 "answers_question": "Why does image processing make a NodeJS backend run out of memory?",
 "text": "My content management backend originally rotated uploaded images in-process, using NodeJS with the lwip module (LightWeight ImageProcessor). That worked fine in most situations, but as images grew in size the memory requirements increased significantly. Doing everything in a single NodeJS process meant the entire backend suffered when pushed to its limits processing thousands of photos.\nThe common strategy for a bottleneck is to extract it from the main program. Instead of processing images inside NodeJS, I call an external auto rotation script built on proven Debian GNU/Linux tools, exiftool and ImageMagick, and wait for its result. Because NodeJS waits asynchronously for the callback, the process stays available for other requests in the meantime.\nThe rewrite was part of cutting my cloud costs: less computer power for the same results.",
 "markdown_url": "https://agents.willem.com/en/snippets/fixing-nodejs-image-processing-memory-problems-with-external-tools/snippet.md"
}