X7ROOT File Manager
Current Path:
/usr/share/doc/python-docs-2.7.5/html/library
usr
/
share
/
doc
/
python-docs-2.7.5
/
html
/
library
/
π
..
π
2to3.html
(49.27 KB)
π
__builtin__.html
(10.26 KB)
π
__future__.html
(13.79 KB)
π
__main__.html
(7.05 KB)
π
_winreg.html
(59.21 KB)
π
abc.html
(23.9 KB)
π
aepack.html
(13.16 KB)
π
aetools.html
(14.91 KB)
π
aetypes.html
(18.88 KB)
π
aifc.html
(22.4 KB)
π
al.html
(17.34 KB)
π
allos.html
(33.72 KB)
π
anydbm.html
(16.33 KB)
π
archiving.html
(9.26 KB)
π
argparse.html
(237.62 KB)
π
array.html
(29.29 KB)
π
ast.html
(34.98 KB)
π
asynchat.html
(31.43 KB)
π
asyncore.html
(36.51 KB)
π
atexit.html
(16.8 KB)
π
audioop.html
(31.36 KB)
π
autogil.html
(8.19 KB)
π
base64.html
(19.67 KB)
π
basehttpserver.html
(34.04 KB)
π
bastion.html
(11.04 KB)
π
bdb.html
(36.68 KB)
π
binascii.html
(20.67 KB)
π
binhex.html
(10.58 KB)
π
bisect.html
(23.24 KB)
π
bsddb.html
(26.43 KB)
π
bz2.html
(26.08 KB)
π
calendar.html
(37.79 KB)
π
carbon.html
(48.94 KB)
π
cd.html
(27.96 KB)
π
cgi.html
(49.92 KB)
π
cgihttpserver.html
(13.1 KB)
π
cgitb.html
(11.41 KB)
π
chunk.html
(14.66 KB)
π
cmath.html
(25.63 KB)
π
cmd.html
(26.09 KB)
π
code.html
(24.58 KB)
π
codecs.html
(100.64 KB)
π
codeop.html
(14.84 KB)
π
collections.html
(133.96 KB)
π
colorpicker.html
(7.52 KB)
π
colorsys.html
(11.04 KB)
π
commands.html
(14.36 KB)
π
compileall.html
(16.83 KB)
π
compiler.html
(67.75 KB)
π
configparser.html
(62.13 KB)
π
constants.html
(12.83 KB)
π
contextlib.html
(19.39 KB)
π
cookie.html
(39.07 KB)
π
cookielib.html
(83.82 KB)
π
copy.html
(12.19 KB)
π
copy_reg.html
(13.76 KB)
π
crypt.html
(10.04 KB)
π
crypto.html
(7.59 KB)
π
csv.html
(67.37 KB)
π
ctypes.html
(238.78 KB)
π
curses.ascii.html
(22.29 KB)
π
curses.html
(146.63 KB)
π
curses.panel.html
(14.39 KB)
π
custominterp.html
(7.62 KB)
π
datatypes.html
(16.84 KB)
π
datetime.html
(226.59 KB)
π
dbhash.html
(15.48 KB)
π
dbm.html
(12.07 KB)
π
debug.html
(10.15 KB)
π
decimal.html
(194.44 KB)
π
development.html
(14.17 KB)
π
difflib.html
(84.83 KB)
π
dircache.html
(11.41 KB)
π
dis.html
(69.95 KB)
π
distutils.html
(8.05 KB)
π
dl.html
(16.33 KB)
π
doctest.html
(165.54 KB)
π
docxmlrpcserver.html
(16.43 KB)
π
dumbdbm.html
(14.02 KB)
π
dummy_thread.html
(9.43 KB)
π
dummy_threading.html
(8.37 KB)
π
easydialogs.html
(30.55 KB)
π
email-examples.html
(45.65 KB)
π
email.charset.html
(26.8 KB)
π
email.encoders.html
(11.86 KB)
π
email.errors.html
(15.77 KB)
π
email.generator.html
(20.77 KB)
π
email.header.html
(26.92 KB)
π
email.html
(44.24 KB)
π
email.iterators.html
(11.52 KB)
π
email.message.html
(63.16 KB)
π
email.mime.html
(27.93 KB)
π
email.parser.html
(30.45 KB)
π
email.util.html
(24.46 KB)
π
errno.html
(37.99 KB)
π
exceptions.html
(56.13 KB)
π
fcntl.html
(22.67 KB)
π
filecmp.html
(22.3 KB)
π
fileformats.html
(9.14 KB)
π
fileinput.html
(24.28 KB)
π
filesys.html
(10.2 KB)
π
fl.html
(49.92 KB)
π
fm.html
(11.91 KB)
π
fnmatch.html
(14.58 KB)
π
formatter.html
(34.06 KB)
π
fpectl.html
(16.01 KB)
π
fpformat.html
(10.59 KB)
π
fractions.html
(22.61 KB)
π
framework.html
(33.34 KB)
π
frameworks.html
(7.14 KB)
π
ftplib.html
(43.99 KB)
π
functions.html
(183.14 KB)
π
functools.html
(27.17 KB)
π
future_builtins.html
(13.04 KB)
π
gc.html
(25.75 KB)
π
gdbm.html
(15.96 KB)
π
gensuitemodule.html
(11.51 KB)
π
getopt.html
(23.66 KB)
π
getpass.html
(10.65 KB)
π
gettext.html
(78.76 KB)
π
gl.html
(22.09 KB)
π
glob.html
(13.26 KB)
π
grp.html
(10.49 KB)
π
gzip.html
(18.99 KB)
π
hashlib.html
(18.2 KB)
π
heapq.html
(31.61 KB)
π
hmac.html
(10.46 KB)
π
hotshot.html
(18.65 KB)
π
htmllib.html
(25.32 KB)
π
htmlparser.html
(39.11 KB)
π
httplib.html
(62.95 KB)
π
i18n.html
(9.52 KB)
π
ic.html
(17.17 KB)
π
idle.html
(20.9 KB)
π
imageop.html
(14.76 KB)
π
imaplib.html
(51.99 KB)
π
imgfile.html
(11.71 KB)
π
imghdr.html
(11.3 KB)
π
imp.html
(34.34 KB)
π
importlib.html
(8.26 KB)
π
imputil.html
(31.81 KB)
π
index.html
(72.78 KB)
π
inspect.html
(50.71 KB)
π
internet.html
(24.87 KB)
π
intro.html
(8.93 KB)
π
io.html
(98.13 KB)
π
ipc.html
(13.41 KB)
π
itertools.html
(115.91 KB)
π
jpeg.html
(12.74 KB)
π
json.html
(67.04 KB)
π
keyword.html
(7.68 KB)
π
language.html
(11.03 KB)
π
linecache.html
(10.59 KB)
π
locale.html
(55.14 KB)
π
logging.config.html
(63.36 KB)
π
logging.handlers.html
(69.64 KB)
π
logging.html
(95.64 KB)
π
mac.html
(21.79 KB)
π
macos.html
(14.76 KB)
π
macosa.html
(12.96 KB)
π
macostools.html
(15.52 KB)
π
macpath.html
(7.76 KB)
π
mailbox.html
(156.75 KB)
π
mailcap.html
(13.21 KB)
π
markup.html
(18.77 KB)
π
marshal.html
(17.98 KB)
π
math.html
(39.24 KB)
π
md5.html
(13.97 KB)
π
mhlib.html
(21.54 KB)
π
mimetools.html
(19.25 KB)
π
mimetypes.html
(28.39 KB)
π
mimewriter.html
(15.02 KB)
π
mimify.html
(13.36 KB)
π
miniaeframe.html
(12.2 KB)
π
misc.html
(6.87 KB)
π
mm.html
(9.03 KB)
π
mmap.html
(28.36 KB)
π
modulefinder.html
(15.31 KB)
π
modules.html
(8.46 KB)
π
msilib.html
(52.43 KB)
π
msvcrt.html
(19.37 KB)
π
multifile.html
(24.3 KB)
π
multiprocessing.html
(365.71 KB)
π
mutex.html
(11.23 KB)
π
netdata.html
(16.98 KB)
π
netrc.html
(12.3 KB)
π
new.html
(12.12 KB)
π
nis.html
(10.64 KB)
π
nntplib.html
(41.92 KB)
π
numbers.html
(37.75 KB)
π
numeric.html
(13.55 KB)
π
operator.html
(82 KB)
π
optparse.html
(222.56 KB)
π
os.html
(214.25 KB)
π
os.path.html
(38.34 KB)
π
ossaudiodev.html
(41.5 KB)
π
othergui.html
(9.08 KB)
π
parser.html
(39.36 KB)
π
pdb.html
(33.96 KB)
π
persistence.html
(14.87 KB)
π
pickle.html
(102.27 KB)
π
pickletools.html
(10.63 KB)
π
pipes.html
(18.01 KB)
π
pkgutil.html
(25.11 KB)
π
platform.html
(28.37 KB)
π
plistlib.html
(17.03 KB)
π
popen2.html
(25.43 KB)
π
poplib.html
(22.32 KB)
π
posix.html
(14.41 KB)
π
posixfile.html
(19.76 KB)
π
pprint.html
(29.92 KB)
π
profile.html
(63.56 KB)
π
pty.html
(9.48 KB)
π
pwd.html
(11.43 KB)
π
py_compile.html
(11.12 KB)
π
pyclbr.html
(14.71 KB)
π
pydoc.html
(11.48 KB)
π
pyexpat.html
(71.53 KB)
π
python.html
(12.27 KB)
π
queue.html
(24.22 KB)
π
quopri.html
(11.9 KB)
π
random.html
(37.83 KB)
π
re.html
(134.74 KB)
π
readline.html
(28.24 KB)
π
repr.html
(20.43 KB)
π
resource.html
(26.48 KB)
π
restricted.html
(11.65 KB)
π
rexec.html
(37.41 KB)
π
rfc822.html
(42.22 KB)
π
rlcompleter.html
(13.51 KB)
π
robotparser.html
(12.27 KB)
π
runpy.html
(19.34 KB)
π
sched.html
(18.54 KB)
π
scrolledtext.html
(9.32 KB)
π
select.html
(39.67 KB)
π
sets.html
(36.92 KB)
π
sgi.html
(9.71 KB)
π
sgmllib.html
(30.77 KB)
π
sha.html
(12.09 KB)
π
shelve.html
(27.02 KB)
π
shlex.html
(32.1 KB)
π
shutil.html
(40.22 KB)
π
signal.html
(31.14 KB)
π
simplehttpserver.html
(18.41 KB)
π
simplexmlrpcserver.html
(31.39 KB)
π
site.html
(23.64 KB)
π
smtpd.html
(12.46 KB)
π
smtplib.html
(42.13 KB)
π
sndhdr.html
(10.02 KB)
π
socket.html
(106.34 KB)
π
socketserver.html
(59.83 KB)
π
someos.html
(15.11 KB)
π
spwd.html
(10.33 KB)
π
sqlite3.html
(139.5 KB)
π
ssl.html
(65.62 KB)
π
stat.html
(32.31 KB)
π
statvfs.html
(10.6 KB)
π
stdtypes.html
(260.4 KB)
π
string.html
(106.65 KB)
π
stringio.html
(18.81 KB)
π
stringprep.html
(16.13 KB)
π
strings.html
(14.93 KB)
π
struct.html
(40.88 KB)
π
subprocess.html
(84.91 KB)
π
sun.html
(6.84 KB)
π
sunau.html
(27.1 KB)
π
sunaudio.html
(17.79 KB)
π
symbol.html
(7.66 KB)
π
symtable.html
(22.94 KB)
π
sys.html
(98.7 KB)
π
sysconfig.html
(23.84 KB)
π
syslog.html
(17.92 KB)
π
tabnanny.html
(10.63 KB)
π
tarfile.html
(78.68 KB)
π
telnetlib.html
(25.48 KB)
π
tempfile.html
(29.42 KB)
π
termios.html
(16.01 KB)
π
test.html
(52.62 KB)
π
textwrap.html
(27.25 KB)
π
thread.html
(20.47 KB)
π
threading.html
(76.69 KB)
π
time.html
(56.93 KB)
π
timeit.html
(36.27 KB)
π
tix.html
(46.96 KB)
π
tk.html
(23.64 KB)
π
tkinter.html
(67.67 KB)
π
token.html
(19.62 KB)
π
tokenize.html
(18.45 KB)
π
trace.html
(25.54 KB)
π
traceback.html
(33.44 KB)
π
ttk.html
(101.75 KB)
π
tty.html
(9.06 KB)
π
turtle.html
(211.74 KB)
π
types.html
(27.59 KB)
π
undoc.html
(23.16 KB)
π
unicodedata.html
(18.55 KB)
π
unittest.html
(202.85 KB)
π
unix.html
(10.55 KB)
π
urllib.html
(58.68 KB)
π
urllib2.html
(100.58 KB)
π
urlparse.html
(40.41 KB)
π
user.html
(11.83 KB)
π
userdict.html
(29.73 KB)
π
uu.html
(11.03 KB)
π
uuid.html
(28.19 KB)
π
warnings.html
(46.6 KB)
π
wave.html
(22.22 KB)
π
weakref.html
(36.52 KB)
π
webbrowser.html
(23.07 KB)
π
whichdb.html
(8.85 KB)
π
windows.html
(9.33 KB)
π
winsound.html
(18.75 KB)
π
wsgiref.html
(81.04 KB)
π
xdrlib.html
(29.94 KB)
π
xml.dom.html
(89.04 KB)
π
xml.dom.minidom.html
(40.42 KB)
π
xml.dom.pulldom.html
(12.71 KB)
π
xml.etree.elementtree.html
(93.22 KB)
π
xml.html
(16.49 KB)
π
xml.sax.handler.html
(38.63 KB)
π
xml.sax.html
(20.22 KB)
π
xml.sax.reader.html
(39.09 KB)
π
xml.sax.utils.html
(14.26 KB)
π
xmlrpclib.html
(60.79 KB)
π
zipfile.html
(53.14 KB)
π
zipimport.html
(20.42 KB)
π
zlib.html
(25.46 KB)
Editing: imghdr.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>21.8. imghdr β Determine the type of an image — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="21. Multimedia Services" href="mm.html" /> <link rel="next" title="21.9. sndhdr β Determine type of sound file" href="sndhdr.html" /> <link rel="prev" title="21.7. colorsys β Conversions between color systems" href="colorsys.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="sndhdr.html" title="21.9. sndhdr β Determine type of sound file" accesskey="N">next</a> |</li> <li class="right" > <a href="colorsys.html" title="21.7. colorsys β Conversions between color systems" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="mm.html" accesskey="U">21. Multimedia Services</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-imghdr"> <span id="imghdr-determine-the-type-of-an-image"></span><h1>21.8. <a class="reference internal" href="#module-imghdr" title="imghdr: Determine the type of image contained in a file or byte stream."><tt class="xref py py-mod docutils literal"><span class="pre">imghdr</span></tt></a> — Determine the type of an image<a class="headerlink" href="#module-imghdr" title="Permalink to this headline">ΒΆ</a></h1> <p><strong>Source code:</strong> <a class="reference external" href="http://hg.python.org/cpython/file/2.7/Lib/imghdr.py">Lib/imghdr.py</a></p> <hr class="docutils" /> <p>The <a class="reference internal" href="#module-imghdr" title="imghdr: Determine the type of image contained in a file or byte stream."><tt class="xref py py-mod docutils literal"><span class="pre">imghdr</span></tt></a> module determines the type of image contained in a file or byte stream.</p> <p>The <a class="reference internal" href="#module-imghdr" title="imghdr: Determine the type of image contained in a file or byte stream."><tt class="xref py py-mod docutils literal"><span class="pre">imghdr</span></tt></a> module defines the following function:</p> <dl class="function"> <dt id="imghdr.what"> <tt class="descclassname">imghdr.</tt><tt class="descname">what</tt><big>(</big><em>filename</em><span class="optional">[</span>, <em>h</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#imghdr.what" title="Permalink to this definition">ΒΆ</a></dt> <dd><p>Tests the image data contained in the file named by <em>filename</em>, and returns a string describing the image type. If optional <em>h</em> is provided, the <em>filename</em> is ignored and <em>h</em> is assumed to contain the byte stream to test.</p> </dd></dl> <p>The following image types are recognized, as listed below with the return value from <a class="reference internal" href="#imghdr.what" title="imghdr.what"><tt class="xref py py-func docutils literal"><span class="pre">what()</span></tt></a>:</p> <table border="1" class="docutils"> <colgroup> <col width="26%" /> <col width="74%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Value</th> <th class="head">Image format</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">'rgb'</span></tt></td> <td>SGI ImgLib Files</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'gif'</span></tt></td> <td>GIF 87a and 89a Files</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">'pbm'</span></tt></td> <td>Portable Bitmap Files</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'pgm'</span></tt></td> <td>Portable Graymap Files</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">'ppm'</span></tt></td> <td>Portable Pixmap Files</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'tiff'</span></tt></td> <td>TIFF Files</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">'rast'</span></tt></td> <td>Sun Raster Files</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'xbm'</span></tt></td> <td>X Bitmap Files</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">'jpeg'</span></tt></td> <td>JPEG data in JFIF or Exif formats</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'bmp'</span></tt></td> <td>BMP files</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">'png'</span></tt></td> <td>Portable Network Graphics</td> </tr> </tbody> </table> <p class="versionadded"> <span class="versionmodified">New in version 2.5: </span>Exif detection.</p> <p>You can extend the list of file types <a class="reference internal" href="#module-imghdr" title="imghdr: Determine the type of image contained in a file or byte stream."><tt class="xref py py-mod docutils literal"><span class="pre">imghdr</span></tt></a> can recognize by appending to this variable:</p> <dl class="data"> <dt id="imghdr.tests"> <tt class="descclassname">imghdr.</tt><tt class="descname">tests</tt><a class="headerlink" href="#imghdr.tests" title="Permalink to this definition">ΒΆ</a></dt> <dd><p>A list of functions performing the individual tests. Each function takes two arguments: the byte-stream and an open file-like object. When <a class="reference internal" href="#imghdr.what" title="imghdr.what"><tt class="xref py py-func docutils literal"><span class="pre">what()</span></tt></a> is called with a byte-stream, the file-like object will be <tt class="docutils literal"><span class="pre">None</span></tt>.</p> <p>The test function should return a string describing the image type if the test succeeded, or <tt class="docutils literal"><span class="pre">None</span></tt> if it failed.</p> </dd></dl> <p>Example:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">imghdr</span> <span class="gp">>>> </span><span class="n">imghdr</span><span class="o">.</span><span class="n">what</span><span class="p">(</span><span class="s">'bass.gif'</span><span class="p">)</span> <span class="go">'gif'</span> </pre></div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="colorsys.html" title="previous chapter">21.7. <tt class="docutils literal"><span class="pre">colorsys</span></tt> — Conversions between color systems</a></p> <h4>Next topic</h4> <p class="topless"><a href="sndhdr.html" title="next chapter">21.9. <tt class="docutils literal"><span class="pre">sndhdr</span></tt> — Determine type of sound file</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/imghdr.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="sndhdr.html" title="21.9. sndhdr β Determine type of sound file" >next</a> |</li> <li class="right" > <a href="colorsys.html" title="21.7. colorsys β Conversions between color systems" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="mm.html" >21. Multimedia Services</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2020, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Oct 13, 2020. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>
Upload File
Create Folder