@guajiritos/image-picker 0.0.5 → 0.0.7
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 +140 -140
- package/esm2022/lib/guachos-image-picker.component.mjs +517 -0
- package/{esm2020 → esm2022}/public-api.mjs +1 -1
- package/esm2022/utils/pipes/calculate-size/calculate-size.pipe.mjs +24 -0
- package/esm2022/utils/pipes/i18n/i18n.pipe.mjs +56 -0
- package/esm2022/utils/pipes/pipes.module.mjs +17 -0
- package/fesm2022/guajiritos-image-picker.mjs +614 -0
- package/fesm2022/guajiritos-image-picker.mjs.map +1 -0
- package/lib/guachos-image-picker.component.d.ts +23 -24
- package/package.json +14 -17
- package/theme.scss +66 -0
- package/utils/pipes/i18n/i18n.pipe.d.ts +9 -0
- package/utils/pipes/pipes.module.d.ts +8 -0
- package/esm2020/lib/guachos-image-picker.component.mjs +0 -548
- package/esm2020/utils/calculate-size.module.mjs +0 -16
- package/esm2020/utils/calculate-size.pipe.mjs +0 -24
- package/fesm2015/guajiritos-image-picker.mjs +0 -614
- package/fesm2015/guajiritos-image-picker.mjs.map +0 -1
- package/fesm2020/guajiritos-image-picker.mjs +0 -592
- package/fesm2020/guajiritos-image-picker.mjs.map +0 -1
- package/utils/calculate-size.module.d.ts +0 -7
- /package/{esm2020 → esm2022}/guajiritos-image-picker.mjs +0 -0
- /package/utils/{calculate-size.pipe.d.ts → pipes/calculate-size/calculate-size.pipe.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
<
|
|
108
|
-
<
|
|
109
|
-
<
|
|
110
|
-
<
|
|
111
|
-
<
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
# Guachos Image Picker
|
|
2
|
+
|
|
3
|
+
Angular library based on angular material components for the selection, edition and compression of images in png, jpeg, webp formats
|
|
4
|
+
This library was generated with Angular CLI version 13.1.3, and support until angular version 10.0.2 to the latest version of angular.
|
|
5
|
+
|
|
6
|
+
### Description
|
|
7
|
+
|
|
8
|
+
In many projects it is of interest to upload and edit images, and sometimes we have to consult other programs for the compression of images and the change of format to improve the performance of the page. With `GuachosImagePicker` this is possible in real time with for each image that you want to upload.
|
|
9
|
+
|
|
10
|
+
### Installation
|
|
11
|
+
|
|
12
|
+
Using `npm`
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm i guachos-image-picker --save
|
|
16
|
+
```
|
|
17
|
+
Using `yarn`
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
yarn add guachos-image-picker
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`GuachosImagePicker` requires [Angular Material](https://material.angular.io/guide/getting-started/).
|
|
24
|
+
version 10.0.1 or higher
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
ng add @angular/material
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Importing the BrowserAnimationsModule into your application enables Angular's animation system. Declining this will disable most of Angular Material's animations.
|
|
31
|
+
|
|
32
|
+
### External Resource
|
|
33
|
+
|
|
34
|
+
`GuachosImagePicker` use `resize-observer`, for the functionality of cropping images. The resize observer api is used
|
|
35
|
+
the resize observer interface reports changes to the dimensions of an Element's content or border box, or the bounding box of an SVGElement.
|
|
36
|
+
Install the package
|
|
37
|
+
|
|
38
|
+
Using `npm`
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm i resize-observer --save
|
|
42
|
+
```
|
|
43
|
+
Using `yarn`
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
yarn add resize-observer
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Usages
|
|
50
|
+
|
|
51
|
+
You must import the module `GuachosImagePicker` where you will use it and use the component
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { GuachosImagePickerModule } from 'guachos-image-picker';
|
|
55
|
+
|
|
56
|
+
@NgModule({
|
|
57
|
+
imports: [
|
|
58
|
+
GuachosImagePickerModule
|
|
59
|
+
],
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
In your component:
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<guachos-image-picker [_config]="imagePickerConf" ($imageChanged)="onImageChange($event)"></guachos-image-picker>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
In .ts file
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
export class ExampleComponent {
|
|
73
|
+
imagePickerConf: ImagePickerConf = {
|
|
74
|
+
borderRadius: '4px',
|
|
75
|
+
language: 'en',
|
|
76
|
+
width: '320px',
|
|
77
|
+
height: '240px',
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Here is an example with different configurations
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
export class ExampleComponent {
|
|
86
|
+
config1: ImagePickerConf = {
|
|
87
|
+
borderRadius: '16px',
|
|
88
|
+
language: 'en',
|
|
89
|
+
};
|
|
90
|
+
config2: ImagePickerConf = {
|
|
91
|
+
borderRadius: '50%',
|
|
92
|
+
language: 'es',
|
|
93
|
+
width: '200px',
|
|
94
|
+
height: '200px',
|
|
95
|
+
};
|
|
96
|
+
config3: ImagePickerConf = {
|
|
97
|
+
borderRadius: '4px',
|
|
98
|
+
language: 'en',
|
|
99
|
+
};
|
|
100
|
+
initialImage = 'https://havanatursa.com/assets/images/multi-agencies/backgrounds/slider.jpg';
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<h2>Basic usage</h2>
|
|
106
|
+
<guachos-image-picker [_config]="config1"></guachos-image-picker>
|
|
107
|
+
<br />
|
|
108
|
+
<h2>Custom config</h2>
|
|
109
|
+
<guachos-image-picker [_config]="config2"></guachos-image-picker>
|
|
110
|
+
<br />
|
|
111
|
+
<h2>Initial Image</h2>
|
|
112
|
+
<guachos-image-picker [_imageSrc]="initialImage" ($imageChanged)="onImageChanged($event)" [_config]="config3"> </guachos-image-picker>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### More about the component
|
|
116
|
+
|
|
117
|
+
The `GuachosImagePicker` component has a setting to change the width and length of the loaded image. In addition to the language (only 'es' and 'en'). It also has an initial compression option that by default is true. The interface looks like this:
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
export interface ImagePickerConf {
|
|
121
|
+
width?: string;
|
|
122
|
+
height?: string;
|
|
123
|
+
borderRadius?: string;
|
|
124
|
+
compressInitial?: boolean;
|
|
125
|
+
language?: string;
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Editing panel
|
|
130
|
+
|
|
131
|
+
Once you have selected an image, three buttons are enabled below the image:
|
|
132
|
+
```text
|
|
133
|
+
1- Load a new image.
|
|
134
|
+
2- Open the editing panel.
|
|
135
|
+
3- DOWNLOAD.
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
In the edit panel, you can change the quality ratio to compress the file size (in kb). Also changing width and height in px keeping aspect ratio or not, is selectable. You can change the image format as you wish, the options are 'png', 'webp','jpeg'. The 'Png' format is not affected by changing the quality ratio.
|
|
140
|
+
|