{"id":23274143,"url":"https://github.com/buzut/resizeimg","last_synced_at":"2025-12-12T04:59:29.331Z","repository":{"id":18505764,"uuid":"84467941","full_name":"Buzut/resizeimg","owner":"Buzut","description":"Smartly resize/crop images in the browser prior to upload","archived":false,"fork":false,"pushed_at":"2023-04-18T07:09:04.000Z","size":169,"stargazers_count":11,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-16T02:42:15.710Z","etag":null,"topics":["crop-image","image-processing","javascript","resize-images"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Buzut.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,"governance":null}},"created_at":"2017-03-09T17:05:57.000Z","updated_at":"2024-07-18T07:19:24.000Z","dependencies_parsed_at":"2023-07-13T15:47:49.313Z","dependency_job_id":null,"html_url":"https://github.com/Buzut/resizeimg","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":"0.11111111111111116","last_synced_commit":"3f6b016210c4761a1fb54dbf46d96a5c06037c91"},"previous_names":["buzut/resize-image"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Buzut%2Fresizeimg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Buzut%2Fresizeimg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Buzut%2Fresizeimg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Buzut%2Fresizeimg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Buzut","download_url":"https://codeload.github.com/Buzut/resizeimg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230494926,"owners_count":18235047,"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":["crop-image","image-processing","javascript","resize-images"],"created_at":"2024-12-19T20:12:19.336Z","updated_at":"2025-12-12T04:59:29.277Z","avatar_url":"https://github.com/Buzut.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# resize-image\n\nEfficiently resize and/or crop images in browser thanks to HTML5 canvas. Cropping is automatically adjusted in a smart way thanks to [smartcrop](https://github.com/jwagner/smartcrop.js).\n\n_Why waste time on network transfer when you can compress in the browser?_\n\n\n## Installation \u0026 usage\n\n```\nnpm install smart-img-resize\n```\n\n\n```js\n// require using commonJS\nconst resizeImage = require('smart-img-resize');\n\n// or in es6, using a module bundler like rollup or webpack\nimport resizeImage from 'smart-img-resize';\n\n// get your input file (it has id=\"upload-image\")\nconst inputFile = document.getElementById('upload-image');\n\n// get the actual file object from your input field as soon as a file is selected\ninputFile.onchange = function () {\n    const img = inputFile.files[0];\n\n    resizeImage(img, {\n        outputFormat: 'jpeg',\n        targetWidth: 200,\n        targetHeight: 200,\n        crop: true\n    }, (err, b64img) =\u003e {\n        if (err) {\n            console.error(err);\n            return;\n        }\n\n        // do what you have to with the b64img\n    });\n};\n```\n\n### Parameters\n\nThe function takes three arguments:\n\n- `img` – the image as a file object from input file\n- `options` object\n  - {string} `outputFormat` – (jpe?g|png|canvas), canvas =\u003e canvas element, others =\u003e dataURI\n  - {string} `targetWidth`\n  - {string} `targetHeight`\n  - {bool} `crop` – if true, (smartly) crop image to the desired dimensions (optional)\n  - {bool} `forceRatio` – if true, force dimensions without regard to the aspect ratio (optional)\n- `callback`\n\n__Note that `crop` and `forceRatio` are mutually exclusive__\n\n## Contributing\nThere's sure room for improvement, so feel free to hack around and submit PRs!\nPlease just follow the style of the existing code, which is [Airbnb's style](http://airbnb.io/javascript/) with [minor modifications](.eslintrc).\n\nTo maintain things clear and visual, please follow the [git commit template](https://github.com/Buzut/git-emojis-hook).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuzut%2Fresizeimg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuzut%2Fresizeimg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuzut%2Fresizeimg/lists"}