We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Asset Download:
from urllib.request import urlopen from PIL import Image def download_and_save(url, name): im = Image.open(urlopen(url)) im = im.resize((500, 293)).crop((0, 0, 500, 290)) im.save(f'{name}.png') im.save(f'{name}.jpg') download_and_save('https://www.nicepng.com/png/detail/50-503681_shaq-face-png-moniece-slaughter.png', 'shaq') download_and_save('https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/close-up-of-cat-wearing-sunglasses-while-sitting-royalty-free-image-1571755145.jpg', 'cat')
JPG works:
shaq = Image.open('shaq.jpg') cat = Image.open('cat.jpg') type(shaq) # PIL.JpegImagePlugin.JpegImageFile shaq.save( 'shaq_cat_jpg.gif', save_all=True, append_images=[cat], duration=200, loop=0 )
PNG doesn't work:
shaq = Image.open('shaq.png') cat = Image.open('cat.png') type(shaq) # PIL.PngImagePlugin.PngImageFile shaq.save( 'shaq_cat_png.gif', save_all=True, append_images=[cat], duration=200, loop=0 )
Both JPG and PNG code should run.
PNG code errors out with ValueError: read of closed file
ValueError: read of closed file
Both the PNG and JPG code run on 6.0.0 and 7.0.0, though!
The text was updated successfully, but these errors were encountered:
This is actually a duplicate of #4543.
If you're interested in workaround until #4528 is released as part of the next Pillow, you could use copy() -
copy()
from PIL import Image shaq = Image.open('shaq.png') cat = Image.open('cat.png') type(shaq) # PIL.PngImagePlugin.PngImageFile shaq.copy().save( 'shaq_cat_png.gif', save_all=True, append_images=[cat.copy()], duration=200, loop=0 )
Sorry, something went wrong.
Awesome! Looking forward to the fix and really appreciate the work around. Thanks @radarhere :)
Pillow 7.1.2 has now been released with the fix for this.
No branches or pull requests
What did you do?
Asset Download:
JPG works:
PNG doesn't work:
What did you expect to happen?
Both JPG and PNG code should run.
What actually happened?
PNG code errors out with
ValueError: read of closed file
What are your OS, Python and Pillow versions?
Both the PNG and JPG code run on 6.0.0 and 7.0.0, though!
The text was updated successfully, but these errors were encountered: