├── .browserslistrc ├── .editorconfig ├── .eslintrc ├── .gitattributes ├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── ci.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .stylelintrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── babel.config.js ├── commitlint.config.js ├── dist ├── compressor.common.js ├── compressor.esm.js ├── compressor.js └── compressor.min.js ├── docs ├── css │ └── main.css ├── examples │ ├── grayscale.html │ ├── watermark.html │ └── work-with-promise.html ├── images │ ├── picture.jpg │ └── picture.png ├── index.html └── js │ ├── compressor.js │ └── main.js ├── lint-staged.config.js ├── package-lock.json ├── package.json ├── rollup.config.js ├── src ├── constants.js ├── defaults.js ├── index.js └── utilities.js ├── test ├── .eslintrc ├── helpers.js ├── karma.conf.js └── specs │ ├── Compressor.spec.js │ ├── methods │ ├── abort.spec.js │ ├── noConflict.spec.js │ └── setDefaults.spec.js │ └── options │ ├── beforeDraw.spec.js │ ├── checkOrientation.spec.js │ ├── convertSize.spec.js │ ├── convertTypes.spec.js │ ├── drew.spec.js │ ├── error.spec.js │ ├── height.spec.js │ ├── maxHeight.spec.js │ ├── maxWidth.spec.js │ ├── mimeType.spec.js │ ├── minHeight.spec.js │ ├── minWidth.spec.js │ ├── quality.spec.js │ ├── resize.spec.js │ ├── retainExif.spec.js │ ├── strict.spec.js │ ├── success.spec.js │ └── width.spec.js └── types └── index.d.ts /.browserslistrc: -------------------------------------------------------------------------------- 1 | defaults 2 | ie >= 10 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb-base", 3 | "env": { 4 | "browser": true 5 | }, 6 | "root": true, 7 | "rules": { 8 | "no-param-reassign": "off", 9 | "valid-jsdoc": ["error", { 10 | "requireReturn": false 11 | }] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of the level of experience, gender, gender identity, and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 6 | 7 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 8 | 9 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. 10 | 11 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 12 | 13 | This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at https://www.contributor-covenant.org/version/1/0/0/code-of-conduct.html 14 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Compressor.js 2 | 3 | > Based on [Angular's contributing guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md). 4 | 5 | We would love for you to contribute to Compressor.js and help make it even better than it is today! As a contributor, here are the guidelines we would like you to follow: 6 | 7 | - [Contributing to Compressor.js](#contributing-to-compressorjs) 8 | - [Code of Conduct](#code-of-conduct) 9 | - [Question or Problem](#question-or-problem) 10 | - [Issues and Bugs](#issues-and-bugs) 11 | - [Feature Requests](#feature-requests) 12 | - [Submission Guidelines](#submission-guidelines) 13 | - [Submitting an Issue](#submitting-an-issue) 14 | - [Submitting a Pull Request (PR)](#submitting-a-pull-request-pr) 15 | - [After your pull request is merged](#after-your-pull-request-is-merged) 16 | - [Coding Rules](#coding-rules) 17 | - [Commit Message Guidelines](#commit-message-guidelines) 18 | - [Commit Message Format](#commit-message-format) 19 | - [Revert](#revert) 20 | - [Type](#type) 21 | - [Scope](#scope) 22 | - [Subject](#subject) 23 | - [Body](#body) 24 | - [Footer](#footer) 25 | 26 | ## Code of Conduct 27 | 28 | Help us keep Compressor.js open and inclusive. Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md). 29 | 30 | ## Question or Problem 31 | 32 | Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on [Stack Overflow](https://stackoverflow.com/questions/tagged/compressorjs) where the questions should be tagged with tag `compressorjs`. 33 | 34 | Stack Overflow is a much better place to ask questions since: 35 | 36 | - There are thousands of people willing to help on Stack Overflow. 37 | - Questions and answers stay available for public viewing so your question/answer might help someone else. 38 | - Stack Overflow's voting system assures that the best answers are prominently visible. 39 | 40 | To save you and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow. 41 | 42 | ## Issues and Bugs 43 | 44 | If you find a bug in the source code, you can help us by [submitting an issue](#submitting-an-issue) to our [GitHub Repository](https://github.com/fengyuanchen/compressorjs). Even better, you can [submit a Pull Request](#submitting-a-pull-request-pr) with a fix. 45 | 46 | ## Feature Requests 47 | 48 | You can *request* a new feature by [submitting an issue](#submitting-an-issue) to our [GitHub Repository](https://github.com/fengyuanchen/compressorjs). If you would like to *implement* a new feature, please submit an issue with a proposal for your work first, to be sure that we can use it. 49 | 50 | Please consider what kind of change it is: 51 | 52 | - For a **Major Feature**, first, open an issue and outline your proposal so that it can be discussed. This will also allow us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project. 53 | - **Small Features** can be crafted and directly [submitted as a Pull Request](#submitting-a-pull-request-pr). 54 | 55 | ## Submission Guidelines 56 | 57 | ### Submitting an Issue 58 | 59 | Before you submit an issue, please search the [issue tracker](https://github.com/fengyuanchen/compressorjs/issues), which may be an issue for your problem already exists and the discussion might inform you of workarounds readily available. 60 | 61 | We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. To reproduce bugs, we will systematically ask you to provide a minimal reproduction scenario using [CodePen](https://codepen.io/pen). Having a live, reproducible scenario gives us a wealth of important information without going back & forth to you with additional questions like: 62 | 63 | - version of Compressor.js used 64 | - 3rd-party libraries and their versions 65 | - and most importantly - a use-case that fails 66 | 67 | A minimal reproduction scenario using [CodePen](https://codepen.io/pen) allows us to quickly confirm a bug (or point out a coding problem) as well as confirm that we are fixing the right problem. If [CodePen](https://codepen.io/pen) is not a suitable way to demonstrate the problem (for example for issues related to our npm packaging), please create a standalone git repository demonstrating the problem. 68 | 69 | We will be insisting on a minimal reproduction scenario to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience users often find coding problems themselves while preparing a minimal reproduction scenario. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we need to isolate the problem before we can fix it. 70 | 71 | Unfortunately, we are not able to investigate/fix bugs without a minimal reproduction scenario, so if we don't hear back from you we are going to close an issue that doesn't have enough info to be reproduced. 72 | 73 | You can file new issues by filling out our [new issue form](https://github.com/fengyuanchen/compressorjs/issues/new). 74 | 75 | ### Submitting a Pull Request (PR) 76 | 77 | Before you submit your Pull Request (PR) consider the following guidelines: 78 | 79 | 1. Search [GitHub](https://github.com/fengyuanchen/compressorjs/pulls) for an open or closed PR that relates to your submission. You don't want to duplicate effort. 80 | 1. Fork the **fengyuanchen/compressorjs** repo. 81 | 1. Make your changes in a new git branch: 82 | 83 | ```shell 84 | git checkout -b my-fix-branch main 85 | ``` 86 | 87 | 1. Create your patch, **including appropriate test cases**. 88 | 1. Follow our [Coding Rules](#coding-rules). 89 | 1. Run the full Compressor.js test suite, and ensure that all tests pass. 90 | 1. Commit your changes using a descriptive commit message that follows our [Commit Message Guidelines](#commit-message-guidelines). Adherence to these guidelines is necessary because release notes are automatically generated from these messages. 91 | 92 | ```shell 93 | git commit -a 94 | ``` 95 | 96 | Note: the optional commit `-a` command-line option will automatically "add" and "rm" edited files. 97 | 1. Push your branch to GitHub: 98 | 99 | ```shell 100 | git push origin my-fix-branch 101 | ``` 102 | 103 | 1. In GitHub, send a pull request to `compressorjs:main`. 104 | 1. If we suggest changes then: 105 | - Make the required updates. 106 | - Re-run the Compressor.js test suites to ensure tests are still passing. 107 | - Rebase your branch and force push to your GitHub repository (this will update your Pull Request): 108 | 109 | ```shell 110 | git rebase main -i 111 | git push -f 112 | ``` 113 | 114 | That's it! Thank you for your contribution! 115 | 116 | #### After your pull request is merged 117 | 118 | After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository: 119 | 120 | 1. Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: 121 | 122 | ```shell 123 | git push origin --delete my-fix-branch 124 | ``` 125 | 126 | 1. Check out the main branch: 127 | 128 | ```shell 129 | git checkout main -f 130 | ``` 131 | 132 | 1. Delete the local branch: 133 | 134 | ```shell 135 | git branch -D my-fix-branch 136 | ``` 137 | 138 | 1. Update your main with the latest upstream version: 139 | 140 | ```shell 141 | git pull --ff upstream main 142 | ``` 143 | 144 | ## Coding Rules 145 | 146 | To ensure consistency throughout the source code, keep these rules in mind as you are working: 147 | 148 | - All features or bug fixes **must be tested** by one or more specs (unit-tests). 149 | - All public API methods **must be documented**. 150 | - We follow [Airbnb's JavaScript Style Guide](https://github.com/airbnb/javascript). 151 | 152 | ## Commit Message Guidelines 153 | 154 | ### Commit Message Format 155 | 156 | A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: 157 | 158 | ``` 159 | (): 160 | 161 | 162 | 163 |