cozy-ui 105.2.1 → 105.3.1
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [105.3.1](https://github.com/cozy/cozy-ui/compare/v105.3.0...v105.3.1) (2024-03-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Argos screenshots could not be validated ([4cc3a0d](https://github.com/cozy/cozy-ui/commit/4cc3a0d))
|
|
7
|
+
|
|
8
|
+
# [105.3.0](https://github.com/cozy/cozy-ui/compare/v105.2.1...v105.3.0) (2024-03-27)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **resizeImage:** Reduce quality for big image ([2b6cacf](https://github.com/cozy/cozy-ui/commit/2b6cacf))
|
|
14
|
+
|
|
1
15
|
## [105.2.1](https://github.com/cozy/cozy-ui/compare/v105.2.0...v105.2.1) (2024-03-26)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { fetchBlobFileById } from 'cozy-client/dist/models/file'
|
|
|
3
3
|
|
|
4
4
|
// Should guarantee good resolution for different uses (printing, downloading, etc.)
|
|
5
5
|
const MAX_RESIZE_IMAGE_SIZE = 3840
|
|
6
|
+
const MAX_IMAGE_SIDE_SIZE = 1920
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Make array of actions and hydrate actions with options
|
|
@@ -125,6 +126,11 @@ const resizeImage = async ({
|
|
|
125
126
|
const scaleRatio = getImageScaleRatio(newImage, maxSize)
|
|
126
127
|
const scaledWidth = scaleRatio * newImage.width
|
|
127
128
|
const scaledHeight = scaleRatio * newImage.height
|
|
129
|
+
const quality =
|
|
130
|
+
scaledWidth >= MAX_IMAGE_SIDE_SIZE ||
|
|
131
|
+
scaledHeight >= MAX_IMAGE_SIDE_SIZE
|
|
132
|
+
? 0.35
|
|
133
|
+
: 0.75
|
|
128
134
|
|
|
129
135
|
canvas.width = scaledWidth
|
|
130
136
|
canvas.height = scaledHeight
|
|
@@ -132,7 +138,7 @@ const resizeImage = async ({
|
|
|
132
138
|
.getContext('2d')
|
|
133
139
|
.drawImage(newImage, 0, 0, scaledWidth, scaledHeight)
|
|
134
140
|
|
|
135
|
-
resolve(canvas.toDataURL(fileType))
|
|
141
|
+
resolve(canvas.toDataURL(fileType, quality))
|
|
136
142
|
}
|
|
137
143
|
})
|
|
138
144
|
}
|
|
@@ -12,6 +12,7 @@ import { PDFDocument } from 'pdf-lib';
|
|
|
12
12
|
import { fetchBlobFileById } from 'cozy-client/dist/models/file'; // Should guarantee good resolution for different uses (printing, downloading, etc.)
|
|
13
13
|
|
|
14
14
|
var MAX_RESIZE_IMAGE_SIZE = 3840;
|
|
15
|
+
var MAX_IMAGE_SIDE_SIZE = 1920;
|
|
15
16
|
/**
|
|
16
17
|
* Make array of actions and hydrate actions with options
|
|
17
18
|
*
|
|
@@ -143,10 +144,11 @@ var resizeImage = /*#__PURE__*/function () {
|
|
|
143
144
|
var scaleRatio = getImageScaleRatio(newImage, maxSize);
|
|
144
145
|
var scaledWidth = scaleRatio * newImage.width;
|
|
145
146
|
var scaledHeight = scaleRatio * newImage.height;
|
|
147
|
+
var quality = scaledWidth >= MAX_IMAGE_SIDE_SIZE || scaledHeight >= MAX_IMAGE_SIDE_SIZE ? 0.35 : 0.75;
|
|
146
148
|
canvas.width = scaledWidth;
|
|
147
149
|
canvas.height = scaledHeight;
|
|
148
150
|
canvas.getContext('2d').drawImage(newImage, 0, 0, scaledWidth, scaledHeight);
|
|
149
|
-
resolve(canvas.toDataURL(fileType));
|
|
151
|
+
resolve(canvas.toDataURL(fileType, quality));
|
|
150
152
|
};
|
|
151
153
|
}));
|
|
152
154
|
|