# d-image-edit

> A Derby JS component for editing images.

Latest version **0.4.3** (published 2014-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install d-image-edit
pnpm add d-image-edit
yarn add d-image-edit
bun add d-image-edit
```

## 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.3 |
| Published | 2014-11-11 |
| First published | 2014-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Dennis Torres |
| Maintainers | psirenny |
| Keywords | component, derby, derby-component, image, edit, photo, picture |

## Links

- npm: https://www.npmjs.com/package/d-image-edit
- Repository: https://github.com/psirenny/d-image-edit
- Issues: https://github.com/psirenny/d-image-edit/issues
- npm.io page: https://npm.io/package/d-image-edit

## Dependencies (2)

- [debounce](https://npm.io/package/debounce.md) ^1.0.0
- [d-panzoom](https://npm.io/package/d-panzoom.md) ^0.1.2

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 0.4.3 (latest) — 2014-11-11
- 0.4.2 — 2014-10-29
- 0.4.1 — 2014-09-22
- 0.4.0 — 2014-08-10
- 0.5.0 — 2014-07-26

## README

Derby Image Edit
================

A [Derby JS](http://derbyjs.com) component for editing images.
It uses [Derby Panzoom](https://github.com/psirenny/d-panzoom) to edit images.

Features
--------

* Resize and crop images by panning and zooming.
* Display your image in a container smaller than the final image size.
* All of the features in jQuery Panzoom (transitions, etc.)

Installation
------------

    $ npm install d-image-edit --save

Dependencies
------------

This component extends Derby Panzoom which, requires [jQuery Panzoom](https://github.com/timmywil/jquery.panzoom) in order to work.
You must include the script on the page.

Usage
-----

Create a view:

    <index: element="image-edit">
      <div as="container">
        <img alt="" as="image" src="{{@src}}">
      </div>
      <!-- must use hidden/visible classes rather than {{if}} blocks -->
      <div class="{{if !canScale}}hidden{{/if}}">
        <button on-click="zoom(true)" type="button">Zoom out</button>
        <input type="range" as="range">
        <button on-click="zoom()" type="button">Zoom in</button>
      </div>

Associate the view with the component:

    app.use('image-edit', require('d-image-edit'));

Use the view:

    <Scripts:>
      <script src="jquery.panzoom.js">

    <Body:>
      <edit contain="invert" on-draw="save()" src="..."></edit>

Elements
--------

**image (Required)** - The `<img>` element that should contain the image source.

**input** - The `<input type="file">` element that can select a new image.

**range** - The `<input type="range">` element that can zoom in and out.

Data
----

The following path data is available to the view implementing the component:

**canScale** - True if the computed max scale is greater than the min scale. Use this to conditionally display zoom in and zoom out controls.

**from.image** - The image used to draw the final image.

**loading** - True while the image is loading.

**to.image** - The final image.

Options
-------

**debounce** - The wait time before a re-draw occurs after a change.

**filetype** - The file type to draw the image as. Defaults to **png**.

**size** - The width and height of the final image.

**width** - The width of the final image. Overrides **size**.

**height** - The height of the final image. Overrides **size**.

Functions
---------

**clear()** - Clear all image data.

Events
------

**clear()** - Event emitted after the image is cleared.

**draw(image)** - Event emitted after a new image is drawn based on changes by panning or zooming.

**load(image)** - Event emitted after the image is loaded.

Other
-----

There are more options, events and functions. See [Derby Panzoom](http://derbyjs.com).

Notes
-----

Be careful about wrapping special elements such as `input` and `range` in `{{if}}` blocks.
If the `{{if}}` block evaluates to false then the server will not render the initial element and it won't be found by the component.
Use `hidden` or `visible` classes to toggle visibility instead.

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