{"id":21027813,"url":"https://github.com/idiotwu/canvas-compress","last_synced_at":"2025-05-15T10:32:55.836Z","repository":{"id":57193690,"uuid":"49405835","full_name":"idiotWu/canvas-compress","owner":"idiotWu","description":"Image compression with the magic of canvas.","archived":false,"fork":false,"pushed_at":"2016-11-16T07:58:30.000Z","size":46,"stargazers_count":54,"open_issues_count":1,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-19T18:17:03.589Z","etag":null,"topics":["canvas","image-compression"],"latest_commit_sha":null,"homepage":"http://idiotwu.github.io/canvas-compress/","language":"JavaScript","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/idiotWu.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":"2016-01-11T06:06:55.000Z","updated_at":"2025-04-09T07:56:45.000Z","dependencies_parsed_at":"2022-09-11T07:51:26.297Z","dependency_job_id":null,"html_url":"https://github.com/idiotWu/canvas-compress","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiotWu%2Fcanvas-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiotWu%2Fcanvas-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiotWu%2Fcanvas-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiotWu%2Fcanvas-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiotWu","download_url":"https://codeload.github.com/idiotWu/canvas-compress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254323195,"owners_count":22051742,"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","image-compression"],"created_at":"2024-11-19T11:52:41.646Z","updated_at":"2025-05-15T10:32:55.466Z","avatar_url":"https://github.com/idiotWu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CanvasCompress\n\nCompressing image with HTML5 canvas.\n\n## Browser Compatibility\n\n| Browser | Version |\n| :------ | :-----: |\n| IE      | 10+     |\n| Chrome  | 22+     |\n| Firefox | 16+     |\n| Safari  | 8+      |\n| Android Browser | 4+ |\n| Chrome for Android | 32+ |\n| iOS Safarri | 7+ |\n\n## Dependencies\n\n1. [Exif.js](https://github.com/exif-js/exif-js)\n2. ES6 Promise polyfill.\n\n## Install\n\nVia npm:\n\n```\nnpm install canvas-compress --save\n```\n\nVia bower:\n\n```\nbower install canvas-compress --save\n```\n\n## Usage\n\n```javascript\nimport CanvasCompress from 'canvas-compress';\n\nconst compressor = new CanvasCompress({\n    type: CanvasCompress.MIME.JPEG,\n    width: 1000,\n    height: 618,\n    quality: 0.9,\n});\n\ncompressor.process(fileBlob).then(({ source, result }) =\u003e {\n    // const { blob, width, height } = source;\n    const { blob, width, height } = result;\n    ...\n});\n```\n\n## Options\n\nThere're four optional properties for options object:\n\n- `type: string`: output type, default is `CanvasCompress.MIME.JPEG`\n\n- `width: number`: output width, default is `1000`\n\n- `height: number`: ouput height, default is `618`\n\n- `quality: number`: output quality, defalut is `0.9`\n\n## Use third-party Promise\n\n```javascript\nCanvasCompress.usePromise(require('bluebird'));\n```\n\n## Supported output MIME types\n\nSince canvas-compress uses [`canvas.toDataUrl()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL) method to convert canvas to binary, the following MIME types are supported:\n\n- `'image/png'`\n- `'image/jpeg'`\n- `'image/webp'`\n\nYou can get MIME type via `CanvasCompress.MIME`, or use `CanvasCompress.isSupportedType(MIMEtype: string)` to check if it's a valid MIME type.\n\n## About alpha channel\n\nAlpha channel is not available with MIME type `image/jpeg`, so when you are trying to turn an image into jpeg, you'll get a full white background(`rgb(255, 255, 255)`) instead of transparent black(`rgba(0, 0, 0, 0)`).\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiotwu%2Fcanvas-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiotwu%2Fcanvas-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiotwu%2Fcanvas-compress/lists"}