{
  "schemaVersion": 1,
  "slug": "sharp-vs-jimp-image-resize",
  "tool": {
    "name": "sharp",
    "repo": "lovell/sharp",
    "version": "0.35.5"
  },
  "environment": {
    "arch": "aarch64",
    "cpu": "Neoverse-N1 x2, CPUQuota 150%",
    "memMB": 2048,
    "os": "Ubuntu 24.04.4 LTS",
    "runtime": "Node.js 24.21.0"
  },
  "method": {
    "hypothesis": "README 주장: libvips 기반인 sharp로 이미지를 리사이즈하면 ImageMagick이나 GraphicsMagick의 가장 빠른 설정보다 처리 속도가 약 4~5배 빠르다고 설명한다. 이 환경에서 확인: 단일 노드 샌드박스에서 동일한 PNG 이미지 버퍼를 축소 리사이즈할 때 sharp가 순수 자바스크립트 이미지 처리 라이브러리인 jimp보다 짧은 총 처리 시간을 기록하는지 확인한다.",
    "conditions": [
      "네이티브 CLI 도구인 ImageMagick 대신 Node.js 환경의 순수 자바스크립트 라이브러리 jimp를 비교 기준으로 사용",
      "가로 1200열, 세로 1200행 크기의 결정적 RGB 패턴 PNG 이미지 파일 10개를 입력으로 생성",
      "각 이미지를 가로 300열, 세로 300행 크기의 PNG 버퍼로 축소 리사이즈하고 인코딩까지 완료하는 시간을 측정",
      "speedup이 1보다 크면 같은 방향, 1 이하이면 다른 방향으로 판정"
    ],
    "repeats": 5
  },
  "script": "import { performance } from 'node:perf_hooks';\nimport sharp from 'sharp';\nimport * as jimpMod from 'jimp';\n\nsharp.cache(false);\n\nconst Jimp = jimpMod.Jimp || jimpMod.default || jimpMod;\n\nasync function resizeWithJimp(buf, width, height) {\n  if (typeof Jimp.fromBuffer === 'function') {\n    const img = await Jimp.fromBuffer(buf);\n    img.resize({ w: width, h: height });\n    return await img.getBuffer('image/png');\n  }\n  const img = await Jimp.read(buf);\n  img.resize(width, height);\n  return await img.getBufferAsync('image/png');\n}\n\nasync function resizeWithSharp(buf, width, height) {\n  return await sharp(buf).resize({ width, height }).png().toBuffer();\n}\n\nconst SRC_W = 1200;\nconst SRC_H = 1200;\nconst DST_W = 300;\nconst DST_H = 300;\nconst COUNT = 10;\n\nconst inputs = [];\nfor (let i = 0; i < COUNT; i++) {\n  const raw = Buffer.allocUnsafe(SRC_W * SRC_H * 3);\n  for (let y = 0; y < SRC_H; y++) {\n    for (let x = 0; x < SRC_W; x++) {\n      const idx = (y * SRC_W + x) * 3;\n      raw[idx] = (x + i * 17) & 255;\n      raw[idx + 1] = (y + i * 31) & 255;\n      raw[idx + 2] = ((x ^ y) + i * 13) & 255;\n    }\n  }\n  const pngBuf = await sharp(raw, { raw: { width: SRC_W, height: SRC_H, channels: 3 } }).png().toBuffer();\n  inputs.push(pngBuf);\n}\n\nawait resizeWithSharp(inputs[0], DST_W, DST_H);\nawait resizeWithJimp(inputs[0], DST_W, DST_H);\n\nlet sharpBytes = 0;\nconst t0 = performance.now();\nfor (let i = 0; i < COUNT; i++) {\n  const out = await resizeWithSharp(inputs[i], DST_W, DST_H);\n  sharpBytes += out.byteLength;\n}\nconst sharpMs = Number((performance.now() - t0).toFixed(2));\n\nlet jimpBytes = 0;\nconst t1 = performance.now();\nfor (let i = 0; i < COUNT; i++) {\n  const out = await resizeWithJimp(inputs[i], DST_W, DST_H);\n  jimpBytes += out.byteLength;\n}\nconst jimpMs = Number((performance.now() - t1).toFixed(2));\n\nconsole.log(JSON.stringify({ sharpMs, jimpMs, sharpBytes, jimpBytes }));",
  "scriptSha256": "a6bfe3015be8d83aecb8542a28a85861099382fddb0713aa174222fab7d607cf",
  "runs": [
    {
      "run": 1,
      "sharpMs": 170.64,
      "jimpMs": 974.4,
      "sharpBytes": 587329,
      "jimpBytes": 689071,
      "wallMs": 2171.459
    },
    {
      "run": 2,
      "sharpMs": 168.41,
      "jimpMs": 951.16,
      "sharpBytes": 587329,
      "jimpBytes": 689071,
      "wallMs": 2124.96
    },
    {
      "run": 3,
      "sharpMs": 167.14,
      "jimpMs": 993.01,
      "sharpBytes": 587329,
      "jimpBytes": 689071,
      "wallMs": 2121.469
    },
    {
      "run": 4,
      "sharpMs": 170.43,
      "jimpMs": 1003.77,
      "sharpBytes": 587329,
      "jimpBytes": 689071,
      "wallMs": 2222.029
    },
    {
      "run": 5,
      "sharpMs": 173.39,
      "jimpMs": 995.3,
      "sharpBytes": 587329,
      "jimpBytes": 689071,
      "wallMs": 2022.078
    }
  ],
  "summary": {
    "sharpMs": {
      "median": 170.43,
      "min": 167.14,
      "max": 173.39,
      "unit": "ms"
    },
    "jimpMs": {
      "median": 993.01,
      "min": 951.16,
      "max": 1003.77,
      "unit": "ms"
    },
    "sharpBytes": {
      "median": 587329,
      "min": 587329,
      "max": 587329,
      "unit": "bytes"
    },
    "jimpBytes": {
      "median": 689071,
      "min": 689071,
      "max": 689071,
      "unit": "bytes"
    },
    "speedup": 5.826498,
    "timeDiffPct": -82.837031
  },
  "chart": {
    "title": {
      "ko": "이미지 리사이즈 시간과 출력 크기",
      "en": "Image resize time and output size"
    },
    "series": [
      {
        "id": "sharp",
        "role": "target",
        "label": {
          "ko": "sharp",
          "en": "sharp"
        },
        "short": {
          "ko": "sharp",
          "en": "sharp"
        }
      },
      {
        "id": "jimp",
        "role": "baseline",
        "label": {
          "ko": "jimp",
          "en": "jimp"
        },
        "short": {
          "ko": "jimp",
          "en": "jimp"
        }
      }
    ],
    "panels": [
      {
        "title": {
          "ko": "리사이즈 처리 시간",
          "en": "Resize processing time"
        },
        "unit": "ms",
        "kind": "time",
        "better": "lower",
        "keys": {
          "sharp": "sharpMs",
          "jimp": "jimpMs"
        }
      },
      {
        "title": {
          "ko": "출력 이미지 크기",
          "en": "Output image size"
        },
        "unit": "B",
        "kind": "size",
        "better": "lower",
        "keys": {
          "sharp": "sharpBytes",
          "jimp": "jimpBytes"
        }
      }
    ]
  },
  "createdAt": "2026-11-05T01:04:43Z",
  "claim": {
    "quote": "Resizing an image is typically 4x-5x faster than using the quickest ImageMagick and GraphicsMagick settings due to its use of libvips.",
    "url": "https://github.com/lovell/sharp#readme",
    "numbers": [
      5
    ]
  }
}
