Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/coderofsalvation/parse-server-image-resize-byurl

Flexible way to resize images on demand (using url-arguments)
https://github.com/coderofsalvation/parse-server-image-resize-byurl

Last synced: 12 days ago
JSON representation

Flexible way to resize images on demand (using url-arguments)

Awesome Lists containing this project

README

        

Flexible Parse server middleware to resize images on demand:

* http://my.parse.server/api/files/myproject/72243e65cd8af516dbc8a67b344.PNG?w=200
* http://my.parse.server/api/files/myproject/72243e65cd8af516dbc8a67b344.PNG?w=700

> It resizes on demand, or serves a cached file after the first requests

Fast performance: it clamps imagesizes:

* ?w=200 => resizes to width of 200px
* ?w=260 => resizes to width of 300px
* ?w=320 => resizes to width of 400px

## Installation

$ npm install parse-server-image-resize-byurl

now add it as express middleware:

```
var cfg {

...

filesAdapter: {
module: 'parse-server-fs-store-adapter',
options: { filesSubDirectory: 'data/files' }
}
}

var parse = new ParseServer(cfg)

var app = express()
app.use( require('parse-server-image-resize-byurl')(cfg.filesAdapter.options.filesSubDirectory) )
```

Now you can just use Parse imagefiles as usual, and add the `?w=xxxx` resize-option to urls.