/usr/share/pyshared/textile/tools/imagesize.py is in python-textile 1:2.1.5-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | def getimagesize(url):
"""
Attempts to determine an image's width and height, and returns a string
suitable for use in an <img> tag, or an empty string in case of failure.
Requires that PIL is installed.
>>> getimagesize("http://www.google.com/intl/en_ALL/images/logo.gif")
... #doctest: +ELLIPSIS
'width="..." height="..."'
>>> getimagesize("http://bad.domain/")
''
"""
try:
import ImageFile
import urllib2
except ImportError:
return ''
try:
p = ImageFile.Parser()
f = urllib2.urlopen(url)
while True:
s = f.read(1024)
if not s:
break
p.feed(s)
if p.image:
return 'width="%i" height="%i"' % p.image.size
except (IOError, ValueError):
return ''
def setup_module(module):
from nose.plugins.skip import SkipTest
try:
import ImageFile
except ImportError:
raise SkipTest()
|