ngx-image-cropper 6.1.0 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -47
- package/esm2020/index.mjs +7 -0
- package/esm2020/lib/component/image-cropper.component.mjs +35 -9
- package/esm2020/lib/image-cropper.module.mjs +2 -2
- package/esm2020/lib/interfaces/image-transform.interface.mjs +1 -1
- package/esm2020/lib/interfaces/move-start.interface.mjs +2 -1
- package/esm2020/lib/services/crop.service.mjs +24 -7
- package/esm2020/public-api.mjs +2 -6
- package/fesm2015/ngx-image-cropper.mjs +59 -17
- package/fesm2015/ngx-image-cropper.mjs.map +1 -1
- package/fesm2020/ngx-image-cropper.mjs +60 -16
- package/fesm2020/ngx-image-cropper.mjs.map +1 -1
- package/index.d.ts +6 -0
- package/lib/component/image-cropper.component.d.ts +3 -1
- package/lib/interfaces/image-transform.interface.d.ts +1 -0
- package/lib/interfaces/move-start.interface.d.ts +3 -0
- package/lib/services/crop.service.d.ts +2 -0
- package/package.json +2 -1
- package/public-api.d.ts +1 -5
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ Add the element to your HTML:
|
|
|
55
55
|
|
|
56
56
|
And add this to your ts file:
|
|
57
57
|
```
|
|
58
|
-
import { ImageCroppedEvent } from 'ngx-image-cropper';
|
|
58
|
+
import { ImageCroppedEvent, LoadedImage } from 'ngx-image-cropper';
|
|
59
59
|
|
|
60
60
|
export class YourComponent {
|
|
61
61
|
imageChangedEvent: any = '';
|
|
@@ -85,36 +85,37 @@ Everytime you release the mouse, the `imageCropped` event will be triggered with
|
|
|
85
85
|
## API
|
|
86
86
|
All inputs are optional. Either the `imageChangedEvent`, `imageBase64` or `imageFile` should be set to load an image into the cropper.
|
|
87
87
|
### Inputs
|
|
88
|
-
| Name | Type
|
|
89
|
-
| --------------------------
|
|
90
|
-
| `imageChangedEvent` | FileEvent
|
|
91
|
-
| `imageFile` | Blob(File)| | The file you want to change (set to `null` to reset the cropper)
|
|
92
|
-
| `imageBase64` | string
|
|
93
|
-
| `imageURL` | string
|
|
94
|
-
| `format` | string
|
|
95
|
-
| `aspectRatio` | number
|
|
96
|
-
| `maintainAspectRatio` | boolean
|
|
97
|
-
| `containWithinAspectRatio` | boolean
|
|
98
|
-
| `resizeToWidth` | number
|
|
99
|
-
| `resizeToHeight` | number
|
|
100
|
-
| `cropperStaticWidth` | number
|
|
101
|
-
| `cropperStaticHeight` | number
|
|
102
|
-
| `cropperMinWidth` | number
|
|
103
|
-
| `cropperMinHeight` | number
|
|
104
|
-
| `cropperMaxWidth` | number
|
|
105
|
-
| `cropperMaxHeight` | number
|
|
106
|
-
| `initialStepSize` | number
|
|
107
|
-
| `onlyScaleDown` | boolean
|
|
108
|
-
| `cropper` | CropperPosition
|
|
109
|
-
| `roundCropper` | boolean
|
|
110
|
-
| `imageQuality` | number
|
|
111
|
-
| `autoCrop` | boolean
|
|
112
|
-
| `alignImage` | 'left' or 'center' | 'center'
|
|
113
|
-
| `backgroundColor` | string
|
|
114
|
-
| `hideResizeSquares` | boolean
|
|
115
|
-
| `disabled` | boolean
|
|
116
|
-
| `canvasRotation` | number
|
|
117
|
-
| `transform` | ImageTransform
|
|
88
|
+
| Name | Type | Default | Description |
|
|
89
|
+
| -------------------------- |--------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
90
|
+
| `imageChangedEvent` | FileEvent | | The change event from your file input (set to `null` to reset the cropper) |
|
|
91
|
+
| `imageFile` | Blob(File) | | The file you want to change (set to `null` to reset the cropper) |
|
|
92
|
+
| `imageBase64` | string | | If you don't want to use a file input, you can set a base64 image directly and it will be loaded into the cropper |
|
|
93
|
+
| `imageURL` | string | | If you don't want to use a file input or a base64 you can set an URL to get the image from. If requesting an image from a different domain make sure Cross-Origin Resource Sharing (CORS) is allowed or the image will fail to load. |
|
|
94
|
+
| `format` | string | png | Output format (png, jpeg, webp, bmp, ico) (not all browsers support all types, png is always supported, others are optional) |
|
|
95
|
+
| `aspectRatio` | number | 1 / 1 | The width / height ratio (e.g. 1 / 1 for a square, 4 / 3, 16 / 9 ...) |
|
|
96
|
+
| `maintainAspectRatio` | boolean | true | Keep width and height of cropped image equal according to the aspectRatio |
|
|
97
|
+
| `containWithinAspectRatio` | boolean | false | When set to true, padding will be added around the image to make it fit to the aspect ratio |
|
|
98
|
+
| `resizeToWidth` | number | 0 (disabled) | Cropped image will be resized to at most this width (in px) |
|
|
99
|
+
| `resizeToHeight` | number | 0 (disabled) | Cropped image will be resized to at most this height (in px) |
|
|
100
|
+
| `cropperStaticWidth` | number | 0 (disabled) | Set Cropper Width and disable resize (in px) |
|
|
101
|
+
| `cropperStaticHeight` | number | 0 (disabled) | Set Cropper Height and disable resize (in px) |
|
|
102
|
+
| `cropperMinWidth` | number | 0 (disabled) | The cropper cannot be made smaller than this number of pixels in width (relative to original image's size) (in px) |
|
|
103
|
+
| `cropperMinHeight` | number | 0 (disabled) | The cropper cannot be made smaller than this number of pixels in height (relative to original image's size) (in px) (will be ignored if `maintainAspectRatio` is set) |
|
|
104
|
+
| `cropperMaxWidth` | number | 0 (disabled) | The cropper cannot be made bigger than this number of pixels in width (in px) |
|
|
105
|
+
| `cropperMaxHeight` | number | 0 (disabled) | The cropper cannot be made bigger than this number of pixels in height (in px) |
|
|
106
|
+
| `initialStepSize` | number | 3 (px) | The initial step size in pixels when moving the cropper using the keyboard. Step size can then be changed by using the numpad when the cropper is focused |
|
|
107
|
+
| `onlyScaleDown` | boolean | false | When the `resizeToWidth` or `resizeToHeight` is set, enabling this option will make sure smaller images are not scaled up |
|
|
108
|
+
| `cropper` | CropperPosition | | To be able to overwrite the cropper coordinates, you can use this input. Create a new object of type `CropperPosition` and assign it to this input. Make sure to create a new object each time you wish to overwrite the cropper's position and wait for the `cropperReady` event to have fired. |
|
|
109
|
+
| `roundCropper` | boolean | false | Set this to true for a round cropper. Resulting image will still be square, use `border-radius: 100%` on resulting image to show it as round. |
|
|
110
|
+
| `imageQuality` | number | 92 | This only applies when using jpeg or webp as output format. Entering a number between 0 and 100 will determine the quality of the output image. |
|
|
111
|
+
| `autoCrop` | boolean | true | When set to true, the cropper will emit an image each time the position or size of the cropper is changed. When set to false, you can call the crop method yourself (use @ViewChild to get access to the croppers methods). |
|
|
112
|
+
| `alignImage` | 'left' or 'center' | 'center' | Use this to align the image in the cropper either to the left or center. |
|
|
113
|
+
| `backgroundColor` | string | | Use this to set a backgroundColor, this is useful if you upload an image of a format with transparent colors and convert it to 'jpeg' or 'bmp'. The transparent pixels will then become the set color or the default value. Enter any string representing a CSS color (https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). |
|
|
114
|
+
| `hideResizeSquares` | boolean | false | Disables the resize-squares at the border of the cropper. This is mostly useful for Touch Devices where you can change the Size of the Cropper via Pinch-To-Zoom |
|
|
115
|
+
| `disabled` | boolean | false | Disables the component and prevents changing the cropper position |
|
|
116
|
+
| `canvasRotation` | number | 0 | Rotate the canvas (1 = 90deg, 2 = 180deg...) |
|
|
117
|
+
| `transform` | ImageTransform | {} | Flip, rotate and scale image |
|
|
118
|
+
| `allowMoveImage` | boolean | false | Allow background image to be moved |
|
|
118
119
|
|
|
119
120
|
### CSS Variables
|
|
120
121
|
| Name | Type | Default | Description |
|
|
@@ -148,24 +149,25 @@ To gain access to the image cropper's methods use `@ViewChild(ImageCropperCompon
|
|
|
148
149
|
| y2 | number | Y position of second coordinate (in px) |
|
|
149
150
|
|
|
150
151
|
#### ImageTransform
|
|
151
|
-
| Property | Type | Description
|
|
152
|
-
|
|
153
|
-
| scale | number | Scale image (1=normal, 2=2x zoom...)
|
|
154
|
-
| rotate | number | Rotation in degrees
|
|
155
|
-
| flipH | boolean | Flipped horizontally
|
|
156
|
-
| flipV | boolean | Flipped vertically
|
|
157
|
-
| translateH | number | Move horizontally (in %)
|
|
158
|
-
| translateV | number | Moved vertically (in %)
|
|
152
|
+
| Property | Type | Description |
|
|
153
|
+
|---------------|----------|---------------------------------------------------------|
|
|
154
|
+
| scale | number | Scale image (1=normal, 2=2x zoom...) |
|
|
155
|
+
| rotate | number | Rotation in degrees |
|
|
156
|
+
| flipH | boolean | Flipped horizontally |
|
|
157
|
+
| flipV | boolean | Flipped vertically |
|
|
158
|
+
| translateH | number | Move horizontally (in %) |
|
|
159
|
+
| translateV | number | Moved vertically (in %) |
|
|
160
|
+
| translateUnit | number | The unit used for the translate (% or px) (default = %) |
|
|
159
161
|
|
|
160
162
|
#### ImageCroppedEvent
|
|
161
|
-
| Property
|
|
162
|
-
|
|
163
|
-
| base64
|
|
164
|
-
| width
|
|
165
|
-
| height
|
|
166
|
-
| cropperPosition
|
|
167
|
-
| imagePosition
|
|
168
|
-
| offsetImagePosition
|
|
163
|
+
| Property | Type | Description |
|
|
164
|
+
|---------------------| ------ | ----------- |
|
|
165
|
+
| base64 | string | Base64 string of the cropped image |
|
|
166
|
+
| width | number | Width of the cropped image |
|
|
167
|
+
| height | number | Height of the cropped image |
|
|
168
|
+
| cropperPosition | CropperPosition | Position of the cropper when it was cropped relative to the displayed image size |
|
|
169
|
+
| imagePosition | CropperPosition | Position of the cropper when it was cropped relative to the original image size |
|
|
170
|
+
| offsetImagePosition | CropperPosition | Position of the cropper when it was cropped relative to the original image size without padding when containWithinAspectRatio is true |
|
|
169
171
|
|
|
170
172
|
#### LoadedImage
|
|
171
173
|
| Property | Type | Description |
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './lib/component/image-cropper.component';
|
|
2
|
+
export * from './lib/services/crop.service';
|
|
3
|
+
export * from './lib/image-cropper.module';
|
|
4
|
+
export * from './lib/interfaces';
|
|
5
|
+
export { base64ToFile } from './lib/utils/blob.utils';
|
|
6
|
+
export { resizeCanvas } from './lib/utils/resize.utils';
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9wcm9qZWN0cy9uZ3gtaW1hZ2UtY3JvcHBlci9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyx5Q0FBeUMsQ0FBQztBQUN4RCxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMsNEJBQTRCLENBQUM7QUFDM0MsY0FBYyxrQkFBa0IsQ0FBQztBQUNqQyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDdEQsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDBCQUEwQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9saWIvY29tcG9uZW50L2ltYWdlLWNyb3BwZXIuY29tcG9uZW50JztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3NlcnZpY2VzL2Nyb3Auc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9pbWFnZS1jcm9wcGVyLm1vZHVsZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9pbnRlcmZhY2VzJztcbmV4cG9ydCB7IGJhc2U2NFRvRmlsZSB9IGZyb20gJy4vbGliL3V0aWxzL2Jsb2IudXRpbHMnO1xuZXhwb3J0IHsgcmVzaXplQ2FudmFzIH0gZnJvbSAnLi9saWIvdXRpbHMvcmVzaXplLnV0aWxzJztcbiJdfQ==
|