From 308bad797278ed1ba79102a4115d36ff53c4207a Mon Sep 17 00:00:00 2001 From: sksadjad Date: Thu, 8 Feb 2024 22:57:26 +0100 Subject: [PATCH] fix: changed image-size library version to a react friendly one --- packages/ssi-sdk-core/package.json | 2 +- packages/ssi-sdk-core/src/utils/image.ts | 14 ++++++++++---- pnpm-lock.yaml | 11 +++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/ssi-sdk-core/package.json b/packages/ssi-sdk-core/package.json index 5056341dc..a44a8b7c0 100644 --- a/packages/ssi-sdk-core/package.json +++ b/packages/ssi-sdk-core/package.json @@ -13,7 +13,7 @@ "@veramo/core": "4.2.0", "cross-fetch": "^3.1.8", "debug": "^4.3.4", - "image-size": "^1.0.2", + "image-size": "^2.0.0-beta.2", "uint8arrays": "3.1.1" }, "devDependencies": { diff --git a/packages/ssi-sdk-core/src/utils/image.ts b/packages/ssi-sdk-core/src/utils/image.ts index c9760ddb9..8ca322a39 100644 --- a/packages/ssi-sdk-core/src/utils/image.ts +++ b/packages/ssi-sdk-core/src/utils/image.ts @@ -1,11 +1,17 @@ import fetch from 'cross-fetch' -import sizeOf from 'image-size' -import { ISizeCalculationResult } from 'image-size/dist/types/interface' +import {imageSize} from 'image-size' import { IImageDimensions, IImageResource } from '../types' +type SizeCalculationResult = { + width: number | undefined + height: number | undefined + orientation?: number + type?: string +} + export const getImageMediaType = async (base64: string): Promise => { const buffer: Buffer = Buffer.from(base64, 'base64') - const result: ISizeCalculationResult = sizeOf(buffer) + const result: SizeCalculationResult = imageSize(buffer) switch (result.type) { case undefined: @@ -19,7 +25,7 @@ export const getImageMediaType = async (base64: string): Promise => { const buffer: Buffer = Buffer.from(base64, 'base64') - const dimensions: ISizeCalculationResult = sizeOf(buffer) + const dimensions: SizeCalculationResult = imageSize(buffer) if (!dimensions.width || !dimensions.height) { return Promise.reject(Error('Unable to get image dimensions')) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7f89a328d..e635fe876 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1554,8 +1554,8 @@ importers: specifier: ^4.3.4 version: 4.3.4 image-size: - specifier: ^1.0.2 - version: 1.0.2 + specifier: ^2.0.0-beta.2 + version: 2.0.0-beta.2 uint8arrays: specifier: 3.1.1 version: 3.1.1 @@ -12352,6 +12352,7 @@ packages: dependencies: is-hex-prefixed: 1.0.0 strip-hex-prefix: 1.0.0 + bundledDependencies: false /ethr-did-resolver@8.1.2: resolution: {integrity: sha512-dnbE3GItE1YHp/eavR11KbGDi8Il01H9GeH+wKgoSgE95pKBZufHyHYce/EK2k8VOmj6MJf8u/TIpPvxjCbK+A==} @@ -13792,6 +13793,12 @@ packages: dependencies: queue: 6.0.2 + /image-size@2.0.0-beta.2: + resolution: {integrity: sha512-1nDNnVxJixMWBynFgQ1q8+aVqK60TiNHpMyFAXt9xpzGZV+2lHI1IXjgdcAjBxPc4nx2ed1NdYs2I+Zfq+Zn7w==} + engines: {node: '>=18.18.0'} + hasBin: true + dev: false + /import-fresh@2.0.0: resolution: {integrity: sha512-eZ5H8rcgYazHbKC3PG4ClHNykCSxtAhxSSEM+2mb+7evD2CKF5V7c0dNum7AdpDh0ZdICwZY9sRSn8f+KH96sg==} engines: {node: '>=4'}