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

proposal: image/jpeg: allow images larger than 65536 #51690

Closed
alimoeeny opened this issue Mar 15, 2022 · 3 comments
Closed

proposal: image/jpeg: allow images larger than 65536 #51690

alimoeeny opened this issue Mar 15, 2022 · 3 comments

Comments

@alimoeeny
Copy link

Currently the jpeg.Encode() checks if the size of the image.Image passed to it is smaller than 1<<16 in either dimension.

We often work with images up to 1<<20 pixels wide.

Our current solution is to patch the go source code before build to remove this check.

This solution works fine on amd64, I don't know if this restriction is mean to protect systems with lower memory or is just a sanity check.

Proposal: modify the line lined below to allow images as large as 1<<21

https://cs.opensource.google/go/go/+/refs/tags/go1.18:src/image/jpeg/writer.go;drc=35cbc3b55b9d5d159a5a7a160ea680b32f043bf8;l=577

@gopherbot gopherbot added this to the Proposal milestone Mar 15, 2022
@seankhliao
Copy link
Member

cc @nigeltao

@alimoeeny
Copy link
Author

I apologize I think I need to do more investigation, it looks like there is an actual hard limit at 65536 and going beyond it will cause some sort of banding artifact.
of course if it would be possible to fix the underlying issue and make it possible to process HUGE images, that would be fantastic.
But it looks like my proposal for just increasing the limit will not work.
Although we patch the limits, I must have accidently only tested with images that are still below the threshold.

@ALTree
Copy link
Member

ALTree commented Mar 16, 2022

The jpeg standard does not allow images with dimensions bigger than 65535 pixels (the number-of-lines field in the header is 2 bytes).

@ALTree ALTree closed this as completed Mar 16, 2022
@golang golang locked and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants