{"id":17676542,"url":"https://github.com/yoannchb-pro/jimg","last_synced_at":"2026-05-17T09:43:27.554Z","repository":{"id":57750173,"uuid":"525076273","full_name":"yoannchb-pro/jimg","owner":"yoannchb-pro","description":"Merge multiple images into one single image","archived":false,"fork":false,"pushed_at":"2022-08-23T15:50:56.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-07T09:04:59.254Z","etag":null,"topics":["canvas","compression","format","image","image-processing","join","merge","nodejs","resize-images","truncate"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoannchb-pro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-15T17:24:09.000Z","updated_at":"2022-08-23T15:51:28.000Z","dependencies_parsed_at":"2022-08-26T09:30:56.742Z","dependency_job_id":null,"html_url":"https://github.com/yoannchb-pro/jimg","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannchb-pro%2Fjimg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannchb-pro%2Fjimg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannchb-pro%2Fjimg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannchb-pro%2Fjimg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoannchb-pro","download_url":"https://codeload.github.com/yoannchb-pro/jimg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246353138,"owners_count":20763609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["canvas","compression","format","image","image-processing","join","merge","nodejs","resize-images","truncate"],"created_at":"2024-10-24T07:25:57.342Z","updated_at":"2025-10-16T21:08:36.760Z","avatar_url":"https://github.com/yoannchb-pro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jimg\n\n\u003e **Note:** The README is inspired from merge-images by Luke Childs but it's not the same package and fonctionnalities\n\nMerge, truncat, compress, resize, convert, edit multiple images into one single image on nodejs and in the browser.\n\n## Install\n\n```\n$ npm install --save jimg\n```\n\n## Usage\n\nWith the following images:\n\n| `/body.png`                               | `/eyes.png`                               | `/mouth.png`                               |\n| ----------------------------------------- | ----------------------------------------- | ------------------------------------------ |\n| \u003cimg src=\"./assets/body.png\" width=\"128\"\u003e | \u003cimg src=\"./assets/eyes.png\" width=\"128\"\u003e | \u003cimg src=\"./assets/mouth.png\" width=\"128\"\u003e |\n\nYou can do:\n\n```js\nconst jimg = require(\"jimg\");\n\njimg({ images: [\"/body.png\", \"/eyes.png\", \"/mouth.png\"] }).then(\n  (b64) =\u003e (document.querySelector(\"img\").src = b64)\n);\n// data:image/png;base64,iVBORw0KGgoAA...\n```\n\nOr in the browser\n\n```html\n\u003cscript src=\"https://unpkg.com/jimg@1.0.1/dist/index.js\"\u003e\u003c/script\u003e\n```\n\nAnd that would update the `img` element to show this image:\n\n\u003cimg src=\"./assets/face.png\" width=\"128\"\u003e\n\n## Saving image\n\nThis is how to save an image to a specific location on nodejs or in the browser\n\n```js\njimg({\n  path: \"./merged.png\",\n  images: [\"/body.png\", \"/eyes.png\", \"/mouth.png\"],\n}).then((b64) =\u003e (document.querySelector(\"img\").src = b64));\n// data:image/png;base64,iVBORw0KGgoAA...\n```\n\n## Positioning and resizing\n\nThose source png images were already the right dimensions to be overlaid on top of each other. You can also supply an array of objects with x/y co-ords to manually position each image or resize an image with width/height:\n\n```js\njimg({\n    images: [\n        { path: 'body.png', x: 0, y: 0 },\n        { path: 'eyes.png', x: 32, y: 0, width: 256, height: 256 },\n        { path: 'mouth.png', x: 16, y: 0 }\n    ]\n})\n  .then(b64 =\u003e ...);\n// data:image/png;base64,iVBORw0KGgoAA...\n```\n\nUsing the same source images as above would output this:\n\n\u003cimg src=\"./assets/face-custom-positions.png\" width=\"128\"\u003e\n\n### Opacity\n\nThe opacity can also be tweaked on each image.\n\n```js\njimg({\n    images: [\n        { path: 'body.png' },\n        { path: 'eyes.png', opacity: 0.7 },\n        { path: 'mouth.png', opacity: 0.3 }\n    ]\n})\n  .then(b64 =\u003e ...);\n// data:image/png;base64,iVBORw0KGgoAA...\n```\n\n\u003cimg src=\"./assets/face-opacity.png\" width=\"128\"\u003e\n\n### Truncat\n\nYou can simply truncat an image by using truncat property (x, y, width and height are optionals)\n\n```js\njimg({\n    images: [\"/body.png\", \"/eyes.png\", \"/mouth.png\"],\n    truncat: { x: 0, y: 0, width: 128, height: 128 }\n  }).then(\n  b64 =\u003e ...\n);\n// data:image/png;base64,iVBORw0KGgoAA...\n```\n\nWhich will look like this:\n\n\u003cimg src=\"./assets/face-custom-dimension.png\" width=\"64\"\u003e\n\n## Quality\n\nYou can custom the quality of the image to compress it. Default is 0.92.\n\n```js\njimg({\n    images: [\"/body.png\", \"/eyes.png\", \"/mouth.png\"],\n    quality: 0.7\n  }).then(\n  b64 =\u003e ...\n);\n// data:image/png;base64,iVBORw0KGgoAA...\n```\n\n## Format\n\nCustom the format in jpg for example\n\n```js\njimg({\n    images: [\"/body.png\", \"/eyes.png\", \"/mouth.png\"],\n    format: 'image/jpeg'\n  }).then(\n  b64 =\u003e ...\n);\n// data:image/png;base64,iVBORw0KGgoAA...\n```\n\n## Canvas\n\nCustom the canvas. Can be an instance of document canvas or nodejs canvas package.\n\n```js\njimg({\n    images: [\"/body.png\", \"/eyes.png\", \"/mouth.png\"],\n    canvas: document.querySelector(\"canvas\") //of createCanvas()\n  }).then(\n  b64 =\u003e ...\n);\n// data:image/png;base64,iVBORw0KGgoAA...\n```\n\n## License\n\nMIT © yoannchb\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoannchb-pro%2Fjimg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoannchb-pro%2Fjimg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoannchb-pro%2Fjimg/lists"}