Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@
<!--- Why is this change required? What problem does it solve? -->


## Related Issue
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->


## How Has This Been Tested
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->


## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up php ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3

- name: Install phpdocumentor
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ["7.4"]
php-version: ["8.1"]
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_test-code-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
max-parallel: 2
matrix:
php-version:
- "7.4"
- "8.3"
- "8.1"
- "8.4"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
max-parallel: 2
matrix:
php-version:
- 7.4
- 8.3
- 8.1
- 8.4
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -59,8 +59,8 @@ jobs:
# max-parallel: 2
# matrix:
# php-version:
# - 7.4
# - 8.3
# - 8.1
# - 8.4
# runs-on: "macos-latest"
# steps:
# - uses: actions/checkout@v4
Expand Down Expand Up @@ -90,8 +90,8 @@ jobs:
max-parallel: 2
matrix:
php-version:
- 7.4
- 8.3
- 8.1
- 8.4
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v4
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
Expand All @@ -37,11 +36,10 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -74,11 +72,10 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4
runs-on: "macos-latest"
steps:
- uses: actions/checkout@v4
Expand All @@ -104,11 +101,10 @@ jobs:
# strategy:
# matrix:
# php-version:
# - 7.4
# - 8.0
# - 8.1
# - 8.2
# - 8.3
# - 8.4
# runs-on: "macos-latest"
# steps:
# - uses: actions/checkout@v4
Expand Down Expand Up @@ -146,11 +142,10 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v4
Expand All @@ -176,22 +171,21 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Ghostscript
run: choco install ghostscript --version 10.03.1 -y
run: choco install ghostscript --version 10.04.0 -y
- name: Create Ghostscript alias
run: |
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs.exe" -Target "C:\Program Files\gs\gs10.03.1\bin\gswin64c.exe"
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs" -Target "C:\Program Files\gs\gs10.03.1\bin\gswin64c.exe"
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs.exe" -Target "C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe"
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs" -Target "C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe"
shell: powershell
- name: Set up php ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
Expand Down
3 changes: 1 addition & 2 deletions bin/MindeeCLICommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ private function handleCustomOrGeneratedProduct(
PredictMethodOptions $predictMethodOptions,
string $product
): bool {
if (in_array($product, ["custom", "generated"])) {
if ($product == "generated") {
$accountName = $input->getOption('account_name');
$endpointName = $input->getOption('endpoint_name');
$endpointVersion = $input->getOption('endpoint_version') ?? '1';
Expand All @@ -459,7 +459,6 @@ private function handleCustomOrGeneratedProduct(
"<comment>No version provided for \"$endpointName\", version 1 will be used by default.</comment>"
);
}

$endpoint = $client->createEndpoint($endpointName, $accountName, $endpointVersion);
$predictMethodOptions->setEndpoint($endpoint);
}
Expand Down
6 changes: 0 additions & 6 deletions bin/MindeeCLIDocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public static function getSpecs(): array
false,
true
),
"custom" => new DocumentCommandConfig(
"Custom document type from API builder",
\Mindee\Product\Custom\CustomV1::class,
true,
false
),
"barcode-reader" => new DocumentCommandConfig(
"Barcode Reader",
\Mindee\Product\BarcodeReader\BarcodeReaderV1::class,
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=7.4",
"php": ">=8.1",
"ext-curl": "*",
"ext-fileinfo": "*",
"ext-json": "*",
"symfony/console": ">=5.4",
"symfony/console": ">=6.0",
"setasign/fpdf": "^1.8",
"setasign/fpdi": "^2.6",
"smalot/pdfparser": "^2.11"
"smalot/pdfparser": "^2.12"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.38",
"squizlabs/php_codesniffer": "^3.7",
"phpunit/phpunit": "^9.6",
"madewithlove/license-checker": "^0.10.0"
"madewithlove/license-checker": "^v1.0"
},
"suggest": {
"ext-imagick": "Required for PDF rasterization and image processing features",
Expand Down
6 changes: 6 additions & 0 deletions docs/code_samples/custom_v1.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

//
// DEPRECATED API
// Support removed in version 2.0 of the Mindee PHP library.
// Use only with version 1.x of the library.
//

use Mindee\Client;
use Mindee\Product\Custom\CustomV1;
use Mindee\Input\PredictMethodOptions;
Expand Down
8 changes: 4 additions & 4 deletions docs/code_samples/default_v2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ $inferenceParams = new InferenceParameters(
// Options: set to `true` or `false` to override defaults

// Enhance extraction accuracy with Retrieval-Augmented Generation.
false,
rag: null,
// Extract the full text content from the document as strings.
false,
rawText: null,
// Calculate bounding box polygons for all fields.
false,
polygon: null,
// Boost the precision and accuracy of all extractions.
// Calculate confidence scores for all fields.
false
confidence: null
);

// Load a file from disk
Expand Down
28 changes: 21 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ public function __construct(?string $apiKey = null)
*/
public function sourceFromPath(string $filePath, bool $fixPDF = false): PathInput
{
return new PathInput($filePath, $fixPDF);
$input = new PathInput($filePath);
if ($fixPDF) {
$input->fixPDF();
}
return $input;
}

/**
Expand All @@ -83,9 +87,13 @@ public function sourceFromPath(string $filePath, bool $fixPDF = false): PathInpu
* @param boolean $fixPDF Whether the PDF should be fixed or not.
* @return FileInput
*/
public function sourceFromFile($file, bool $fixPDF = false): FileInput
public function sourceFromFile(mixed $file, bool $fixPDF = false): FileInput
{
return new FileInput($file, $fixPDF);
$input = new FileInput($file);
if ($fixPDF) {
$input->fixPDF();
}
return $input;
}

/**
Expand All @@ -98,7 +106,11 @@ public function sourceFromFile($file, bool $fixPDF = false): FileInput
*/
public function sourceFromBytes(string $fileBytes, string $fileName, bool $fixPDF = false): BytesInput
{
return new BytesInput($fileBytes, $fileName, $fixPDF);
$input = new BytesInput($fileBytes, $fileName);
if ($fixPDF) {
$input->fixPDF();
}
return $input;
}

/**
Expand All @@ -111,7 +123,11 @@ public function sourceFromBytes(string $fileBytes, string $fileName, bool $fixPD
*/
public function sourceFromB64String(string $fileB64, string $fileName, bool $fixPDF = false): Base64Input
{
return new Base64Input($fileB64, $fileName, $fixPDF);
$input = new Base64Input($fileB64, $fileName);
if ($fixPDF) {
$input->fixPDF();
}
return $input;
}

/**
Expand Down Expand Up @@ -515,7 +531,6 @@ public function parseQueued(
return $this->makeParseQueuedRequest($predictionType, $queueId, $endpoint);
}


/**
* @param string $predictionType Name of the product's class.
* @param LocalResponse $localResponse Local response to load.
Expand All @@ -540,7 +555,6 @@ public function loadPrediction(
}
}


/**
* Sends a document to a workflow.
*
Expand Down
21 changes: 8 additions & 13 deletions src/Extraction/ExtractedImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ExtractedImage
* @param string $saveFormat The format to save the image.
* @throws MindeeUnhandledException Throws if PDF operations aren't supported.
*/
public function __construct($image, string $filename, string $saveFormat)
public function __construct(mixed $image, string $filename, string $saveFormat)
{
DependencyChecker::isImageMagickAvailable();
DependencyChecker::isGhostscriptAvailable();
Expand Down Expand Up @@ -86,17 +86,12 @@ public function asInputSource(): BytesInput
*/
private function getEncodedImageFormat(string $saveFormat): string
{
switch (strtolower($saveFormat)) {
case 'png':
return 'png';
case 'bmp':
return 'bmp';
case 'gif':
return 'gif';
case 'webp':
return 'webp';
default:
return 'jpeg';
}
return match (strtolower($saveFormat)) {
'png' => 'png',
'bmp', => 'bmp',
'gif' => 'gif',
'webp' => 'webp',
default => 'jpeg',
};
}
}
2 changes: 0 additions & 2 deletions src/Extraction/PdfExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ public function extractInvoices($pageIndexes, bool $strict = false): array
$previousConfidence = $confidence;
$i++;
}


return $this->extractSubDocuments($correctPageIndexes);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Geometry/BBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public function getMaxY(): float
/**
* Extends the BBox with the provided points.
*
* @param Polygon|array $points Series of points to add to the BBox.
* @param array|Polygon $points Series of points to add to the BBox.
* @return void
*/
public function extendWith($points)
public function extendWith(Polygon|array $points): void
{
if ($points instanceof Polygon) {
$sequence = $points->getCoordinates();
Expand Down
Loading
Loading