repo.or.cz
/
fdr-django.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Updated ez_setup.py from 0.6a7 to 0.6a9
[fdr-django.git]
/
django
/
utils
/
images.py
blob
122c6ae233aba90d7cd454053aa3fc353a31cdfb
1
"""
2
Utility functions for handling images.
3
4
Requires PIL, as you might imagine.
5
"""
6
7
import
ImageFile
8
9
def
get_image_dimensions
(
path
):
10
"""Returns the (width, height) of an image at a given path."""
11
p
=
ImageFile
.
Parser
()
12
fp
=
open
(
path
,
'rb'
)
13
while
1
:
14
data
=
fp
.
read
(
1024
)
15
if not
data
:
16
break
17
p
.
feed
(
data
)
18
if
p
.
image
:
19
return
p
.
image
.
size
20
break
21
fp
.
close
()
22
return None