Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #74 from regulaforensics/stable
Browse files Browse the repository at this point in the history
Stable
  • Loading branch information
aliaksandr-drozd authored Jul 15, 2024
2 parents df88127 + 49972cc commit 13371e8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.73",
"version": "0.0.74",
"author": "Regula Forensics, Inc.",
"name": "@regulaforensics/document-reader-recipes",
"description": "Document Reader Recipes",
Expand All @@ -10,7 +10,7 @@
"test": "jest"
},
"peerDependencies": {
"@regulaforensics/document-reader-typings": ">=0.0.32",
"@regulaforensics/document-reader-typings": ">=0.0.33",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"reflect-metadata": "^0.2.2",
Expand Down
10 changes: 7 additions & 3 deletions src/recipes/image/document-images/get-document-images.recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ export const getDocumentImages = async (
index = result.push(current) - 1
}

const src = `data:image/jpeg;base64,${value}`
const dimensions = await getImageDimensions(src)
const src = value ? `data:image/jpeg;base64,${value}` : undefined
let dimensions = { width: 0, height: 0 }

if (src) {
dimensions = await getImageDimensions(src)
}

const current = new RDocumentImagePage()
current.pageIndex = pageIndex
Expand Down Expand Up @@ -125,7 +129,7 @@ export const getDocumentImagesSync = (
index = result.push(current) - 1
}

const src = `data:image/jpeg;base64,${value}`
const src = value ? `data:image/jpeg;base64,${value}` : undefined

const current = new RDocumentImagePage()
current.pageIndex = pageIndex
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsDefined, IsEnum, IsInt, IsString } from 'class-validator'
import { IsDefined, IsEnum, IsInt, IsOptional, IsString } from 'class-validator'
import { eSource } from '@regulaforensics/document-reader-typings'


Expand All @@ -14,9 +14,9 @@ export interface iRDocumentImagePage {

/**
* Image file in base64 url representation
* @type {string}
* @type {string|undefined}
*/
src: string
src?: string

/**
* Image width
Expand Down Expand Up @@ -51,11 +51,11 @@ export class RDocumentImagePage implements iRDocumentImagePage {

/**
* Image file in base64 url representation
* @type {string}
* @type {string|undefined}
*/
@IsDefined()
@IsOptional()
@IsString()
src: string
src?: string

/**
* Image width
Expand Down

0 comments on commit 13371e8

Please sign in to comment.