refactor: replace image-size with image-meta (#4767)

Image-size is barely supported, works only in node.js.

Image-meta is a fork from unjs community, without dependencies, can work
in browsers, we already use it inside of ipx.
This commit is contained in:
Bogdan Chadkin authored and GitHub committed 2025-01-23 12:33:38 +07:00
1 parent 8f3592d594
commit ac90f03a09
3 files changed
+60 -68

No files matched your search

+2 -2
View File
@@ -11,12 +11,12 @@
},
"dependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"@smithy/signature-v4": "^4.2.3",
"@smithy/signature-v4": "^5.0.1",
"@webstudio-is/fonts": "workspace:*",
"@webstudio-is/sdk": "workspace:*",
"@webstudio-is/trpc-interface": "workspace:*",
"fontkit": "^2.0.4",
"image-size": "^1.1.1",
"image-meta": "^0.2.1",
"immer": "^10.1.1",
"nanoid": "^5.0.9",
"warn-once": "^0.1.1"
@@ -1,5 +1,5 @@
import { z } from "zod";
import { imageSize } from "image-size";
import { imageMeta } from "image-meta";
import { FontMeta } from "@webstudio-is/fonts";
import { ImageMeta } from "@webstudio-is/sdk";
import { getFontData } from "./font-data";
@@ -34,7 +34,7 @@ export const getAssetData = async (
if (options.type === "image") {
let image: undefined | { format: string; width: number; height: number };
try {
const parsed = imageSize(Buffer.from(options.data));
const parsed = imageMeta(Buffer.from(options.data));
if (parsed.type && parsed.width && parsed.height) {
image = {
format: parsed.type,
+56 -64
View File
@@ -1041,8 +1041,8 @@ importers:
specifier: ^5.2.0
version: 5.2.0
'@smithy/signature-v4':
specifier: ^4.2.3
version: 4.2.3
specifier: ^5.0.1
version: 5.0.1
'@webstudio-is/fonts':
specifier: workspace:*
version: link:../fonts
@@ -1055,9 +1055,9 @@ importers:
fontkit:
specifier: ^2.0.4
version: 2.0.4
image-size:
specifier: ^1.1.1
version: 1.1.1
image-meta:
specifier: ^0.2.1
version: 0.2.1
immer:
specifier: ^10.1.1
version: 10.1.1
@@ -4885,49 +4885,53 @@ packages:
resolution: {integrity: sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==}
engines: {node: '>=14.0.0'}
'@smithy/is-array-buffer@3.0.0':
resolution: {integrity: sha512-+Fsu6Q6C4RSJiy81Y8eApjEB5gVtM+oFKTffg+jSuwtvomJJrhUJBu2zS8wjXSgH/g1MKEWrzyChTBe6clb5FQ==}
engines: {node: '>=16.0.0'}
'@smithy/is-array-buffer@4.0.0':
resolution: {integrity: sha512-saYhF8ZZNoJDTvJBEWgeBccCg+yvp1CX+ed12yORU3NilJScfc6gfch2oVb4QgxZrGUx3/ZJlb+c/dJbyupxlw==}
engines: {node: '>=18.0.0'}
'@smithy/protocol-http@4.1.7':
resolution: {integrity: sha512-FP2LepWD0eJeOTm0SjssPcgqAlDFzOmRXqXmGhfIM52G7Lrox/pcpQf6RP4F21k0+O12zaqQt5fCDOeBtqY6Cg==}
engines: {node: '>=16.0.0'}
'@smithy/protocol-http@5.0.1':
resolution: {integrity: sha512-TE4cpj49jJNB/oHyh/cRVEgNZaoPaxd4vteJNB0yGidOCVR0jCw/hjPVsT8Q8FRmj8Bd3bFZt8Dh7xGCT+xMBQ==}
engines: {node: '>=18.0.0'}
'@smithy/signature-v4@4.2.3':
resolution: {integrity: sha512-pPSQQ2v2vu9vc8iew7sszLd0O09I5TRc5zhY71KA+Ao0xYazIG+uLeHbTJfIWGO3BGVLiXjUr3EEeCcEQLjpWQ==}
engines: {node: '>=16.0.0'}
'@smithy/signature-v4@5.0.1':
resolution: {integrity: sha512-nCe6fQ+ppm1bQuw5iKoeJ0MJfz2os7Ic3GBjOkLOPtavbD1ONoyE3ygjBfz2ythFWm4YnRm6OxW+8p/m9uCoIA==}
engines: {node: '>=18.0.0'}
'@smithy/types@3.7.1':
resolution: {integrity: sha512-XKLcLXZY7sUQgvvWyeaL/qwNPp6V3dWcUjqrQKjSb+tzYiCy340R/c64LV5j+Tnb2GhmunEX0eou+L+m2hJNYA==}
engines: {node: '>=16.0.0'}
'@smithy/types@4.1.0':
resolution: {integrity: sha512-enhjdwp4D7CXmwLtD6zbcDMbo6/T6WtuuKCY49Xxc6OMOmUWlBEBDREsxxgV2LIdeQPW756+f97GzcgAwp3iLw==}
engines: {node: '>=18.0.0'}
'@smithy/util-buffer-from@2.2.0':
resolution: {integrity: sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==}
engines: {node: '>=14.0.0'}
'@smithy/util-buffer-from@3.0.0':
resolution: {integrity: sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA==}
engines: {node: '>=16.0.0'}
'@smithy/util-buffer-from@4.0.0':
resolution: {integrity: sha512-9TOQ7781sZvddgO8nxueKi3+yGvkY35kotA0Y6BWRajAv8jjmigQ1sBwz0UX47pQMYXJPahSKEKYFgt+rXdcug==}
engines: {node: '>=18.0.0'}
'@smithy/util-hex-encoding@3.0.0':
resolution: {integrity: sha512-eFndh1WEK5YMUYvy3lPlVmYY/fZcQE1D8oSf41Id2vCeIkKJXPcYDCZD+4+xViI6b1XSd7tE+s5AmXzz5ilabQ==}
engines: {node: '>=16.0.0'}
'@smithy/util-hex-encoding@4.0.0':
resolution: {integrity: sha512-Yk5mLhHtfIgW2W2WQZWSg5kuMZCVbvhFmC7rV4IO2QqnZdbEFPmQnCcGMAX2z/8Qj3B9hYYNjZOhWym+RwhePw==}
engines: {node: '>=18.0.0'}
'@smithy/util-middleware@3.0.10':
resolution: {integrity: sha512-eJO+/+RsrG2RpmY68jZdwQtnfsxjmPxzMlQpnHKjFPwrYqvlcT+fHdT+ZVwcjlWSrByOhGr9Ff2GG17efc192A==}
engines: {node: '>=16.0.0'}
'@smithy/util-middleware@4.0.1':
resolution: {integrity: sha512-HiLAvlcqhbzhuiOa0Lyct5IIlyIz0PQO5dnMlmQ/ubYM46dPInB+3yQGkfxsk6Q24Y0n3/JmcA1v5iEhmOF5mA==}
engines: {node: '>=18.0.0'}
'@smithy/util-uri-escape@3.0.0':
resolution: {integrity: sha512-LqR7qYLgZTD7nWLBecUi4aqolw8Mhza9ArpNEQ881MJJIU2sE5iHCK6TdyqqzcDLy0OPe10IY4T8ctVdtynubg==}
engines: {node: '>=16.0.0'}
'@smithy/util-uri-escape@4.0.0':
resolution: {integrity: sha512-77yfbCbQMtgtTylO9itEAdpPXSog3ZxMe09AEhm0dU0NLTalV70ghDZFR+Nfi1C60jnJoh/Re4090/DuZh2Omg==}
engines: {node: '>=18.0.0'}
'@smithy/util-utf8@2.3.0':
resolution: {integrity: sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==}
engines: {node: '>=14.0.0'}
'@smithy/util-utf8@3.0.0':
resolution: {integrity: sha512-rUeT12bxFnplYDe815GXbq/oixEGHfRFFtcTF3YdDi/JaENIM6aSYYLJydG83UNzLXeRI5K8abYd/8Sp/QM0kA==}
engines: {node: '>=16.0.0'}
'@smithy/util-utf8@4.0.0':
resolution: {integrity: sha512-b+zebfKCfRdgNJDknHCob3O7FpeYQN6ZG6YLExMcasDHsCXlsXCEuiPZeLnJLpwa5dvPetGlnGCiMHuLwGvFow==}
engines: {node: '>=18.0.0'}
'@stitches/react@1.3.1-1':
resolution: {integrity: sha512-ErptbQehV25Da6LtZuM/51kGNK/UvlRY2da9IhhfXQ9h4bmf2f+lYFiJQ9j43O1kwYr6iYJIBRM47FEbsUWffw==}
@@ -6695,11 +6699,6 @@ packages:
image-meta@0.2.1:
resolution: {integrity: sha512-K6acvFaelNxx8wc2VjbIzXKDVB0Khs0QT35U6NkGfTdCmjLNcO2945m7RFNR9/RPVFm48hq7QPzK8uGH18HCGw==}
image-size@1.1.1:
resolution: {integrity: sha512-541xKlUw6jr/6gGuk92F+mYM5zaFAc5ahphvkqvNe2bQ6gVBkd6bfrmVJ2t4KDAfikAYZyIqTnktX3i6/aQDrQ==}
engines: {node: '>=16.x'}
hasBin: true
immer@10.1.1:
resolution: {integrity: sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==}
@@ -8040,9 +8039,6 @@ packages:
queue-microtask@1.2.3:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
queue@6.0.2:
resolution: {integrity: sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==}
radix3@1.1.2:
resolution: {integrity: sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==}
@@ -12004,50 +12000,54 @@ snapshots:
dependencies:
tslib: 2.8.1
'@smithy/is-array-buffer@3.0.0':
'@smithy/is-array-buffer@4.0.0':
dependencies:
tslib: 2.8.1
'@smithy/protocol-http@4.1.7':
'@smithy/protocol-http@5.0.1':
dependencies:
'@smithy/types': 3.7.1
'@smithy/types': 4.1.0
tslib: 2.8.1
'@smithy/signature-v4@4.2.3':
'@smithy/signature-v4@5.0.1':
dependencies:
'@smithy/is-array-buffer': 3.0.0
'@smithy/protocol-http': 4.1.7
'@smithy/types': 3.7.1
'@smithy/util-hex-encoding': 3.0.0
'@smithy/util-middleware': 3.0.10
'@smithy/util-uri-escape': 3.0.0
'@smithy/util-utf8': 3.0.0
'@smithy/is-array-buffer': 4.0.0
'@smithy/protocol-http': 5.0.1
'@smithy/types': 4.1.0
'@smithy/util-hex-encoding': 4.0.0
'@smithy/util-middleware': 4.0.1
'@smithy/util-uri-escape': 4.0.0
'@smithy/util-utf8': 4.0.0
tslib: 2.8.1
'@smithy/types@3.7.1':
dependencies:
tslib: 2.8.1
'@smithy/types@4.1.0':
dependencies:
tslib: 2.8.1
'@smithy/util-buffer-from@2.2.0':
dependencies:
'@smithy/is-array-buffer': 2.2.0
tslib: 2.8.1
'@smithy/util-buffer-from@3.0.0':
'@smithy/util-buffer-from@4.0.0':
dependencies:
'@smithy/is-array-buffer': 3.0.0
'@smithy/is-array-buffer': 4.0.0
tslib: 2.8.1
'@smithy/util-hex-encoding@3.0.0':
'@smithy/util-hex-encoding@4.0.0':
dependencies:
tslib: 2.8.1
'@smithy/util-middleware@3.0.10':
'@smithy/util-middleware@4.0.1':
dependencies:
'@smithy/types': 3.7.1
'@smithy/types': 4.1.0
tslib: 2.8.1
'@smithy/util-uri-escape@3.0.0':
'@smithy/util-uri-escape@4.0.0':
dependencies:
tslib: 2.8.1
@@ -12056,9 +12056,9 @@ snapshots:
'@smithy/util-buffer-from': 2.2.0
tslib: 2.8.1
'@smithy/util-utf8@3.0.0':
'@smithy/util-utf8@4.0.0':
dependencies:
'@smithy/util-buffer-from': 3.0.0
'@smithy/util-buffer-from': 4.0.0
tslib: 2.8.1
'@stitches/react@1.3.1-1(patch_hash=knml42mpr6mlzseo3d6gjljiq4)(react@18.3.0-canary-14898b6a9-20240318)':
@@ -14242,10 +14242,6 @@ snapshots:
image-meta@0.2.1: {}
image-size@1.1.1:
dependencies:
queue: 6.0.2
immer@10.1.1: {}
immerhin@0.10.0:
@@ -15946,10 +15942,6 @@ snapshots:
queue-microtask@1.2.3: {}
queue@6.0.2:
dependencies:
inherits: 2.0.4
radix3@1.1.2: {}
raf-schd@4.0.3: {}