Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downscale image further for platerecognizer ALPR if needed #569

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

josephfrazier
Copy link
Owner

A user found an image that, despite already being less than 4096 pixels
wide, remained larger than the maximum filesize accepted by
platerecognizer, even after being downscaled.

This change makes it so that we scale it further down to 2048 pixels
wide if it's still too big after being scaled to 4096.

See here for more context:
https://reportedcab.slack.com/archives/C7Z0BHMMY/p1734719601962699?thread_ts=1733722096.369269&cid=C7Z0BHMMY:

just tried that one locally, and it looks like the image is too big
for the ALPR API, even after the webapp downscales it. Guess I need to
tweak that to squeeze it down further, yet again...

image buffer length BEFORE sharp: 4855730 bytes
image buffer length AFTER sharp: 2589893 bytes
orientImageBuffer: 187.262ms
file size is greater than maximum of 2411654 bytes, attempting to scale down to width of 4096
file size after scaling down: 2426287 bytes
STARTING platerecognizer
/platerecognizer plate-reader got an error with first token, trying second
/platerecognizer plate-reader {
  platerecognizerRes: Response {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: false, error: null },
    [Symbol(Response internals)]: {
      url: 'https://api.platerecognizer.com/v1/plate-reader/',
      status: 413,
      statusText: 'Request Entity Too Large',
      headers: [Headers],
      counter: 0
    }
  }
}

A user found an image that, despite already being less than 4096 pixels
wide, remained larger than the maximum filesize accepted by
platerecognizer, even after being downscaled.

This change makes it so that we scale it further down to 2048 pixels
wide if it's still too big after being scaled to 4096.

See here for more context:
https://reportedcab.slack.com/archives/C7Z0BHMMY/p1734719601962699?thread_ts=1733722096.369269&cid=C7Z0BHMMY:

> just tried that one locally, and it looks like the image is too big
> for the ALPR API, even after the webapp downscales it. Guess I need to
> tweak that to squeeze it down further, yet again...
>
>     image buffer length BEFORE sharp: 4855730 bytes
>     image buffer length AFTER sharp: 2589893 bytes
>     orientImageBuffer: 187.262ms
>     file size is greater than maximum of 2411654 bytes, attempting to scale down to width of 4096
>     file size after scaling down: 2426287 bytes
>     STARTING platerecognizer
>     /platerecognizer plate-reader got an error with first token, trying second
>     /platerecognizer plate-reader {
>       platerecognizerRes: Response {
>         size: 0,
>         timeout: 0,
>         [Symbol(Body internals)]: { body: [PassThrough], disturbed: false, error: null },
>         [Symbol(Response internals)]: {
>           url: 'https://api.platerecognizer.com/v1/plate-reader/',
>           status: 413,
>           statusText: 'Request Entity Too Large',
>           headers: [Headers],
>           counter: 0
>         }
>       }
>     }
@josephfrazier josephfrazier marked this pull request as ready for review December 20, 2024 19:17
@josephfrazier josephfrazier enabled auto-merge (squash) December 20, 2024 19:17
@josephfrazier josephfrazier temporarily deployed to reported-web-redownscal-bri9ex December 20, 2024 19:17 Inactive
@josephfrazier josephfrazier merged commit 59e46cb into main Dec 20, 2024
5 checks passed
@josephfrazier josephfrazier deleted the redownscale.for.platerecognizer branch December 20, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant