UNPKG

mindee

Version:

Mindee Client Library for Node.js

24 lines (23 loc) 1.05 kB
import { FieldLocation } from "../../../v2/parsing/inference/field/index.js"; import { extractSingleCrop } from "../../../v2/fileOperations/crop.js"; import { ExtractionResponse } from "../../../v2/product/index.js"; export class CropItem { constructor(serverResponse) { this.objectType = serverResponse["object_type"]; this.location = new FieldLocation(serverResponse["location"]); this.extractionResponse = serverResponse["extraction_response"] ? new ExtractionResponse(serverResponse["extraction_response"]) : undefined; } toString() { return `* :Location: ${this.location}\n :Object Type: ${this.objectType}`; } /** * Extracts a single crop from an input. * @param inputSource The input file to extract from. * @param quality Optional quality parameter for image extraction, default is undefined (full quality). */ async extractFromInputSource(inputSource, quality = 1) { return (await extractSingleCrop(inputSource, this, quality)); } }