Skip to content

Commit

Permalink
release v1.0.1
Browse files Browse the repository at this point in the history
- fixing bug related to wrong image output resolution in some cases
  • Loading branch information
Donaldcwl committed Mar 8, 2019
1 parent 3f9079e commit 729951f
Show file tree
Hide file tree
Showing 22 changed files with 560 additions and 410 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Javascript module to be run in the web browser for image compression.
- **Multi-thread** (web worker) non-blocking compression are supported through options.

## Change log ##
v1.0.1
- fixing bug related to wrong image output resolution in some case

v1.0.0
- breaking change: change "imageCompression" function signature
- use of OffscreenCanvas when support, fallback to document.createElement('canvas')
Expand Down Expand Up @@ -141,6 +144,16 @@ cd browser-image-compression/example
# open "basic.html" on your browser
```

## Contribution ##
1. fork the repo and git clone it
2. run `npm run watch` # it will watch code change in lib/ folder and generate js in dist/ folder
3. add/update code in lib/ folder
4. try the code by opening example/development.html which will load the js in dist/ folder
5. add/update test in test/ folder
6. `npm run test`
7. push to your forked repo on github
8. make a pull request to this repo

[dist]: https://github.com/Donaldcwl/browser-image-compression/tree/master/dist
[example]: https://github.com/Donaldcwl/browser-image-compression/tree/master/example
[delivrjs]: https://cdn.jsdelivr.net/
2 changes: 1 addition & 1 deletion coverage/badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions coverage/coverage-final.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"total": {"lines":{"total":159,"covered":110,"skipped":0,"pct":69.18},"statements":{"total":172,"covered":112,"skipped":0,"pct":65.12},"functions":{"total":21,"covered":18,"skipped":0,"pct":85.71},"branches":{"total":74,"covered":34,"skipped":0,"pct":45.95}}
{"total": {"lines":{"total":159,"covered":115,"skipped":0,"pct":72.33},"statements":{"total":172,"covered":117,"skipped":0,"pct":68.02},"functions":{"total":21,"covered":18,"skipped":0,"pct":85.71},"branches":{"total":74,"covered":39,"skipped":0,"pct":52.7}}
,"/Users/donald/Project/browser-image-compression/lib/image-compression.js": {"lines":{"total":31,"covered":23,"skipped":0,"pct":74.19},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":31,"covered":23,"skipped":0,"pct":74.19},"branches":{"total":18,"covered":13,"skipped":0,"pct":72.22}}
,"/Users/donald/Project/browser-image-compression/lib/index.js": {"lines":{"total":25,"covered":22,"skipped":0,"pct":88},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":25,"covered":22,"skipped":0,"pct":88},"branches":{"total":17,"covered":11,"skipped":0,"pct":64.71}}
,"/Users/donald/Project/browser-image-compression/lib/utils.js": {"lines":{"total":103,"covered":65,"skipped":0,"pct":63.11},"functions":{"total":19,"covered":16,"skipped":0,"pct":84.21},"statements":{"total":116,"covered":67,"skipped":0,"pct":57.76},"branches":{"total":39,"covered":10,"skipped":0,"pct":25.64}}
,"/Users/donald/Project/browser-image-compression/lib/index.js": {"lines":{"total":25,"covered":22,"skipped":0,"pct":88},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":25,"covered":22,"skipped":0,"pct":88},"branches":{"total":17,"covered":12,"skipped":0,"pct":70.59}}
,"/Users/donald/Project/browser-image-compression/lib/utils.js": {"lines":{"total":103,"covered":70,"skipped":0,"pct":67.96},"functions":{"total":19,"covered":16,"skipped":0,"pct":84.21},"statements":{"total":116,"covered":72,"skipped":0,"pct":62.07},"branches":{"total":39,"covered":14,"skipped":0,"pct":35.9}}
}
38 changes: 19 additions & 19 deletions coverage/image-compression.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,39 +129,39 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand All @@ -171,7 +171,7 @@ <h1>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand All @@ -183,7 +183,7 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import { canvasToFile, drawFileInCanvas, followExifOrientation, getExifOrientation, handleMaxWidthOrHeight } from './utils'
&nbsp;
/**
Expand Down Expand Up @@ -259,7 +259,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Wed Feb 06 2019 15:51:16 GMT+0800 (Hong Kong Standard Time)
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri Mar 08 2019 15:37:32 GMT+0800 (Hong Kong Standard Time)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
32 changes: 16 additions & 16 deletions coverage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ <h1>
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">65.12% </span>
<span class="strong">68.02% </span>
<span class="quiet">Statements</span>
<span class='fraction'>112/172</span>
<span class='fraction'>117/172</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">45.95% </span>
<span class="strong">52.7% </span>
<span class="quiet">Branches</span>
<span class='fraction'>34/74</span>
<span class='fraction'>39/74</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">85.71% </span>
<span class="quiet">Functions</span>
<span class='fraction'>18/21</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">69.18% </span>
<span class="strong">72.33% </span>
<span class="quiet">Lines</span>
<span class='fraction'>110/159</span>
<span class='fraction'>115/159</span>
</div>
</div>
<p class="quiet">
Expand Down Expand Up @@ -79,8 +79,8 @@ <h1>
<td data-value="88" class="pic high"><div class="chart"><div class="cover-fill" style="width: 88%;"></div><div class="cover-empty" style="width:12%;"></div></div></td>
<td data-value="88" class="pct high">88%</td>
<td data-value="25" class="abs high">22/25</td>
<td data-value="64.71" class="pct medium">64.71%</td>
<td data-value="17" class="abs medium">11/17</td>
<td data-value="70.59" class="pct medium">70.59%</td>
<td data-value="17" class="abs medium">12/17</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="1" class="abs high">1/1</td>
<td data-value="88" class="pct high">88%</td>
Expand All @@ -89,15 +89,15 @@ <h1>

<tr>
<td class="file medium" data-value="utils.js"><a href="utils.js.html">utils.js</a></td>
<td data-value="57.76" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 57%;"></div><div class="cover-empty" style="width:43%;"></div></div></td>
<td data-value="57.76" class="pct medium">57.76%</td>
<td data-value="116" class="abs medium">67/116</td>
<td data-value="25.64" class="pct low">25.64%</td>
<td data-value="39" class="abs low">10/39</td>
<td data-value="62.07" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 62%;"></div><div class="cover-empty" style="width:38%;"></div></div></td>
<td data-value="62.07" class="pct medium">62.07%</td>
<td data-value="116" class="abs medium">72/116</td>
<td data-value="35.9" class="pct low">35.9%</td>
<td data-value="39" class="abs low">14/39</td>
<td data-value="84.21" class="pct high">84.21%</td>
<td data-value="19" class="abs high">16/19</td>
<td data-value="63.11" class="pct medium">63.11%</td>
<td data-value="103" class="abs medium">65/103</td>
<td data-value="67.96" class="pct medium">67.96%</td>
<td data-value="103" class="abs medium">70/103</td>
</tr>

</tbody>
Expand All @@ -106,7 +106,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Wed Feb 06 2019 15:51:16 GMT+0800 (Hong Kong Standard Time)
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri Mar 08 2019 15:37:32 GMT+0800 (Hong Kong Standard Time)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
30 changes: 15 additions & 15 deletions coverage/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ <h1>
<span class='fraction'>22/25</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">64.71% </span>
<span class="strong">70.59% </span>
<span class="quiet">Branches</span>
<span class='fraction'>11/17</span>
<span class='fraction'>12/17</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
Expand Down Expand Up @@ -155,25 +155,25 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-yes">9x</span>
<span class="cline-any cline-yes">9x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-yes">9x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-yes">7x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
Expand All @@ -182,15 +182,15 @@ <h1>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
Expand Down Expand Up @@ -234,7 +234,7 @@ <h1>
&nbsp;
let compressedFile
&nbsp;
options.maxSizeMB = options.maxSizeMB || <span class="branch-1 cbranch-no" title="branch not covered" >Number.POSITIVE_INFINITY</span>
options.maxSizeMB = options.maxSizeMB || Number.POSITIVE_INFINITY
options.useWebWorker = typeof options.useWebWorker === 'boolean' ? options.useWebWorker : <span class="branch-1 cbranch-no" title="branch not covered" >true</span>
&nbsp;
if (!(file instanceof Blob || file instanceof File)) {
Expand Down Expand Up @@ -289,7 +289,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Wed Feb 06 2019 15:51:16 GMT+0800 (Hong Kong Standard Time)
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri Mar 08 2019 15:37:32 GMT+0800 (Hong Kong Standard Time)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
Loading

0 comments on commit 729951f

Please sign in to comment.