Skip to content

Commit

Permalink
add badges
Browse files Browse the repository at this point in the history
  • Loading branch information
elvinzhu committed Aug 21, 2020
1 parent fb10c0e commit 25d5945
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# read file, resize/compress image with or without aspect ratio

[![Build Status](https://travis-ci.org/joyfulljs/draggable.svg?branch=master)](https://travis-ci.org/joyfulljs/draggable)
[![codecov](https://codecov.io/gh/joyfulljs/draggable/branch/master/graph/badge.svg)](https://codecov.io/gh/joyfulljs/draggable)
[![Build Status](https://travis-ci.org/joyfulljs/imagemin.svg?branch=master)](https://travis-ci.org/joyfulljs/imagemin)
[![codecov](https://codecov.io/gh/joyfulljs/imagemin/branch/master/graph/badge.svg)](https://codecov.io/gh/joyfulljs/imagemin)

# API
# usage

```JS
import { compressWithRatio, readFile, compress, createImage } from '@joyfulljs/imagemin';

// compress from a url
createImage('http://yourhost.com/your/img/path/xx.jpg')
.then(img=>{
return compress(img, 80, 80)
}).then(dataUrl=>{
console.log(dataUrl)
});

// compress file from input[type=file]
readFile(fileInput.files[0])
.then(createImage)
.then(img=>{
return compressWithRatio(img, { maxWidth: 800 })
}).then(dataUrl=>{
console.log(dataUrl)
});
```

# api

- **createImage(src: string): Promise\<HTMLImageElement\>**
_Create a HTMLImageElement_
Expand All @@ -30,29 +53,6 @@
_@param dataUrl base64 image_
_@param filename file name_

# DEMO

```JS
import { compressWithRatio, readFile, compress, createImage } from '@joyfulljs/imagemin';

// compress from a url
createImage('http://yourhost.com/your/img/path/xx.jpg')
.then(img=>{
return compress(img, 80, 80)
}).then(dataUrl=>{
console.log(dataUrl)
});

// compress file from input[type=file]
readFile(fileInput.files[0])
.then(createImage)
.then(img=>{
return compressWithRatio(img, { maxWidth: 800 })
}).then(dataUrl=>{
console.log(dataUrl)
});
```

# LICENSE
# licence

MIT
MIT[@elvinzhu](https://github.com/elvinzhu)

0 comments on commit 25d5945

Please sign in to comment.