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

Fix IOError when saving progressive JPEGs. #313

Merged
merged 1 commit into from
Aug 3, 2013

Conversation

e98cuenc
Copy link
Contributor

@e98cuenc e98cuenc commented Aug 2, 2013

when the jpeg encoder sees the flags optimize or progressive (or progression)
it will write the full image in one shot.

The bufsize needs to be big enough to hold the entire image. The current heuristic
is that the entire compressed image will fit in width * height bytes, but this
heuristic is only applied to save operations with the flag "optimize" and not to
save operations with the flag "progressive".

This patch fixes this oversight.

(Btw, it will probably be a good idea to have a loop that retries with a bigger
bufsize in case this guess is not big enough.)

when the jpeg encoder sees the flags optimize or progressive (or progression)
it will write the full image in one shot.

The bufsize needs to be big enough to hold the entire image. The current heuristic
is that the entire compressed image will fit in width * height bytes, but this
heuristic is only applied to save operations with the flag "optimize" and not to
save operations with the flag "progressive".

This patch fixes this oversight.

(Btw, it will probably be a good idea to have a loop that retries with a bigger
bufsize in case this guess is not big enough.)
@aclark4life
Copy link
Member

Thanks! Let's see what @wiredfool and/or @acdha thinks

@wiredfool
Copy link
Member

Looks reasonable to me.

@acdha
Copy link
Contributor

acdha commented Aug 2, 2013

Looks good to me, too

aclark4life added a commit that referenced this pull request Aug 3, 2013
Fix IOError when saving progressive JPEGs.
@aclark4life aclark4life merged commit 845f582 into python-pillow:master Aug 3, 2013
@aclark4life
Copy link
Member

Thanks all

radarhere pushed a commit to radarhere/Pillow that referenced this pull request Sep 24, 2023
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.

4 participants