#33965: Improve docs for PIL validation of ImageField
-------------------------------------+-------------------------------------
Reporter: Timothy Schilling | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.1
Severity: Normal | Resolution:
Keywords: documentation | Triage Stage:
imagefield | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Alex Morega):
FWIW, the call to `Image.new(...).save(...)` looks distracting to me, and
makes the example hard to read. PIL can read the 35-byte GIF from this
StackOverflow answer: https://stackoverflow.com/a/15960901. I think it
works better as an example because it's just a blob of binary.
{{{#!python
>>> from io import BytesIO
>>> from PIL import Image
>>> img = BytesIO(
... b'GIF89a\x01\x00\x01\x00\x00\x00\x00!\xf9\x04\x01\x00\x00\x00'
... b'\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x01\x00\x00'
... )
>>> img.name = 'myimage.gif'
>>> pil_image = Image.open(img)
>>> pil_image
<PIL.GifImagePlugin.GifImageFile image mode=L size=1x1 at 0xFFFF9392BF40>
>>> pil_image.verify()
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33965#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070182eff980f6-f729c948-ed90-4aab-a47d-eec0efd4f61c-000000%40eu-central-1.amazonses.com.