# bookshelf-imageclip

> Image attachments with Bookshelf.js

Latest version **0.4.1-rc2** (published 2018-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install bookshelf-imageclip
pnpm add bookshelf-imageclip
yarn add bookshelf-imageclip
bun add bookshelf-imageclip
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1-rc2 |
| Published | 2018-02-19 |
| First published | 2015-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 462.1 KB |
| Known vulnerabilities | 0 (+9 in 3 direct dependencies) |
| Install scripts | no |
| Author | Adrian Fraiha |
| Maintainers | aef |
| Keywords | bookshelf, image, attachment, paperclip |

## Links

- npm: https://www.npmjs.com/package/bookshelf-imageclip
- Repository: https://github.com/aef-/bookshelf-imageclip
- Homepage: https://github.com/aef-/bookshelf-imageclip#readme
- Issues: https://github.com/aef-/bookshelf-imageclip/issues
- npm.io page: https://npm.io/package/bookshelf-imageclip

## Dependencies (7)

- [gm](https://npm.io/package/gm.md) ^1.18.1
- [knex](https://npm.io/package/knex.md) ^0.8.6
- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [request](https://npm.io/package/request.md) ^2.61.0
- [bluebird](https://npm.io/package/bluebird.md) ^2.9.34
- [fs-extra](https://npm.io/package/fs-extra.md) ^0.24.0
- [bookshelf](https://npm.io/package/bookshelf.md) ^0.8.2

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.4.1-rc2 (latest) — 2018-02-19
- 0.4.1-rc1 — 2018-02-19
- 0.3.3 — 2016-05-24
- 0.3.2 — 2016-05-16
- 0.3.1 — 2016-05-11
- 0.3.0 — 2016-01-14
- 0.2.0 — 2016-01-13
- 0.0.3 — 2015-10-09
- 0.0.2 — 2015-10-09
- 0.0.1 — 2015-10-08

## README

# bookshelf-imageclip

THIS PACKAGE DOES NOT HAVE A STABLE RELEASE JUST YET. USAGE MAY CHANGE. SEE MILESTONES.

## Installation
> npm install bookshelf-imageclip

## Usage
Best to look at the tests.

Your schema must include ```<field>_file_name```.
```js
bookshelf.Model.extend({
  tableName: 'users',
  imageClip: {
    <field_name>: {
      <style_name>: {
        process: function( gm, model ) {
          return gm.resize( "500x500" ); //See node-gm documentation
        }
      }
    }
  }
```

## Examples
```js
    var bookshelf = require('bookshelf')(knex);
    bookshelf.plugin(require('bookshelf-imageclip'), {useImageMagick: true});
    
    User = bookshelf.Model.extend({
      tableName: 'users',
      imageClip: {
        avatar: {
          original: {
            process: function( gm, model ) {
              return gm;
            }
          },
          medium: {
            process: function( gm, model ) {
              return gm.resize( "500x500" ) ;
            }
          },
          thumb: {
            process: function( gm, model ) {
              return gm.resize( "100x100" ) ;
            }
          }
        }
      }
    });
    
    User.forge( )
        .save( { avatar: "http://hamburgerhelper.com/pigeon.jpg" } )
        .then( function( user ) {
          console.info( user.get( "avatar" ).medium ) // outputs: images/244/8ea/avatar/medium/pigeon.jpg
        } );
```

## Roadmap
See issues for milestones and changes for first stable release.

## Contributing
I'd be happy to pull in any requests as long as you add tests.

---
_Source: https://npm.io/package/bookshelf-imageclip · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
