Skip to content
This repository was archived by the owner on May 28, 2026. It is now read-only.
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
4 changes: 4 additions & 0 deletions public/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@
"languages": ["mn"],
"title": "Монгол / Mongolian / Cyrl / Supports handwriting"
},
"mnp": {
"languages": ["mnp"],
"title": "Mìng-dĕ̤ng-ngỳ̄ / Northern Min / Latn / Supports handwriting"
},
"moh": {
"languages": ["moh"],
"title": "Kanienʼkéha / Mohawk / Latn / Mapped / Supports handwriting"
Expand Down
15 changes: 11 additions & 4 deletions src/Engine/GoogleCloudVisionEngine.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
declare( strict_types = 1 );
declare( strict_types=1 );

namespace App\Engine;

Expand Down Expand Up @@ -68,17 +68,24 @@ public function getResult(

$image = $this->getImage( $imageUrl, $crop );
$imageUrlOrData = $image->hasData() ? $image->getData() : $image->getUrl();
$response = $this->imageAnnotator->textDetection( $imageUrlOrData, [ 'imageContext' => $imageContext ] );
$response = $this->imageAnnotator->documentTextDetection(
$imageUrlOrData,
[ 'imageContext' => $imageContext ]
);

// Re-try with direct upload if the error returned is something similar to
// "The URL does not appear to be accessible by us. Please double check or download the content and pass it in."
// There doesn't seem to be a specific error code for this (it is usually 3, but that's also used for other
// things), so it seems like we have to check the actual message string.
if ( $response->getError()
if (
$response->getError()
&& stripos( $response->getError()->getMessage(), 'download the content and pass it in' ) !== false
) {
$image = $this->getImage( $imageUrl, $crop, self::DO_DOWNLOAD_IMAGE );
$response = $this->imageAnnotator->textDetection( $image->getData(), [ 'imageContext' => $imageContext ] );
$response = $this->imageAnnotator->documentTextDetection(
$image->getData(),
[ 'imageContext' => $imageContext ]
);
}

// Other errors, report to the user.
Expand Down
Loading