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

Use early return in downscaleForPlateRecognizer #570

Merged
merged 3 commits into from
Dec 20, 2024

Conversation

josephfrazier
Copy link
Owner

This makes it easier for me to read.

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
>         }
>       }
>     }
This makes it easier for me to read.
@josephfrazier josephfrazier temporarily deployed to reported-web-downscalef-y8k5lh December 20, 2024 19:25 Inactive
@josephfrazier josephfrazier marked this pull request as ready for review December 20, 2024 19:25
@josephfrazier josephfrazier enabled auto-merge (squash) December 20, 2024 19:25
@josephfrazier josephfrazier merged commit 2626f75 into main Dec 20, 2024
5 checks passed
@josephfrazier josephfrazier deleted the downscaleForPlateRecognizer.return.early branch December 20, 2024 19:26
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