| @@ -0,0 +1,5 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| from django.core import management | ||
|
|
||
| if __name__ == "__main__": | ||
| management.execute_from_command_line() |
| @@ -0,0 +1,10 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==20.1.1','console_scripts','easy_install' | ||
| __requires__ = 'setuptools==20.1.1' | ||
| import sys | ||
| from pkg_resources import load_entry_point | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit( | ||
| load_entry_point('setuptools==20.1.1', 'console_scripts', 'easy_install')() | ||
| ) |
| @@ -0,0 +1,10 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==20.1.1','console_scripts','easy_install-2.7' | ||
| __requires__ = 'setuptools==20.1.1' | ||
| import sys | ||
| from pkg_resources import load_entry_point | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit( | ||
| load_entry_point('setuptools==20.1.1', 'console_scripts', 'easy_install-2.7')() | ||
| ) |
| @@ -0,0 +1,59 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # this demo script creates four windows containing an image and a slider. | ||
| # drag the slider to modify the image. | ||
| # | ||
|
|
||
| try: | ||
| from tkinter import Tk, Toplevel, Frame, Label, Scale, HORIZONTAL | ||
| except ImportError: | ||
| from Tkinter import Tk, Toplevel, Frame, Label, Scale, HORIZONTAL | ||
|
|
||
| from PIL import Image, ImageTk, ImageEnhance | ||
| import sys | ||
|
|
||
| # | ||
| # enhancer widget | ||
|
|
||
|
|
||
| class Enhance(Frame): | ||
| def __init__(self, master, image, name, enhancer, lo, hi): | ||
| Frame.__init__(self, master) | ||
|
|
||
| # set up the image | ||
| self.tkim = ImageTk.PhotoImage(image.mode, image.size) | ||
| self.enhancer = enhancer(image) | ||
| self.update("1.0") # normalize | ||
|
|
||
| # image window | ||
| Label(self, image=self.tkim).pack() | ||
|
|
||
| # scale | ||
| s = Scale(self, label=name, orient=HORIZONTAL, | ||
| from_=lo, to=hi, resolution=0.01, | ||
| command=self.update) | ||
| s.set(self.value) | ||
| s.pack() | ||
|
|
||
| def update(self, value): | ||
| self.value = eval(value) | ||
| self.tkim.paste(self.enhancer.enhance(self.value)) | ||
|
|
||
| # | ||
| # main | ||
|
|
||
| root = Tk() | ||
|
|
||
| im = Image.open(sys.argv[1]) | ||
|
|
||
| im.thumbnail((200, 200)) | ||
|
|
||
| Enhance(root, im, "Color", ImageEnhance.Color, 0.0, 4.0).pack() | ||
| Enhance(Toplevel(), im, "Sharpness", ImageEnhance.Sharpness, -2.0, 2.0).pack() | ||
| Enhance(Toplevel(), im, "Brightness", ImageEnhance.Brightness, -1.0, 3.0).pack() | ||
| Enhance(Toplevel(), im, "Contrast", ImageEnhance.Contrast, -1.0, 3.0).pack() | ||
|
|
||
| root.mainloop() |
| @@ -0,0 +1,112 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # split an animation into a number of frame files | ||
| # | ||
|
|
||
| from __future__ import print_function | ||
|
|
||
| from PIL import Image | ||
| import os | ||
| import sys | ||
|
|
||
|
|
||
| class Interval(object): | ||
|
|
||
| def __init__(self, interval="0"): | ||
|
|
||
| self.setinterval(interval) | ||
|
|
||
| def setinterval(self, interval): | ||
|
|
||
| self.hilo = [] | ||
|
|
||
| for s in interval.split(","): | ||
| if not s.strip(): | ||
| continue | ||
| try: | ||
| v = int(s) | ||
| if v < 0: | ||
| lo, hi = 0, -v | ||
| else: | ||
| lo = hi = v | ||
| except ValueError: | ||
| i = s.find("-") | ||
| lo, hi = int(s[:i]), int(s[i+1:]) | ||
|
|
||
| self.hilo.append((hi, lo)) | ||
|
|
||
| if not self.hilo: | ||
| self.hilo = [(sys.maxsize, 0)] | ||
|
|
||
| def __getitem__(self, index): | ||
|
|
||
| for hi, lo in self.hilo: | ||
| if hi >= index >= lo: | ||
| return 1 | ||
| return 0 | ||
|
|
||
| # -------------------------------------------------------------------- | ||
| # main program | ||
|
|
||
| html = 0 | ||
|
|
||
| if sys.argv[1:2] == ["-h"]: | ||
| html = 1 | ||
| del sys.argv[1] | ||
|
|
||
| if not sys.argv[2:]: | ||
| print() | ||
| print("Syntax: python explode.py infile template [range]") | ||
| print() | ||
| print("The template argument is used to construct the names of the") | ||
| print("individual frame files. The frames are numbered file001.ext,") | ||
| print("file002.ext, etc. You can insert %d to control the placement") | ||
| print("and syntax of the frame number.") | ||
| print() | ||
| print("The optional range argument specifies which frames to extract.") | ||
| print("You can give one or more ranges like 1-10, 5, -15 etc. If") | ||
| print("omitted, all frames are extracted.") | ||
| sys.exit(1) | ||
|
|
||
| infile = sys.argv[1] | ||
| outfile = sys.argv[2] | ||
|
|
||
| frames = Interval(",".join(sys.argv[3:])) | ||
|
|
||
| try: | ||
| # check if outfile contains a placeholder | ||
| outfile % 1 | ||
| except TypeError: | ||
| file, ext = os.path.splitext(outfile) | ||
| outfile = file + "%03d" + ext | ||
|
|
||
| ix = 1 | ||
|
|
||
| im = Image.open(infile) | ||
|
|
||
| if html: | ||
| file, ext = os.path.splitext(outfile) | ||
| html = open(file+".html", "w") | ||
| html.write("<html>\n<body>\n") | ||
|
|
||
| while True: | ||
|
|
||
| if frames[ix]: | ||
| im.save(outfile % ix) | ||
| print(outfile % ix) | ||
|
|
||
| if html: | ||
| html.write("<img src='%s'><br>\n" % outfile % ix) | ||
|
|
||
| try: | ||
| im.seek(ix) | ||
| except EOFError: | ||
| break | ||
|
|
||
| ix += 1 | ||
|
|
||
| if html: | ||
| html.write("</body>\n</html>\n") |
| @@ -0,0 +1,20 @@ | ||
| @echo off | ||
|
|
||
| SETLOCAL EnableDelayedExpansion | ||
|
|
||
| if [%1]==[] goto USAGE | ||
| goto FDEL | ||
|
|
||
| :USAGE | ||
| echo. | ||
| echo Usage: folder_delete PATTERN | ||
| echo. | ||
| goto END | ||
|
|
||
| :FDEL | ||
| for /d /r "%CD%" %%d in (%1) do @if exist "%%d" rd /s/q "%%d" | ||
| REM for /d /r %CD% %d in (.svn) do @if exist "%d" rd /s/q "%d" | ||
| REM for /d /r . %d in (%1) do @if exist "%d" rd /s/q "%d" | ||
| REM for /f "usebackq" %%d in ("dir %1 /ad/b/s") do rd /s/q "%%d" | ||
|
|
||
| :END |
| @@ -0,0 +1,31 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # convert sequence format to GIF animation | ||
| # | ||
| # history: | ||
| # 97-01-03 fl created | ||
| # | ||
| # Copyright (c) Secret Labs AB 1997. All rights reserved. | ||
| # Copyright (c) Fredrik Lundh 1997. | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
| from __future__ import print_function | ||
|
|
||
| from PIL import Image | ||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| import sys | ||
|
|
||
| if len(sys.argv) < 3: | ||
| print("GIFMAKER -- create GIF animations") | ||
| print("Usage: gifmaker infile outfile") | ||
| sys.exit(1) | ||
|
|
||
| im = Image.open(sys.argv[1]) | ||
| im.save(sys.argv[2], save_all=True) |
| @@ -0,0 +1,34 @@ | ||
| @echo off | ||
|
|
||
| if defined PYTHONHOME ( | ||
| set "PYHOME=%PYTHONHOME%" | ||
| goto MAIN | ||
| ) | ||
| if defined VIRTUAL_ENV ( | ||
| set "PYHOME=%VIRTUAL_ENV%" | ||
| goto MAIN | ||
| ) | ||
| for /f "usebackq tokens=*" %%a in (`python.exe -c "import sys;print(sys.exec_prefix)"`) do ( | ||
| set "PYHOME=%%a" | ||
| ) | ||
|
|
||
| :MAIN | ||
| echo. | ||
| echo dir /b "%PYHOME%\Lib\site-packages" | ||
| echo ============================================================================== | ||
| dir /b "%PYHOME%\Lib\site-packages" | ||
| echo. | ||
| echo %PYHOME%\Lib\site-packages\easy-install.pth | ||
| echo ============================================================================== | ||
| type "%PYHOME%\Lib\site-packages\easy-install.pth" | ||
| echo. | ||
| if exist "%PYHOME%\Lib\site-packages\virtualenv_path_extensions.pth" ( | ||
| echo %PYHOME%\Lib\site-packages\virtualenv_path_extensions.pth | ||
| echo ============================================================================== | ||
| type "%PYHOME%\Lib\site-packages\virtualenv_path_extensions.pth" | ||
| echo. | ||
| ) | ||
|
|
||
| set PYHOME= | ||
|
|
||
| :END |
| @@ -0,0 +1,14 @@ | ||
| @echo off | ||
|
|
||
| if not defined WORKON_HOME ( | ||
| set "WORKON_HOME=%USERPROFILE%\Envs" | ||
| ) | ||
|
|
||
| :LIST | ||
| echo. | ||
| echo dir /b /ad "%WORKON_HOME%" | ||
| echo ============================================================================== | ||
| dir /b /ad "%WORKON_HOME%" | ||
| echo. | ||
|
|
||
| :END |
| @@ -0,0 +1,83 @@ | ||
| @echo off | ||
|
|
||
| if [%1]==[] goto USAGE | ||
| goto MKVIRTUALENV | ||
|
|
||
| :USAGE | ||
| echo. | ||
| echo. Pass a name to create a new virtualenv | ||
| goto END | ||
|
|
||
| :MKVIRTUALENV | ||
| if not defined WORKON_HOME ( | ||
| set "WORKON_HOME=%USERPROFILE%\Envs" | ||
| ) | ||
|
|
||
| if defined VIRTUAL_ENV ( | ||
| call "%VIRTUAL_ENV%\Scripts\deactivate.bat" | ||
| ) | ||
|
|
||
| if defined PYTHONHOME ( | ||
| set "PYHOME=%PYTHONHOME%" | ||
| goto MAIN | ||
| ) | ||
| for /f "usebackq tokens=*" %%a in (`python.exe -c "import sys;print(sys.exec_prefix)"`) do ( | ||
| set "PYHOME=%%a" | ||
| ) | ||
|
|
||
| :MAIN | ||
| REM Copy all arguments, then set ENVNAME to the last argument | ||
| set "ARGS=%*" | ||
| call :GET_ENVNAME %* | ||
|
|
||
| pushd "%WORKON_HOME%" 2>NUL && popd | ||
| if errorlevel 1 ( | ||
| mkdir "%WORKON_HOME%" | ||
| ) | ||
|
|
||
| pushd "%WORKON_HOME%\%ENVNAME%" 2>NUL && popd | ||
| if not errorlevel 1 ( | ||
| echo. | ||
| echo. virtualenv "%ENVNAME%" already exists | ||
| goto END | ||
| ) | ||
|
|
||
| pushd "%WORKON_HOME%" | ||
| REM As of Python 2.7, calling virtualenv.exe causes a new window to open, | ||
| REM so call the script directly | ||
| REM virtualenv.exe %* | ||
| python.exe "%PYHOME%\Scripts\virtualenv-script.py" %ARGS% | ||
| popd | ||
| if errorlevel 2 goto END | ||
|
|
||
| REM In activate.bat, keep track of PYTHONPATH. | ||
| REM This should be a change adopted by virtualenv. | ||
| >>"%WORKON_HOME%\%ENVNAME%\Scripts\activate.bat" ( | ||
| echo.:: In case user makes changes to PYTHONPATH | ||
| echo.if defined _OLD_VIRTUAL_PYTHONPATH ( | ||
| echo. set "PYTHONPATH=%%_OLD_VIRTUAL_PYTHONPATH%%" | ||
| echo.^) else ( | ||
| echo. set "_OLD_VIRTUAL_PYTHONPATH=%%PYTHONPATH%%" | ||
| echo.^) | ||
| ) | ||
|
|
||
| REM In deactivate.bat, reset PYTHONPATH to its former value | ||
| >>"%WORKON_HOME%\%ENVNAME%\Scripts\deactivate.bat" ( | ||
| echo. | ||
| echo.if defined _OLD_VIRTUAL_PYTHONPATH ( | ||
| echo. set "PYTHONPATH=%%_OLD_VIRTUAL_PYTHONPATH%%" | ||
| echo.^) | ||
| ) | ||
|
|
||
| call "%WORKON_HOME%\%ENVNAME%\Scripts\activate.bat" | ||
| goto END | ||
|
|
||
| :GET_ENVNAME | ||
| set "ENVNAME=%~1" | ||
| shift | ||
| if not "%~1"=="" goto GET_ENVNAME | ||
| goto :eof | ||
|
|
||
| :END | ||
| set PYHOME= | ||
| set ENVNAME= |
| @@ -0,0 +1,82 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # this demo script illustrates pasting into an already displayed | ||
| # photoimage. note that the current version of Tk updates the whole | ||
| # image everytime we paste, so to get decent performance, we split | ||
| # the image into a set of tiles. | ||
| # | ||
|
|
||
| try: | ||
| from tkinter import Tk, Canvas, NW | ||
| except ImportError: | ||
| from Tkinter import Tk, Canvas, NW | ||
|
|
||
| from PIL import Image, ImageTk | ||
| import sys | ||
|
|
||
| # | ||
| # painter widget | ||
|
|
||
|
|
||
| class PaintCanvas(Canvas): | ||
| def __init__(self, master, image): | ||
| Canvas.__init__(self, master, width=image.size[0], height=image.size[1]) | ||
|
|
||
| # fill the canvas | ||
| self.tile = {} | ||
| self.tilesize = tilesize = 32 | ||
| xsize, ysize = image.size | ||
| for x in range(0, xsize, tilesize): | ||
| for y in range(0, ysize, tilesize): | ||
| box = x, y, min(xsize, x+tilesize), min(ysize, y+tilesize) | ||
| tile = ImageTk.PhotoImage(image.crop(box)) | ||
| self.create_image(x, y, image=tile, anchor=NW) | ||
| self.tile[(x, y)] = box, tile | ||
|
|
||
| self.image = image | ||
|
|
||
| self.bind("<B1-Motion>", self.paint) | ||
|
|
||
| def paint(self, event): | ||
| xy = event.x - 10, event.y - 10, event.x + 10, event.y + 10 | ||
| im = self.image.crop(xy) | ||
|
|
||
| # process the image in some fashion | ||
| im = im.convert("L") | ||
|
|
||
| self.image.paste(im, xy) | ||
| self.repair(xy) | ||
|
|
||
| def repair(self, box): | ||
| # update canvas | ||
| dx = box[0] % self.tilesize | ||
| dy = box[1] % self.tilesize | ||
| for x in range(box[0]-dx, box[2]+1, self.tilesize): | ||
| for y in range(box[1]-dy, box[3]+1, self.tilesize): | ||
| try: | ||
| xy, tile = self.tile[(x, y)] | ||
| tile.paste(self.image.crop(xy)) | ||
| except KeyError: | ||
| pass # outside the image | ||
| self.update_idletasks() | ||
|
|
||
| # | ||
| # main | ||
|
|
||
| root = Tk() | ||
|
|
||
| if len(sys.argv) != 2: | ||
| print("Usage: painter file") | ||
| sys.exit(1) | ||
|
|
||
| im = Image.open(sys.argv[1]) | ||
|
|
||
| if im.mode != "RGB": | ||
| im = im.convert("RGB") | ||
|
|
||
| PaintCanvas(root, im).pack() | ||
|
|
||
| root.mainloop() |
| @@ -0,0 +1,11 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| import re | ||
| import sys | ||
|
|
||
| from pbr.cmd.main import main | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
| sys.exit(main()) |
| @@ -0,0 +1,99 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library. | ||
| # $Id$ | ||
| # | ||
| # convert image files | ||
| # | ||
| # History: | ||
| # 0.1 96-04-20 fl Created | ||
| # 0.2 96-10-04 fl Use draft mode when converting images | ||
| # 0.3 96-12-30 fl Optimize output (PNG, JPEG) | ||
| # 0.4 97-01-18 fl Made optimize an option (PNG, JPEG) | ||
| # 0.5 98-12-30 fl Fixed -f option (from Anthony Baxter) | ||
| # | ||
|
|
||
| from __future__ import print_function | ||
|
|
||
| import getopt | ||
| import string | ||
| import sys | ||
|
|
||
| from PIL import Image | ||
|
|
||
|
|
||
| def usage(): | ||
| print("PIL Convert 0.5/1998-12-30 -- convert image files") | ||
| print("Usage: pilconvert [option] infile outfile") | ||
| print() | ||
| print("Options:") | ||
| print() | ||
| print(" -c <format> convert to format (default is given by extension)") | ||
| print() | ||
| print(" -g convert to greyscale") | ||
| print(" -p convert to palette image (using standard palette)") | ||
| print(" -r convert to rgb") | ||
| print() | ||
| print(" -o optimize output (trade speed for size)") | ||
| print(" -q <value> set compression quality (0-100, JPEG only)") | ||
| print() | ||
| print(" -f list supported file formats") | ||
| sys.exit(1) | ||
|
|
||
| if len(sys.argv) == 1: | ||
| usage() | ||
|
|
||
| try: | ||
| opt, argv = getopt.getopt(sys.argv[1:], "c:dfgopq:r") | ||
| except getopt.error as v: | ||
| print(v) | ||
| sys.exit(1) | ||
|
|
||
| output_format = None | ||
| convert = None | ||
|
|
||
| options = {} | ||
|
|
||
| for o, a in opt: | ||
|
|
||
| if o == "-f": | ||
| Image.init() | ||
| id = sorted(Image.ID) | ||
| print("Supported formats (* indicates output format):") | ||
| for i in id: | ||
| if i in Image.SAVE: | ||
| print(i+"*", end=' ') | ||
| else: | ||
| print(i, end=' ') | ||
| sys.exit(1) | ||
|
|
||
| elif o == "-c": | ||
| output_format = a | ||
|
|
||
| if o == "-g": | ||
| convert = "L" | ||
| elif o == "-p": | ||
| convert = "P" | ||
| elif o == "-r": | ||
| convert = "RGB" | ||
|
|
||
| elif o == "-o": | ||
| options["optimize"] = 1 | ||
| elif o == "-q": | ||
| options["quality"] = string.atoi(a) | ||
|
|
||
| if len(argv) != 2: | ||
| usage() | ||
|
|
||
| try: | ||
| im = Image.open(argv[0]) | ||
| if convert and im.mode != convert: | ||
| im.draft(convert, im.size) | ||
| im = im.convert(convert) | ||
| if output_format: | ||
| im.save(argv[1], output_format, **options) | ||
| else: | ||
| im.save(argv[1], **options) | ||
| except: | ||
| print("cannot convert image", end=' ') | ||
| print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1])) |
| @@ -0,0 +1,101 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library. | ||
| # $Id$ | ||
| # | ||
| # a utility to identify image files | ||
| # | ||
| # this script identifies image files, extracting size and | ||
| # pixel mode information for known file formats. Note that | ||
| # you don't need the PIL C extension to use this module. | ||
| # | ||
| # History: | ||
| # 0.0 1995-09-01 fl Created | ||
| # 0.1 1996-05-18 fl Modified options, added debugging mode | ||
| # 0.2 1996-12-29 fl Added verify mode | ||
| # 0.3 1999-06-05 fl Don't mess up on class exceptions (1.5.2 and later) | ||
| # 0.4 2003-09-30 fl Expand wildcards on Windows; robustness tweaks | ||
| # | ||
|
|
||
| from __future__ import print_function | ||
|
|
||
| import getopt | ||
| import glob | ||
| import logging | ||
| import sys | ||
|
|
||
| from PIL import Image | ||
|
|
||
| if len(sys.argv) == 1: | ||
| print("PIL File 0.4/2003-09-30 -- identify image files") | ||
| print("Usage: pilfile [option] files...") | ||
| print("Options:") | ||
| print(" -f list supported file formats") | ||
| print(" -i show associated info and tile data") | ||
| print(" -v verify file headers") | ||
| print(" -q quiet, don't warn for unidentified/missing/broken files") | ||
| sys.exit(1) | ||
|
|
||
| try: | ||
| opt, args = getopt.getopt(sys.argv[1:], "fqivD") | ||
| except getopt.error as v: | ||
| print(v) | ||
| sys.exit(1) | ||
|
|
||
| verbose = quiet = verify = 0 | ||
| logging_level = "WARNING" | ||
|
|
||
| for o, a in opt: | ||
| if o == "-f": | ||
| Image.init() | ||
| id = sorted(Image.ID) | ||
| print("Supported formats:") | ||
| for i in id: | ||
| print(i, end=' ') | ||
| sys.exit(1) | ||
| elif o == "-i": | ||
| verbose = 1 | ||
| elif o == "-q": | ||
| quiet = 1 | ||
| elif o == "-v": | ||
| verify = 1 | ||
| elif o == "-D": | ||
| logging_level = "DEBUG" | ||
|
|
||
| logging.basicConfig(level=logging_level) | ||
|
|
||
|
|
||
| def globfix(files): | ||
| # expand wildcards where necessary | ||
| if sys.platform == "win32": | ||
| out = [] | ||
| for file in files: | ||
| if glob.has_magic(file): | ||
| out.extend(glob.glob(file)) | ||
| else: | ||
| out.append(file) | ||
| return out | ||
| return files | ||
|
|
||
| for file in globfix(args): | ||
| try: | ||
| im = Image.open(file) | ||
| print("%s:" % file, im.format, "%dx%d" % im.size, im.mode, end=' ') | ||
| if verbose: | ||
| print(im.info, im.tile, end=' ') | ||
| print() | ||
| if verify: | ||
| try: | ||
| im.verify() | ||
| except: | ||
| if not quiet: | ||
| print("failed to verify image", end=' ') | ||
| print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1])) | ||
| except IOError as v: | ||
| if not quiet: | ||
| print(file, "failed:", v) | ||
| except: | ||
| import traceback | ||
| if not quiet: | ||
| print(file, "failed:", "unexpected error") | ||
| traceback.print_exc(file=sys.stdout) |
| @@ -0,0 +1,57 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # PIL raster font compiler | ||
| # | ||
| # history: | ||
| # 1997-08-25 fl created | ||
| # 2002-03-10 fl use "from PIL import" | ||
| # | ||
|
|
||
| from __future__ import print_function | ||
|
|
||
| import glob | ||
| import sys | ||
|
|
||
| # drivers | ||
| from PIL import BdfFontFile | ||
| from PIL import PcfFontFile | ||
|
|
||
| VERSION = "0.4" | ||
|
|
||
| if len(sys.argv) <= 1: | ||
| print("PILFONT", VERSION, "-- PIL font compiler.") | ||
| print() | ||
| print("Usage: pilfont fontfiles...") | ||
| print() | ||
| print("Convert given font files to the PIL raster font format.") | ||
| print("This version of pilfont supports X BDF and PCF fonts.") | ||
| sys.exit(1) | ||
|
|
||
| files = [] | ||
| for f in sys.argv[1:]: | ||
| files = files + glob.glob(f) | ||
|
|
||
| for f in files: | ||
|
|
||
| print(f + "...", end=' ') | ||
|
|
||
| try: | ||
|
|
||
| fp = open(f, "rb") | ||
|
|
||
| try: | ||
| p = PcfFontFile.PcfFontFile(fp) | ||
| except SyntaxError: | ||
| fp.seek(0) | ||
| p = BdfFontFile.BdfFontFile(fp) | ||
|
|
||
| p.save(f) | ||
|
|
||
| except (SyntaxError, IOError): | ||
| print("failed") | ||
|
|
||
| else: | ||
| print("OK") |
| @@ -0,0 +1,101 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library. | ||
| # $Id$ | ||
| # | ||
| # print image files to postscript printer | ||
| # | ||
| # History: | ||
| # 0.1 1996-04-20 fl Created | ||
| # 0.2 1996-10-04 fl Use draft mode when converting. | ||
| # 0.3 2003-05-06 fl Fixed a typo or two. | ||
| # | ||
|
|
||
| from __future__ import print_function | ||
| import getopt | ||
| import os | ||
| import sys | ||
| import subprocess | ||
|
|
||
| VERSION = "pilprint 0.3/2003-05-05" | ||
|
|
||
| from PIL import Image | ||
| from PIL import PSDraw | ||
|
|
||
| letter = (1.0*72, 1.0*72, 7.5*72, 10.0*72) | ||
|
|
||
|
|
||
| def description(filepath, image): | ||
| title = os.path.splitext(os.path.split(filepath)[1])[0] | ||
| format = " (%dx%d " | ||
| if image.format: | ||
| format = " (" + image.format + " %dx%d " | ||
| return title + format % image.size + image.mode + ")" | ||
|
|
||
| if len(sys.argv) == 1: | ||
| print("PIL Print 0.2a1/96-10-04 -- print image files") | ||
| print("Usage: pilprint files...") | ||
| print("Options:") | ||
| print(" -c colour printer (default is monochrome)") | ||
| print(" -p print via lpr (default is stdout)") | ||
| print(" -P <printer> same as -p but use given printer") | ||
| sys.exit(1) | ||
|
|
||
| try: | ||
| opt, argv = getopt.getopt(sys.argv[1:], "cdpP:") | ||
| except getopt.error as v: | ||
| print(v) | ||
| sys.exit(1) | ||
|
|
||
| printerArgs = [] # print to stdout | ||
| monochrome = 1 # reduce file size for most common case | ||
|
|
||
| for o, a in opt: | ||
| if o == "-d": | ||
| # debug: show available drivers | ||
| Image.init() | ||
| print(Image.ID) | ||
| sys.exit(1) | ||
| elif o == "-c": | ||
| # colour printer | ||
| monochrome = 0 | ||
| elif o == "-p": | ||
| # default printer channel | ||
| printerArgs = ["lpr"] | ||
| elif o == "-P": | ||
| # printer channel | ||
| printerArgs = ["lpr", "-P%s" % a] | ||
|
|
||
| for filepath in argv: | ||
| try: | ||
|
|
||
| im = Image.open(filepath) | ||
|
|
||
| title = description(filepath, im) | ||
|
|
||
| if monochrome and im.mode not in ["1", "L"]: | ||
| im.draft("L", im.size) | ||
| im = im.convert("L") | ||
|
|
||
| if printerArgs: | ||
| p = subprocess.Popen(printerArgs, stdin=subprocess.PIPE) | ||
| fp = p.stdin | ||
| else: | ||
| fp = sys.stdout | ||
|
|
||
| ps = PSDraw.PSDraw(fp) | ||
|
|
||
| ps.begin_document() | ||
| ps.setfont("Helvetica-Narrow-Bold", 18) | ||
| ps.text((letter[0], letter[3]+24), title) | ||
| ps.setfont("Helvetica-Narrow-Bold", 8) | ||
| ps.text((letter[0], letter[1]-30), VERSION) | ||
| ps.image(letter, im) | ||
| ps.end_document() | ||
|
|
||
| if printerArgs: | ||
| fp.close() | ||
|
|
||
| except: | ||
| print("cannot print image", end=' ') | ||
| print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1])) |
| @@ -0,0 +1,10 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # EASY-INSTALL-ENTRY-SCRIPT: 'pip==8.0.2','console_scripts','pip' | ||
| __requires__ = 'pip==8.0.2' | ||
| import sys | ||
| from pkg_resources import load_entry_point | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit( | ||
| load_entry_point('pip==8.0.2', 'console_scripts', 'pip')() | ||
| ) |
| @@ -0,0 +1,11 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| import re | ||
| import sys | ||
|
|
||
| from pip import main | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
| sys.exit(main()) |
| @@ -0,0 +1,11 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| import re | ||
| import sys | ||
|
|
||
| from pip import main | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
| sys.exit(main()) |
| @@ -0,0 +1,10 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # EASY-INSTALL-ENTRY-SCRIPT: 'pip==8.0.2','console_scripts','pip3' | ||
| __requires__ = 'pip==8.0.2' | ||
| import sys | ||
| from pkg_resources import load_entry_point | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit( | ||
| load_entry_point('pip==8.0.2', 'console_scripts', 'pip3')() | ||
| ) |
| @@ -0,0 +1,10 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # EASY-INSTALL-ENTRY-SCRIPT: 'pip==8.0.2','console_scripts','pip3.5' | ||
| __requires__ = 'pip==8.0.2' | ||
| import sys | ||
| from pkg_resources import load_entry_point | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit( | ||
| load_entry_point('pip==8.0.2', 'console_scripts', 'pip3.5')() | ||
| ) |
| @@ -0,0 +1,102 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
|
|
||
| from __future__ import print_function | ||
|
|
||
| try: | ||
| from tkinter import * | ||
| except ImportError: | ||
| from Tkinter import * | ||
|
|
||
| from PIL import Image, ImageTk | ||
| import sys | ||
|
|
||
|
|
||
| # -------------------------------------------------------------------- | ||
| # an image animation player | ||
|
|
||
| class UI(Label): | ||
|
|
||
| def __init__(self, master, im): | ||
| if isinstance(im, list): | ||
| # list of images | ||
| self.im = im[1:] | ||
| im = self.im[0] | ||
| else: | ||
| # sequence | ||
| self.im = im | ||
|
|
||
| if im.mode == "1": | ||
| self.image = ImageTk.BitmapImage(im, foreground="white") | ||
| else: | ||
| self.image = ImageTk.PhotoImage(im) | ||
|
|
||
| Label.__init__(self, master, image=self.image, bg="black", bd=0) | ||
|
|
||
| self.update() | ||
|
|
||
| try: | ||
| duration = im.info["duration"] | ||
| except KeyError: | ||
| duration = 100 | ||
| self.after(duration, self.next) | ||
|
|
||
| def next(self): | ||
|
|
||
| if isinstance(self.im, list): | ||
|
|
||
| try: | ||
| im = self.im[0] | ||
| del self.im[0] | ||
| self.image.paste(im) | ||
| except IndexError: | ||
| return # end of list | ||
|
|
||
| else: | ||
|
|
||
| try: | ||
| im = self.im | ||
| im.seek(im.tell() + 1) | ||
| self.image.paste(im) | ||
| except EOFError: | ||
| return # end of file | ||
|
|
||
| try: | ||
| duration = im.info["duration"] | ||
| except KeyError: | ||
| duration = 100 | ||
| self.after(duration, self.next) | ||
|
|
||
| self.update_idletasks() | ||
|
|
||
|
|
||
| # -------------------------------------------------------------------- | ||
| # script interface | ||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| if not sys.argv[1:]: | ||
| print("Syntax: python player.py imagefile(s)") | ||
| sys.exit(1) | ||
|
|
||
| filename = sys.argv[1] | ||
|
|
||
| root = Tk() | ||
| root.title(filename) | ||
|
|
||
| if len(sys.argv) > 2: | ||
| # list of images | ||
| print("loading...") | ||
| im = [] | ||
| for filename in sys.argv[1:]: | ||
| im.append(Image.open(filename)) | ||
| else: | ||
| # sequence | ||
| im = Image.open(filename) | ||
|
|
||
| UI(root, im).pack() | ||
|
|
||
| root.mainloop() |
| @@ -0,0 +1,78 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
|
|
||
| import sys | ||
| import getopt | ||
| import sysconfig | ||
|
|
||
| valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', | ||
| 'ldflags', 'help'] | ||
|
|
||
| if sys.version_info >= (3, 2): | ||
| valid_opts.insert(-1, 'extension-suffix') | ||
| valid_opts.append('abiflags') | ||
| if sys.version_info >= (3, 3): | ||
| valid_opts.append('configdir') | ||
|
|
||
|
|
||
| def exit_with_usage(code=1): | ||
| sys.stderr.write("Usage: {0} [{1}]\n".format( | ||
| sys.argv[0], '|'.join('--'+opt for opt in valid_opts))) | ||
| sys.exit(code) | ||
|
|
||
| try: | ||
| opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) | ||
| except getopt.error: | ||
| exit_with_usage() | ||
|
|
||
| if not opts: | ||
| exit_with_usage() | ||
|
|
||
| pyver = sysconfig.get_config_var('VERSION') | ||
| getvar = sysconfig.get_config_var | ||
|
|
||
| opt_flags = [flag for (flag, val) in opts] | ||
|
|
||
| if '--help' in opt_flags: | ||
| exit_with_usage(code=0) | ||
|
|
||
| for opt in opt_flags: | ||
| if opt == '--prefix': | ||
| print(sysconfig.get_config_var('prefix')) | ||
|
|
||
| elif opt == '--exec-prefix': | ||
| print(sysconfig.get_config_var('exec_prefix')) | ||
|
|
||
| elif opt in ('--includes', '--cflags'): | ||
| flags = ['-I' + sysconfig.get_path('include'), | ||
| '-I' + sysconfig.get_path('platinclude')] | ||
| if opt == '--cflags': | ||
| flags.extend(getvar('CFLAGS').split()) | ||
| print(' '.join(flags)) | ||
|
|
||
| elif opt in ('--libs', '--ldflags'): | ||
| abiflags = getattr(sys, 'abiflags', '') | ||
| libs = ['-lpython' + pyver + abiflags] | ||
| libs += getvar('LIBS').split() | ||
| libs += getvar('SYSLIBS').split() | ||
| # add the prefix/lib/pythonX.Y/config dir, but only if there is no | ||
| # shared library in prefix/lib/. | ||
| if opt == '--ldflags': | ||
| if not getvar('Py_ENABLE_SHARED'): | ||
| libs.insert(0, '-L' + getvar('LIBPL')) | ||
| if not getvar('PYTHONFRAMEWORK'): | ||
| libs.extend(getvar('LINKFORSHARED').split()) | ||
| print(' '.join(libs)) | ||
|
|
||
| elif opt == '--extension-suffix': | ||
| ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') | ||
| if ext_suffix is None: | ||
| ext_suffix = sysconfig.get_config_var('SO') | ||
| print(ext_suffix) | ||
|
|
||
| elif opt == '--abiflags': | ||
| if not getattr(sys, 'abiflags', None): | ||
| exit_with_usage() | ||
| print(sys.abiflags) | ||
|
|
||
| elif opt == '--configdir': | ||
| print(sysconfig.get_config_var('LIBPL')) |
| @@ -0,0 +1 @@ | ||
| python |
| @@ -0,0 +1 @@ | ||
| python |
| @@ -0,0 +1,52 @@ | ||
| @echo off | ||
|
|
||
| if [%1]==[] goto USAGE | ||
| goto RMVIRTUALENV | ||
|
|
||
| :USAGE | ||
| echo. | ||
| echo. Pass a name to remove a virtualenv | ||
| goto END | ||
|
|
||
| :RMVIRTUALENV | ||
| if not defined WORKON_HOME ( | ||
| set "WORKON_HOME=%USERPROFILE%\Envs" | ||
| ) | ||
|
|
||
| if defined VIRTUAL_ENV ( | ||
| if [%VIRTUAL_ENV%]==[%WORKON_HOME%\%1] call "%WORKON_HOME%\%1\Scripts\deactivate.bat" | ||
| ) | ||
|
|
||
| if not defined VIRTUALENVWRAPPER_PROJECT_FILENAME ( | ||
| set VIRTUALENVWRAPPER_PROJECT_FILENAME=.project | ||
| ) | ||
|
|
||
| pushd "%WORKON_HOME%" 2>NUL && popd | ||
| if errorlevel 1 ( | ||
| mkdir "%WORKON_HOME%" | ||
| ) | ||
|
|
||
| pushd "%WORKON_HOME%\%1" 2>NUL && popd | ||
| if errorlevel 1 ( | ||
| echo. | ||
| echo. virtualenv "%1" does not exist | ||
| goto END | ||
| ) | ||
|
|
||
| set "_CURRDIR=%CD%" | ||
| cd /d "%WORKON_HOME%\%1" | ||
| if exist "%WORKON_HOME%\%1\%VIRTUALENVWRAPPER_PROJECT_FILENAME%" ( | ||
| del "%WORKON_HOME%\%1\%VIRTUALENVWRAPPER_PROJECT_FILENAME%" | ||
| ) | ||
|
|
||
| call folder_delete.bat * | ||
| cd .. | ||
| rmdir "%1" | ||
| cd /d "%_CURRDIR%" | ||
| echo. | ||
| echo. Deleted %WORKON_HOME%\%1 | ||
| echo. | ||
|
|
||
| set _CURRDIR= | ||
|
|
||
| :END |
| @@ -0,0 +1,48 @@ | ||
| @echo off | ||
|
|
||
| if [%1]==[] goto USAGE | ||
| goto SETPROJECTDIR | ||
|
|
||
| :USAGE | ||
| echo. | ||
| echo. Pass in a full or relative path to the project directory. | ||
| echo. If the directory doesn't exist, it will be created. | ||
| goto END | ||
|
|
||
| :SETPROJECTDIR | ||
| if not defined WORKON_HOME ( | ||
| set "WORKON_HOME=%USERPROFILE%\Envs" | ||
| ) | ||
|
|
||
| if not defined VIRTUALENVWRAPPER_PROJECT_FILENAME ( | ||
| set VIRTUALENVWRAPPER_PROJECT_FILENAME=.project | ||
| ) | ||
|
|
||
| if not defined VIRTUAL_ENV ( | ||
| echo. | ||
| echo A virtualenv must be activated. | ||
| goto USAGE | ||
| ) | ||
|
|
||
| set "CALLINGPATH=%CD%" | ||
| set "PROJDIR=%1" | ||
| pushd "%PROJDIR%" 2>NUL | ||
| if errorlevel 1 ( | ||
| popd | ||
| mkdir "%PROJDIR%" | ||
| set "PROJDIR=%CALLINGPATH%\%PROJDIR%" | ||
| ) else ( | ||
| set "PROJDIR=%CD%" | ||
| popd | ||
| ) | ||
|
|
||
| echo. | ||
| echo. "%PROJDIR%" is now the project directory for | ||
| echo. virtualenv "%VIRTUAL_ENV%" | ||
|
|
||
| set /p ="%PROJDIR%">"%VIRTUAL_ENV%\%VIRTUALENVWRAPPER_PROJECT_FILENAME%" <NUL | ||
| call add2virtualenv.bat "%PROJDIR%" | ||
|
|
||
| :END | ||
| set CALLINGPATH= | ||
| set PROJDIR= |
| @@ -0,0 +1,74 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # this demo script illustrates how a 1-bit BitmapImage can be used | ||
| # as a dynamically updated overlay | ||
| # | ||
|
|
||
| try: | ||
| from tkinter import * | ||
| except ImportError: | ||
| from Tkinter import * | ||
|
|
||
| from PIL import Image, ImageTk | ||
| import sys | ||
|
|
||
| # | ||
| # an image viewer | ||
|
|
||
|
|
||
| class UI(Frame): | ||
| def __init__(self, master, im, value=128): | ||
| Frame.__init__(self, master) | ||
|
|
||
| self.image = im | ||
| self.value = value | ||
|
|
||
| self.canvas = Canvas(self, width=im.size[0], height=im.size[1]) | ||
| self.backdrop = ImageTk.PhotoImage(im) | ||
| self.canvas.create_image(0, 0, image=self.backdrop, anchor=NW) | ||
| self.canvas.pack() | ||
|
|
||
| scale = Scale(self, orient=HORIZONTAL, from_=0, to=255, | ||
| resolution=1, command=self.update_scale, length=256) | ||
| scale.set(value) | ||
| scale.bind("<ButtonRelease-1>", self.redraw) | ||
| scale.pack() | ||
|
|
||
| # uncomment the following line for instant feedback (might | ||
| # be too slow on some platforms) | ||
| # self.redraw() | ||
|
|
||
| def update_scale(self, value): | ||
| self.value = eval(value) | ||
|
|
||
| self.redraw() | ||
|
|
||
| def redraw(self, event=None): | ||
|
|
||
| # create overlay (note the explicit conversion to mode "1") | ||
| im = self.image.point(lambda v, t=self.value: v >= t, "1") | ||
| self.overlay = ImageTk.BitmapImage(im, foreground="green") | ||
|
|
||
| # update canvas | ||
| self.canvas.delete("overlay") | ||
| self.canvas.create_image(0, 0, image=self.overlay, anchor=NW, | ||
| tags="overlay") | ||
|
|
||
| # -------------------------------------------------------------------- | ||
| # main | ||
|
|
||
| root = Tk() | ||
|
|
||
| im = Image.open(sys.argv[1]) | ||
|
|
||
| if im.mode != "L": | ||
| im = im.convert("L") | ||
|
|
||
| # im.thumbnail((320,200)) | ||
|
|
||
| UI(root, im).pack() | ||
|
|
||
| root.mainloop() |
| @@ -0,0 +1,23 @@ | ||
| @echo off | ||
|
|
||
| :MAIN | ||
| if not defined VIRTUAL_ENV ( | ||
| echo. | ||
| echo You must have an active virtualenv to use this command. | ||
| goto END | ||
| ) | ||
|
|
||
| set "file=%VIRTUAL_ENV%\Lib\no-global-site-packages.txt" | ||
| if exist "%file%" ( | ||
| del "%file%" | ||
| echo. | ||
| echo. Enabled global site-packages | ||
| goto END | ||
| ) else ( | ||
| type nul >>"%file%" | ||
| echo. | ||
| echo. Disabled global site-packages | ||
| ) | ||
| set file= | ||
|
|
||
| :END |
| @@ -0,0 +1,54 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
|
|
||
| from __future__ import print_function | ||
|
|
||
| try: | ||
| from tkinter import Tk, Label | ||
| except ImportError: | ||
| from Tkinter import Tk, Label | ||
|
|
||
| from PIL import Image, ImageTk | ||
|
|
||
| # | ||
| # an image viewer | ||
|
|
||
|
|
||
| class UI(Label): | ||
|
|
||
| def __init__(self, master, im): | ||
|
|
||
| if im.mode == "1": | ||
| # bitmap image | ||
| self.image = ImageTk.BitmapImage(im, foreground="white") | ||
| Label.__init__(self, master, image=self.image, bg="black", bd=0) | ||
|
|
||
| else: | ||
| # photo image | ||
| self.image = ImageTk.PhotoImage(im) | ||
| Label.__init__(self, master, image=self.image, bd=0) | ||
|
|
||
| # | ||
| # script interface | ||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| import sys | ||
|
|
||
| if not sys.argv[1:]: | ||
| print("Syntax: python viewer.py imagefile") | ||
| sys.exit(1) | ||
|
|
||
| filename = sys.argv[1] | ||
|
|
||
| root = Tk() | ||
| root.title(filename) | ||
|
|
||
| im = Image.open(filename) | ||
|
|
||
| UI(root, im).pack() | ||
|
|
||
| root.mainloop() |
| @@ -0,0 +1,11 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| import re | ||
| import sys | ||
|
|
||
| from virtualenv import main | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
| sys.exit(main()) |
| @@ -0,0 +1,11 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| import re | ||
| import sys | ||
|
|
||
| from virtualenv import main | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
| sys.exit(main()) |
| @@ -0,0 +1,11 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| import re | ||
| import sys | ||
|
|
||
| from clonevirtualenv import main | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
| sys.exit(main()) |
| @@ -0,0 +1,56 @@ | ||
| #!/bin/sh | ||
| # Alternative startup script for faster login times. | ||
|
|
||
| export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv lsvirtualenv showvirtualenv workon add2virtualenv cdsitepackages cdvirtualenv lssitepackages toggleglobalsitepackages cpvirtualenv setvirtualenvproject mkproject cdproject mktmpenv" | ||
|
|
||
| if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] | ||
| then | ||
| export VIRTUALENVWRAPPER_SCRIPT="$(command \which virtualenvwrapper.sh)" | ||
| fi | ||
| if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] | ||
| then | ||
| echo "ERROR: virtualenvwrapper_lazy.sh: Could not find virtualenvwrapper.sh" 1>&2 | ||
| fi | ||
|
|
||
| # Load the real implementation of the API from virtualenvwrapper.sh | ||
| function virtualenvwrapper_load { | ||
| # Only source the script once. | ||
| # We might get called multiple times, because not all of _VIRTUALENVWRAPPER_API gets | ||
| # a real completion. | ||
| if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ] | ||
| then | ||
| # NOTE: For Zsh, I have tried to unset any auto-load completion. | ||
| # (via `compctl + $(echo ${_VIRTUALENVWRAPPER_API})`. | ||
| # But this does not appear to work / triggers a crash. | ||
| source "$VIRTUALENVWRAPPER_SCRIPT" | ||
| VIRTUALENVWRAPPER_LAZY_LOADED=1 | ||
| fi | ||
| } | ||
|
|
||
| # Set up "alias" functions based on the API definition. | ||
| function virtualenvwrapper_setup_lazy_loader { | ||
| typeset venvw_name | ||
| for venvw_name in $(echo ${_VIRTUALENVWRAPPER_API}) | ||
| do | ||
| eval " | ||
| function $venvw_name { | ||
| virtualenvwrapper_load | ||
| ${venvw_name} \"\$@\" | ||
| } | ||
| " | ||
| done | ||
| } | ||
|
|
||
| # Set up completion functions to virtualenvwrapper_load | ||
| function virtualenvwrapper_setup_lazy_completion { | ||
| if [ -n "$BASH" ] ; then | ||
| complete -o nospace -F virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API}) | ||
| elif [ -n "$ZSH_VERSION" ] ; then | ||
| compctl -K virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API}) | ||
| fi | ||
| } | ||
|
|
||
| virtualenvwrapper_setup_lazy_loader | ||
| # Does not really work. Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv). | ||
| # It also needs a second invocation, because the first one only sets up the real completion. | ||
| virtualenvwrapper_setup_lazy_completion |
| @@ -0,0 +1,11 @@ | ||
| #!/home/spedroq/itech2016/itech2016/bin/python | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| import re | ||
| import sys | ||
|
|
||
| from wheel.tool import main | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
| sys.exit(main()) |
| @@ -0,0 +1,5 @@ | ||
| @echo off | ||
| SETLOCAL | ||
| set "P2=.;%PATH%" | ||
| for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT "%%~$P2:i"=="" echo %%~$P2:i | ||
| for %%i in (%1) do @if NOT "%%~$P2:i"=="" echo %%~$P2:i |
| @@ -0,0 +1,44 @@ | ||
| @echo off | ||
|
|
||
| if not defined WORKON_HOME ( | ||
| set "WORKON_HOME=%USERPROFILE%\Envs" | ||
| ) | ||
|
|
||
| if not defined VIRTUALENVWRAPPER_PROJECT_FILENAME ( | ||
| set VIRTUALENVWRAPPER_PROJECT_FILENAME=.project | ||
| ) | ||
|
|
||
| if [%1]==[] goto LIST | ||
| goto WORKON | ||
|
|
||
| :LIST | ||
| echo. | ||
| echo Pass a name to activate one of the following virtualenvs: | ||
| echo ============================================================================== | ||
| dir /b /ad "%WORKON_HOME%" | ||
| goto END | ||
|
|
||
| :WORKON | ||
| if defined VIRTUAL_ENV ( | ||
| call "%VIRTUAL_ENV%\Scripts\deactivate.bat" | ||
| ) | ||
|
|
||
| pushd "%WORKON_HOME%" 2>NUL && popd | ||
| if errorlevel 1 ( | ||
| mkdir "%WORKON_HOME%" | ||
| ) | ||
|
|
||
| pushd "%WORKON_HOME%\%1" 2>NUL && popd | ||
| if errorlevel 1 ( | ||
| echo. | ||
| echo. virtualenv "%1" does not exist. Create it with "mkvirtualenv %1" | ||
| goto END | ||
| ) | ||
|
|
||
| call "%WORKON_HOME%\%1\Scripts\activate.bat" | ||
|
|
||
| if exist "%WORKON_HOME%\%1\%VIRTUALENVWRAPPER_PROJECT_FILENAME%" ( | ||
| call cdproject.bat | ||
| ) | ||
|
|
||
| :END |
| @@ -0,0 +1 @@ | ||
| /usr/include/python2.7 |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/UserDict.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/_abcoll.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/_weakrefset.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/abc.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/codecs.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/config |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/copy_reg.py |
| @@ -0,0 +1,101 @@ | ||
| import os | ||
| import sys | ||
| import warnings | ||
| import imp | ||
| import opcode # opcode is not a virtualenv module, so we can use it to find the stdlib | ||
| # Important! To work on pypy, this must be a module that resides in the | ||
| # lib-python/modified-x.y.z directory | ||
|
|
||
| dirname = os.path.dirname | ||
|
|
||
| distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils') | ||
| if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)): | ||
| warnings.warn( | ||
| "The virtualenv distutils package at %s appears to be in the same location as the system distutils?") | ||
| else: | ||
| __path__.insert(0, distutils_path) | ||
| real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ('', '', imp.PKG_DIRECTORY)) | ||
| # Copy the relevant attributes | ||
| try: | ||
| __revision__ = real_distutils.__revision__ | ||
| except AttributeError: | ||
| pass | ||
| __version__ = real_distutils.__version__ | ||
|
|
||
| from distutils import dist, sysconfig | ||
|
|
||
| try: | ||
| basestring | ||
| except NameError: | ||
| basestring = str | ||
|
|
||
| ## patch build_ext (distutils doesn't know how to get the libs directory | ||
| ## path on windows - it hardcodes the paths around the patched sys.prefix) | ||
|
|
||
| if sys.platform == 'win32': | ||
| from distutils.command.build_ext import build_ext as old_build_ext | ||
| class build_ext(old_build_ext): | ||
| def finalize_options (self): | ||
| if self.library_dirs is None: | ||
| self.library_dirs = [] | ||
| elif isinstance(self.library_dirs, basestring): | ||
| self.library_dirs = self.library_dirs.split(os.pathsep) | ||
|
|
||
| self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs")) | ||
| old_build_ext.finalize_options(self) | ||
|
|
||
| from distutils.command import build_ext as build_ext_module | ||
| build_ext_module.build_ext = build_ext | ||
|
|
||
| ## distutils.dist patches: | ||
|
|
||
| old_find_config_files = dist.Distribution.find_config_files | ||
| def find_config_files(self): | ||
| found = old_find_config_files(self) | ||
| system_distutils = os.path.join(distutils_path, 'distutils.cfg') | ||
| #if os.path.exists(system_distutils): | ||
| # found.insert(0, system_distutils) | ||
| # What to call the per-user config file | ||
| if os.name == 'posix': | ||
| user_filename = ".pydistutils.cfg" | ||
| else: | ||
| user_filename = "pydistutils.cfg" | ||
| user_filename = os.path.join(sys.prefix, user_filename) | ||
| if os.path.isfile(user_filename): | ||
| for item in list(found): | ||
| if item.endswith('pydistutils.cfg'): | ||
| found.remove(item) | ||
| found.append(user_filename) | ||
| return found | ||
| dist.Distribution.find_config_files = find_config_files | ||
|
|
||
| ## distutils.sysconfig patches: | ||
|
|
||
| old_get_python_inc = sysconfig.get_python_inc | ||
| def sysconfig_get_python_inc(plat_specific=0, prefix=None): | ||
| if prefix is None: | ||
| prefix = sys.real_prefix | ||
| return old_get_python_inc(plat_specific, prefix) | ||
| sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__ | ||
| sysconfig.get_python_inc = sysconfig_get_python_inc | ||
|
|
||
| old_get_python_lib = sysconfig.get_python_lib | ||
| def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None): | ||
| if standard_lib and prefix is None: | ||
| prefix = sys.real_prefix | ||
| return old_get_python_lib(plat_specific, standard_lib, prefix) | ||
| sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__ | ||
| sysconfig.get_python_lib = sysconfig_get_python_lib | ||
|
|
||
| old_get_config_vars = sysconfig.get_config_vars | ||
| def sysconfig_get_config_vars(*args): | ||
| real_vars = old_get_config_vars(*args) | ||
| if sys.platform == 'win32': | ||
| lib_dir = os.path.join(sys.real_prefix, "libs") | ||
| if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars: | ||
| real_vars['LIBDIR'] = lib_dir # asked for all | ||
| elif isinstance(real_vars, list) and 'LIBDIR' in args: | ||
| real_vars = real_vars + [lib_dir] # asked for list | ||
| return real_vars | ||
| sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__ | ||
| sysconfig.get_config_vars = sysconfig_get_config_vars |
| @@ -0,0 +1,6 @@ | ||
| # This is a config file local to this virtualenv installation | ||
| # You may include options that will be used by all distutils commands, | ||
| # and by easy_install. For instance: | ||
| # | ||
| # [easy_install] | ||
| # find_links = http://mylocalsite |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/encodings |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/fnmatch.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/genericpath.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/lib-dynload |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/linecache.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/locale.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/ntpath.py |
| @@ -0,0 +1 @@ | ||
| /usr |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/os.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/posixpath.py |
| @@ -0,0 +1 @@ | ||
| /usr/lib/python2.7/re.py |
| @@ -0,0 +1,3 @@ | ||
| UNKNOWN | ||
|
|
||
|
|
| @@ -0,0 +1 @@ | ||
| pip |
| @@ -0,0 +1,27 @@ | ||
| Copyright (c) Django Software Foundation and individual contributors. | ||
| All rights reserved. | ||
|
|
||
| Redistribution and use in source and binary forms, with or without modification, | ||
| are permitted provided that the following conditions are met: | ||
|
|
||
| 1. Redistributions of source code must retain the above copyright notice, | ||
| this list of conditions and the following disclaimer. | ||
|
|
||
| 2. Redistributions in binary form must reproduce the above copyright | ||
| notice, this list of conditions and the following disclaimer in the | ||
| documentation and/or other materials provided with the distribution. | ||
|
|
||
| 3. Neither the name of Django nor the names of its contributors may be used | ||
| to endorse or promote products derived from this software without | ||
| specific prior written permission. | ||
|
|
||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
| ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
| ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| @@ -0,0 +1,34 @@ | ||
| Metadata-Version: 2.0 | ||
| Name: Django | ||
| Version: 1.8.8 | ||
| Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design. | ||
| Home-page: http://www.djangoproject.com/ | ||
| Author: Django Software Foundation | ||
| Author-email: foundation@djangoproject.com | ||
| License: BSD | ||
| Platform: UNKNOWN | ||
| Classifier: Development Status :: 5 - Production/Stable | ||
| Classifier: Environment :: Web Environment | ||
| Classifier: Framework :: Django | ||
| Classifier: Intended Audience :: Developers | ||
| Classifier: License :: OSI Approved :: BSD License | ||
| Classifier: Operating System :: OS Independent | ||
| Classifier: Programming Language :: Python | ||
| Classifier: Programming Language :: Python :: 2 | ||
| Classifier: Programming Language :: Python :: 2.7 | ||
| Classifier: Programming Language :: Python :: 3 | ||
| Classifier: Programming Language :: Python :: 3.2 | ||
| Classifier: Programming Language :: Python :: 3.3 | ||
| Classifier: Programming Language :: Python :: 3.4 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
| Classifier: Topic :: Internet :: WWW/HTTP | ||
| Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content | ||
| Classifier: Topic :: Internet :: WWW/HTTP :: WSGI | ||
| Classifier: Topic :: Software Development :: Libraries :: Application Frameworks | ||
| Classifier: Topic :: Software Development :: Libraries :: Python Modules | ||
| Provides-Extra: bcrypt | ||
| Requires-Dist: bcrypt; extra == 'bcrypt' | ||
|
|
||
| UNKNOWN | ||
|
|
||
|
|
| @@ -0,0 +1,6 @@ | ||
| Wheel-Version: 1.0 | ||
| Generator: bdist_wheel (0.26.0) | ||
| Root-Is-Purelib: true | ||
| Tag: py2-none-any | ||
| Tag: py3-none-any | ||
|
|
| @@ -0,0 +1,3 @@ | ||
| [console_scripts] | ||
| django-admin = django.core.management:execute_from_command_line | ||
|
|
| @@ -0,0 +1 @@ | ||
| {"generator": "bdist_wheel (0.26.0)", "summary": "A high-level Python Web framework that encourages rapid development and clean, pragmatic design.", "classifiers": ["Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Libraries :: Python Modules"], "extensions": {"python.details": {"project_urls": {"Home": "http://www.djangoproject.com/"}, "contacts": [{"email": "foundation@djangoproject.com", "name": "Django Software Foundation", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst", "license": "LICENSE.txt"}}, "python.exports": {"console_scripts": {"django-admin": "django.core.management:execute_from_command_line"}}, "python.commands": {"wrap_console": {"django-admin": "django.core.management:execute_from_command_line"}}}, "license": "BSD", "metadata_version": "2.0", "name": "Django", "extras": ["bcrypt"], "run_requires": [{"requires": ["bcrypt"], "extra": "bcrypt"}], "version": "1.8.8"} |
| @@ -0,0 +1 @@ | ||
| django |
| @@ -0,0 +1,132 @@ | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # bitmap distribution font (bdf) file parser | ||
| # | ||
| # history: | ||
| # 1996-05-16 fl created (as bdf2pil) | ||
| # 1997-08-25 fl converted to FontFile driver | ||
| # 2001-05-25 fl removed bogus __init__ call | ||
| # 2002-11-20 fl robustification (from Kevin Cazabon, Dmitry Vasiliev) | ||
| # 2003-04-22 fl more robustification (from Graham Dumpleton) | ||
| # | ||
| # Copyright (c) 1997-2003 by Secret Labs AB. | ||
| # Copyright (c) 1997-2003 by Fredrik Lundh. | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
| from PIL import Image | ||
| from PIL import FontFile | ||
|
|
||
|
|
||
| # -------------------------------------------------------------------- | ||
| # parse X Bitmap Distribution Format (BDF) | ||
| # -------------------------------------------------------------------- | ||
|
|
||
| bdf_slant = { | ||
| "R": "Roman", | ||
| "I": "Italic", | ||
| "O": "Oblique", | ||
| "RI": "Reverse Italic", | ||
| "RO": "Reverse Oblique", | ||
| "OT": "Other" | ||
| } | ||
|
|
||
| bdf_spacing = { | ||
| "P": "Proportional", | ||
| "M": "Monospaced", | ||
| "C": "Cell" | ||
| } | ||
|
|
||
|
|
||
| def bdf_char(f): | ||
| # skip to STARTCHAR | ||
| while True: | ||
| s = f.readline() | ||
| if not s: | ||
| return None | ||
| if s[:9] == b"STARTCHAR": | ||
| break | ||
| id = s[9:].strip().decode('ascii') | ||
|
|
||
| # load symbol properties | ||
| props = {} | ||
| while True: | ||
| s = f.readline() | ||
| if not s or s[:6] == b"BITMAP": | ||
| break | ||
| i = s.find(b" ") | ||
| props[s[:i].decode('ascii')] = s[i+1:-1].decode('ascii') | ||
|
|
||
| # load bitmap | ||
| bitmap = [] | ||
| while True: | ||
| s = f.readline() | ||
| if not s or s[:7] == b"ENDCHAR": | ||
| break | ||
| bitmap.append(s[:-1]) | ||
| bitmap = b"".join(bitmap) | ||
|
|
||
| [x, y, l, d] = [int(p) for p in props["BBX"].split()] | ||
| [dx, dy] = [int(p) for p in props["DWIDTH"].split()] | ||
|
|
||
| bbox = (dx, dy), (l, -d-y, x+l, -d), (0, 0, x, y) | ||
|
|
||
| try: | ||
| im = Image.frombytes("1", (x, y), bitmap, "hex", "1") | ||
| except ValueError: | ||
| # deal with zero-width characters | ||
| im = Image.new("1", (x, y)) | ||
|
|
||
| return id, int(props["ENCODING"]), bbox, im | ||
|
|
||
|
|
||
| ## | ||
| # Font file plugin for the X11 BDF format. | ||
|
|
||
| class BdfFontFile(FontFile.FontFile): | ||
|
|
||
| def __init__(self, fp): | ||
|
|
||
| FontFile.FontFile.__init__(self) | ||
|
|
||
| s = fp.readline() | ||
| if s[:13] != b"STARTFONT 2.1": | ||
| raise SyntaxError("not a valid BDF file") | ||
|
|
||
| props = {} | ||
| comments = [] | ||
|
|
||
| while True: | ||
| s = fp.readline() | ||
| if not s or s[:13] == b"ENDPROPERTIES": | ||
| break | ||
| i = s.find(b" ") | ||
| props[s[:i].decode('ascii')] = s[i+1:-1].decode('ascii') | ||
| if s[:i] in [b"COMMENT", b"COPYRIGHT"]: | ||
| if s.find(b"LogicalFontDescription") < 0: | ||
| comments.append(s[i+1:-1].decode('ascii')) | ||
|
|
||
| # font = props["FONT"].split("-") | ||
|
|
||
| # font[4] = bdf_slant[font[4].upper()] | ||
| # font[11] = bdf_spacing[font[11].upper()] | ||
|
|
||
| # ascent = int(props["FONT_ASCENT"]) | ||
| # descent = int(props["FONT_DESCENT"]) | ||
|
|
||
| # fontname = ";".join(font[1:]) | ||
|
|
||
| # print "#", fontname | ||
| # for i in comments: | ||
| # print "#", i | ||
|
|
||
| while True: | ||
| c = bdf_char(fp) | ||
| if not c: | ||
| break | ||
| id, ch, (xy, dst, src), im = c | ||
| if 0 <= ch < len(self.glyph): | ||
| self.glyph[ch] = xy, dst, src, im |
| @@ -0,0 +1,288 @@ | ||
| # | ||
| # The Python Imaging Library. | ||
| # $Id$ | ||
| # | ||
| # BMP file handler | ||
| # | ||
| # Windows (and OS/2) native bitmap storage format. | ||
| # | ||
| # history: | ||
| # 1995-09-01 fl Created | ||
| # 1996-04-30 fl Added save | ||
| # 1997-08-27 fl Fixed save of 1-bit images | ||
| # 1998-03-06 fl Load P images as L where possible | ||
| # 1998-07-03 fl Load P images as 1 where possible | ||
| # 1998-12-29 fl Handle small palettes | ||
| # 2002-12-30 fl Fixed load of 1-bit palette images | ||
| # 2003-04-21 fl Fixed load of 1-bit monochrome images | ||
| # 2003-04-23 fl Added limited support for BI_BITFIELDS compression | ||
| # | ||
| # Copyright (c) 1997-2003 by Secret Labs AB | ||
| # Copyright (c) 1995-2003 by Fredrik Lundh | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
|
|
||
| from PIL import Image, ImageFile, ImagePalette, _binary | ||
| import math | ||
|
|
||
| __version__ = "0.7" | ||
|
|
||
| i8 = _binary.i8 | ||
| i16 = _binary.i16le | ||
| i32 = _binary.i32le | ||
| o8 = _binary.o8 | ||
| o16 = _binary.o16le | ||
| o32 = _binary.o32le | ||
|
|
||
| # | ||
| # -------------------------------------------------------------------- | ||
| # Read BMP file | ||
|
|
||
| BIT2MODE = { | ||
| # bits => mode, rawmode | ||
| 1: ("P", "P;1"), | ||
| 4: ("P", "P;4"), | ||
| 8: ("P", "P"), | ||
| 16: ("RGB", "BGR;15"), | ||
| 24: ("RGB", "BGR"), | ||
| 32: ("RGB", "BGRX"), | ||
| } | ||
|
|
||
|
|
||
| def _accept(prefix): | ||
| return prefix[:2] == b"BM" | ||
|
|
||
|
|
||
| # ============================================================================== | ||
| # Image plugin for the Windows BMP format. | ||
| # ============================================================================== | ||
| class BmpImageFile(ImageFile.ImageFile): | ||
| """ Image plugin for the Windows Bitmap format (BMP) """ | ||
|
|
||
| # -------------------------------------------------------------- Description | ||
| format_description = "Windows Bitmap" | ||
| format = "BMP" | ||
| # --------------------------------------------------- BMP Compression values | ||
| COMPRESSIONS = {'RAW': 0, 'RLE8': 1, 'RLE4': 2, 'BITFIELDS': 3, 'JPEG': 4, 'PNG': 5} | ||
| RAW, RLE8, RLE4, BITFIELDS, JPEG, PNG = 0, 1, 2, 3, 4, 5 | ||
|
|
||
| def _bitmap(self, header=0, offset=0): | ||
| """ Read relevant info about the BMP """ | ||
| read, seek = self.fp.read, self.fp.seek | ||
| if header: | ||
| seek(header) | ||
| file_info = dict() | ||
| file_info['header_size'] = i32(read(4)) # read bmp header size @offset 14 (this is part of the header size) | ||
| file_info['direction'] = -1 | ||
| # --------------------- If requested, read header at a specific position | ||
| header_data = ImageFile._safe_read(self.fp, file_info['header_size'] - 4) # read the rest of the bmp header, without its size | ||
| # --------------------------------------------------- IBM OS/2 Bitmap v1 | ||
| # ------ This format has different offsets because of width/height types | ||
| if file_info['header_size'] == 12: | ||
| file_info['width'] = i16(header_data[0:2]) | ||
| file_info['height'] = i16(header_data[2:4]) | ||
| file_info['planes'] = i16(header_data[4:6]) | ||
| file_info['bits'] = i16(header_data[6:8]) | ||
| file_info['compression'] = self.RAW | ||
| file_info['palette_padding'] = 3 | ||
| # ---------------------------------------------- Windows Bitmap v2 to v5 | ||
| elif file_info['header_size'] in (40, 64, 108, 124): # v3, OS/2 v2, v4, v5 | ||
| if file_info['header_size'] >= 40: # v3 and OS/2 | ||
| file_info['y_flip'] = i8(header_data[7]) == 0xff | ||
| file_info['direction'] = 1 if file_info['y_flip'] else -1 | ||
| file_info['width'] = i32(header_data[0:4]) | ||
| file_info['height'] = i32(header_data[4:8]) if not file_info['y_flip'] else 2**32 - i32(header_data[4:8]) | ||
| file_info['planes'] = i16(header_data[8:10]) | ||
| file_info['bits'] = i16(header_data[10:12]) | ||
| file_info['compression'] = i32(header_data[12:16]) | ||
| file_info['data_size'] = i32(header_data[16:20]) # byte size of pixel data | ||
| file_info['pixels_per_meter'] = (i32(header_data[20:24]), i32(header_data[24:28])) | ||
| file_info['colors'] = i32(header_data[28:32]) | ||
| file_info['palette_padding'] = 4 | ||
| self.info["dpi"] = tuple( | ||
| map(lambda x: int(math.ceil(x / 39.3701)), | ||
| file_info['pixels_per_meter'])) | ||
| if file_info['compression'] == self.BITFIELDS: | ||
| if len(header_data) >= 52: | ||
| for idx, mask in enumerate(['r_mask', 'g_mask', 'b_mask', 'a_mask']): | ||
| file_info[mask] = i32(header_data[36+idx*4:40+idx*4]) | ||
| else: | ||
| for mask in ['r_mask', 'g_mask', 'b_mask', 'a_mask']: | ||
| file_info[mask] = i32(read(4)) | ||
| file_info['rgb_mask'] = (file_info['r_mask'], file_info['g_mask'], file_info['b_mask']) | ||
| file_info['rgba_mask'] = (file_info['r_mask'], file_info['g_mask'], file_info['b_mask'], file_info['a_mask']) | ||
| else: | ||
| raise IOError("Unsupported BMP header type (%d)" % file_info['header_size']) | ||
| # ------------------ Special case : header is reported 40, which | ||
| # ---------------------- is shorter than real size for bpp >= 16 | ||
| self.size = file_info['width'], file_info['height'] | ||
| # -------- If color count was not found in the header, compute from bits | ||
| file_info['colors'] = file_info['colors'] if file_info.get('colors', 0) else (1 << file_info['bits']) | ||
| # -------------------------------- Check abnormal values for DOS attacks | ||
| if file_info['width'] * file_info['height'] > 2**31: | ||
| raise IOError("Unsupported BMP Size: (%dx%d)" % self.size) | ||
| # ----------------------- Check bit depth for unusual unsupported values | ||
| self.mode, raw_mode = BIT2MODE.get(file_info['bits'], (None, None)) | ||
| if self.mode is None: | ||
| raise IOError("Unsupported BMP pixel depth (%d)" % file_info['bits']) | ||
| # ----------------- Process BMP with Bitfields compression (not palette) | ||
| if file_info['compression'] == self.BITFIELDS: | ||
| SUPPORTED = { | ||
| 32: [(0xff0000, 0xff00, 0xff, 0x0), (0xff0000, 0xff00, 0xff, 0xff000000), (0x0, 0x0, 0x0, 0x0)], | ||
| 24: [(0xff0000, 0xff00, 0xff)], | ||
| 16: [(0xf800, 0x7e0, 0x1f), (0x7c00, 0x3e0, 0x1f)] | ||
| } | ||
| MASK_MODES = { | ||
| (32, (0xff0000, 0xff00, 0xff, 0x0)): "BGRX", | ||
| (32, (0xff0000, 0xff00, 0xff, 0xff000000)): "BGRA", | ||
| (32, (0x0, 0x0, 0x0, 0x0)): "BGRA", | ||
| (24, (0xff0000, 0xff00, 0xff)): "BGR", | ||
| (16, (0xf800, 0x7e0, 0x1f)): "BGR;16", | ||
| (16, (0x7c00, 0x3e0, 0x1f)): "BGR;15" | ||
| } | ||
| if file_info['bits'] in SUPPORTED: | ||
| if file_info['bits'] == 32 and file_info['rgba_mask'] in SUPPORTED[file_info['bits']]: | ||
| raw_mode = MASK_MODES[(file_info['bits'], file_info['rgba_mask'])] | ||
| self.mode = "RGBA" if raw_mode in ("BGRA",) else self.mode | ||
| elif file_info['bits'] in (24, 16) and file_info['rgb_mask'] in SUPPORTED[file_info['bits']]: | ||
| raw_mode = MASK_MODES[(file_info['bits'], file_info['rgb_mask'])] | ||
| else: | ||
| raise IOError("Unsupported BMP bitfields layout") | ||
| else: | ||
| raise IOError("Unsupported BMP bitfields layout") | ||
| elif file_info['compression'] == self.RAW: | ||
| if file_info['bits'] == 32 and header == 22: # 32-bit .cur offset | ||
| raw_mode, self.mode = "BGRA", "RGBA" | ||
| else: | ||
| raise IOError("Unsupported BMP compression (%d)" % file_info['compression']) | ||
| # ---------------- Once the header is processed, process the palette/LUT | ||
| if self.mode == "P": # Paletted for 1, 4 and 8 bit images | ||
| # ----------------------------------------------------- 1-bit images | ||
| if not (0 < file_info['colors'] <= 65536): | ||
| raise IOError("Unsupported BMP Palette size (%d)" % file_info['colors']) | ||
| else: | ||
| padding = file_info['palette_padding'] | ||
| palette = read(padding * file_info['colors']) | ||
| greyscale = True | ||
| indices = (0, 255) if file_info['colors'] == 2 else list(range(file_info['colors'])) | ||
| # ------------------ Check if greyscale and ignore palette if so | ||
| for ind, val in enumerate(indices): | ||
| rgb = palette[ind*padding:ind*padding + 3] | ||
| if rgb != o8(val) * 3: | ||
| greyscale = False | ||
| # -------- If all colors are grey, white or black, ditch palette | ||
| if greyscale: | ||
| self.mode = "1" if file_info['colors'] == 2 else "L" | ||
| raw_mode = self.mode | ||
| else: | ||
| self.mode = "P" | ||
| self.palette = ImagePalette.raw("BGRX" if padding == 4 else "BGR", palette) | ||
|
|
||
| # ----------------------------- Finally set the tile data for the plugin | ||
| self.info['compression'] = file_info['compression'] | ||
| self.tile = [('raw', (0, 0, file_info['width'], file_info['height']), offset or self.fp.tell(), | ||
| (raw_mode, ((file_info['width'] * file_info['bits'] + 31) >> 3) & (~3), file_info['direction']) | ||
| )] | ||
|
|
||
| def _open(self): | ||
| """ Open file, check magic number and read header """ | ||
| # read 14 bytes: magic number, filesize, reserved, header final offset | ||
| head_data = self.fp.read(14) | ||
| # choke if the file does not have the required magic bytes | ||
| if head_data[0:2] != b"BM": | ||
| raise SyntaxError("Not a BMP file") | ||
| # read the start position of the BMP image data (u32) | ||
| offset = i32(head_data[10:14]) | ||
| # load bitmap information (offset=raster info) | ||
| self._bitmap(offset=offset) | ||
|
|
||
|
|
||
| # ============================================================================== | ||
| # Image plugin for the DIB format (BMP alias) | ||
| # ============================================================================== | ||
| class DibImageFile(BmpImageFile): | ||
|
|
||
| format = "DIB" | ||
| format_description = "Windows Bitmap" | ||
|
|
||
| def _open(self): | ||
| self._bitmap() | ||
|
|
||
| # | ||
| # -------------------------------------------------------------------- | ||
| # Write BMP file | ||
|
|
||
| SAVE = { | ||
| "1": ("1", 1, 2), | ||
| "L": ("L", 8, 256), | ||
| "P": ("P", 8, 256), | ||
| "RGB": ("BGR", 24, 0), | ||
| "RGBA": ("BGRA", 32, 0), | ||
| } | ||
|
|
||
|
|
||
| def _save(im, fp, filename, check=0): | ||
| try: | ||
| rawmode, bits, colors = SAVE[im.mode] | ||
| except KeyError: | ||
| raise IOError("cannot write mode %s as BMP" % im.mode) | ||
|
|
||
| if check: | ||
| return check | ||
|
|
||
| info = im.encoderinfo | ||
|
|
||
| dpi = info.get("dpi", (96, 96)) | ||
|
|
||
| # 1 meter == 39.3701 inches | ||
| ppm = tuple(map(lambda x: int(x * 39.3701), dpi)) | ||
|
|
||
| stride = ((im.size[0]*bits+7)//8+3) & (~3) | ||
| header = 40 # or 64 for OS/2 version 2 | ||
| offset = 14 + header + colors * 4 | ||
| image = stride * im.size[1] | ||
|
|
||
| # bitmap header | ||
| fp.write(b"BM" + # file type (magic) | ||
| o32(offset+image) + # file size | ||
| o32(0) + # reserved | ||
| o32(offset)) # image data offset | ||
|
|
||
| # bitmap info header | ||
| fp.write(o32(header) + # info header size | ||
| o32(im.size[0]) + # width | ||
| o32(im.size[1]) + # height | ||
| o16(1) + # planes | ||
| o16(bits) + # depth | ||
| o32(0) + # compression (0=uncompressed) | ||
| o32(image) + # size of bitmap | ||
| o32(ppm[0]) + o32(ppm[1]) + # resolution | ||
| o32(colors) + # colors used | ||
| o32(colors)) # colors important | ||
|
|
||
| fp.write(b"\0" * (header - 40)) # padding (for OS/2 format) | ||
|
|
||
| if im.mode == "1": | ||
| for i in (0, 255): | ||
| fp.write(o8(i) * 4) | ||
| elif im.mode == "L": | ||
| for i in range(256): | ||
| fp.write(o8(i) * 4) | ||
| elif im.mode == "P": | ||
| fp.write(im.im.getpalette("RGB", "BGRX")) | ||
|
|
||
| ImageFile._save(im, fp, [("raw", (0, 0)+im.size, 0, | ||
| (rawmode, stride, -1))]) | ||
|
|
||
| # | ||
| # -------------------------------------------------------------------- | ||
| # Registry | ||
|
|
||
| Image.register_open(BmpImageFile.format, BmpImageFile, _accept) | ||
| Image.register_save(BmpImageFile.format, _save) | ||
|
|
||
| Image.register_extension(BmpImageFile.format, ".bmp") | ||
|
|
||
| Image.register_mime(BmpImageFile.format, "image/bmp") |
| @@ -0,0 +1,72 @@ | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # BUFR stub adapter | ||
| # | ||
| # Copyright (c) 1996-2003 by Fredrik Lundh | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
| from PIL import Image, ImageFile | ||
|
|
||
| _handler = None | ||
|
|
||
|
|
||
| ## | ||
| # Install application-specific BUFR image handler. | ||
| # | ||
| # @param handler Handler object. | ||
|
|
||
| def register_handler(handler): | ||
| global _handler | ||
| _handler = handler | ||
|
|
||
|
|
||
| # -------------------------------------------------------------------- | ||
| # Image adapter | ||
|
|
||
| def _accept(prefix): | ||
| return prefix[:4] == b"BUFR" or prefix[:4] == b"ZCZC" | ||
|
|
||
|
|
||
| class BufrStubImageFile(ImageFile.StubImageFile): | ||
|
|
||
| format = "BUFR" | ||
| format_description = "BUFR" | ||
|
|
||
| def _open(self): | ||
|
|
||
| offset = self.fp.tell() | ||
|
|
||
| if not _accept(self.fp.read(8)): | ||
| raise SyntaxError("Not a BUFR file") | ||
|
|
||
| self.fp.seek(offset) | ||
|
|
||
| # make something up | ||
| self.mode = "F" | ||
| self.size = 1, 1 | ||
|
|
||
| loader = self._load() | ||
| if loader: | ||
| loader.open(self) | ||
|
|
||
| def _load(self): | ||
| return _handler | ||
|
|
||
|
|
||
| def _save(im, fp, filename): | ||
| if _handler is None or not hasattr("_handler", "save"): | ||
| raise IOError("BUFR save handler not installed") | ||
| _handler.save(im, fp, filename) | ||
|
|
||
|
|
||
| # -------------------------------------------------------------------- | ||
| # Registry | ||
|
|
||
| Image.register_open(BufrStubImageFile.format, BufrStubImageFile, _accept) | ||
| Image.register_save(BufrStubImageFile.format, _save) | ||
|
|
||
| Image.register_extension(BufrStubImageFile.format, ".bufr") |
| @@ -0,0 +1,117 @@ | ||
| # | ||
| # The Python Imaging Library. | ||
| # $Id$ | ||
| # | ||
| # a class to read from a container file | ||
| # | ||
| # History: | ||
| # 1995-06-18 fl Created | ||
| # 1995-09-07 fl Added readline(), readlines() | ||
| # | ||
| # Copyright (c) 1997-2001 by Secret Labs AB | ||
| # Copyright (c) 1995 by Fredrik Lundh | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
| ## | ||
| # A file object that provides read access to a part of an existing | ||
| # file (for example a TAR file). | ||
|
|
||
|
|
||
| class ContainerIO(object): | ||
|
|
||
| ## | ||
| # Create file object. | ||
| # | ||
| # @param file Existing file. | ||
| # @param offset Start of region, in bytes. | ||
| # @param length Size of region, in bytes. | ||
|
|
||
| def __init__(self, file, offset, length): | ||
| self.fh = file | ||
| self.pos = 0 | ||
| self.offset = offset | ||
| self.length = length | ||
| self.fh.seek(offset) | ||
|
|
||
| ## | ||
| # Always false. | ||
|
|
||
| def isatty(self): | ||
| return 0 | ||
|
|
||
| ## | ||
| # Move file pointer. | ||
| # | ||
| # @param offset Offset in bytes. | ||
| # @param mode Starting position. Use 0 for beginning of region, 1 | ||
| # for current offset, and 2 for end of region. You cannot move | ||
| # the pointer outside the defined region. | ||
|
|
||
| def seek(self, offset, mode=0): | ||
| if mode == 1: | ||
| self.pos = self.pos + offset | ||
| elif mode == 2: | ||
| self.pos = self.length + offset | ||
| else: | ||
| self.pos = offset | ||
| # clamp | ||
| self.pos = max(0, min(self.pos, self.length)) | ||
| self.fh.seek(self.offset + self.pos) | ||
|
|
||
| ## | ||
| # Get current file pointer. | ||
| # | ||
| # @return Offset from start of region, in bytes. | ||
|
|
||
| def tell(self): | ||
| return self.pos | ||
|
|
||
| ## | ||
| # Read data. | ||
| # | ||
| # @def read(bytes=0) | ||
| # @param bytes Number of bytes to read. If omitted or zero, | ||
| # read until end of region. | ||
| # @return An 8-bit string. | ||
|
|
||
| def read(self, n=0): | ||
| if n: | ||
| n = min(n, self.length - self.pos) | ||
| else: | ||
| n = self.length - self.pos | ||
| if not n: # EOF | ||
| return "" | ||
| self.pos = self.pos + n | ||
| return self.fh.read(n) | ||
|
|
||
| ## | ||
| # Read a line of text. | ||
| # | ||
| # @return An 8-bit string. | ||
|
|
||
| def readline(self): | ||
| s = "" | ||
| while True: | ||
| c = self.read(1) | ||
| if not c: | ||
| break | ||
| s = s + c | ||
| if c == "\n": | ||
| break | ||
| return s | ||
|
|
||
| ## | ||
| # Read multiple lines of text. | ||
| # | ||
| # @return A list of 8-bit strings. | ||
|
|
||
| def readlines(self): | ||
| l = [] | ||
| while True: | ||
| s = self.readline() | ||
| if not s: | ||
| break | ||
| l.append(s) | ||
| return l |
| @@ -0,0 +1,88 @@ | ||
| # | ||
| # The Python Imaging Library. | ||
| # $Id$ | ||
| # | ||
| # Windows Cursor support for PIL | ||
| # | ||
| # notes: | ||
| # uses BmpImagePlugin.py to read the bitmap data. | ||
| # | ||
| # history: | ||
| # 96-05-27 fl Created | ||
| # | ||
| # Copyright (c) Secret Labs AB 1997. | ||
| # Copyright (c) Fredrik Lundh 1996. | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
|
|
||
| from PIL import Image, BmpImagePlugin, _binary | ||
|
|
||
| __version__ = "0.1" | ||
|
|
||
| # | ||
| # -------------------------------------------------------------------- | ||
|
|
||
| i8 = _binary.i8 | ||
| i16 = _binary.i16le | ||
| i32 = _binary.i32le | ||
|
|
||
|
|
||
| def _accept(prefix): | ||
| return prefix[:4] == b"\0\0\2\0" | ||
|
|
||
|
|
||
| ## | ||
| # Image plugin for Windows Cursor files. | ||
|
|
||
| class CurImageFile(BmpImagePlugin.BmpImageFile): | ||
|
|
||
| format = "CUR" | ||
| format_description = "Windows Cursor" | ||
|
|
||
| def _open(self): | ||
|
|
||
| offset = self.fp.tell() | ||
|
|
||
| # check magic | ||
| s = self.fp.read(6) | ||
| if not _accept(s): | ||
| raise SyntaxError("not a CUR file") | ||
|
|
||
| # pick the largest cursor in the file | ||
| m = b"" | ||
| for i in range(i16(s[4:])): | ||
| s = self.fp.read(16) | ||
| if not m: | ||
| m = s | ||
| elif i8(s[0]) > i8(m[0]) and i8(s[1]) > i8(m[1]): | ||
| m = s | ||
| # print "width", i8(s[0]) | ||
| # print "height", i8(s[1]) | ||
| # print "colors", i8(s[2]) | ||
| # print "reserved", i8(s[3]) | ||
| # print "hotspot x", i16(s[4:]) | ||
| # print "hotspot y", i16(s[6:]) | ||
| # print "bytes", i32(s[8:]) | ||
| # print "offset", i32(s[12:]) | ||
| if not m: | ||
| raise TypeError("No cursors were found") | ||
|
|
||
| # load as bitmap | ||
| self._bitmap(i32(m[12:]) + offset) | ||
|
|
||
| # patch up the bitmap height | ||
| self.size = self.size[0], self.size[1]//2 | ||
| d, e, o, a = self.tile[0] | ||
| self.tile[0] = d, (0, 0)+self.size, o, a | ||
|
|
||
| return | ||
|
|
||
|
|
||
| # | ||
| # -------------------------------------------------------------------- | ||
|
|
||
| Image.register_open(CurImageFile.format, CurImageFile, _accept) | ||
|
|
||
| Image.register_extension(CurImageFile.format, ".cur") |
| @@ -0,0 +1,86 @@ | ||
| # | ||
| # The Python Imaging Library. | ||
| # $Id$ | ||
| # | ||
| # DCX file handling | ||
| # | ||
| # DCX is a container file format defined by Intel, commonly used | ||
| # for fax applications. Each DCX file consists of a directory | ||
| # (a list of file offsets) followed by a set of (usually 1-bit) | ||
| # PCX files. | ||
| # | ||
| # History: | ||
| # 1995-09-09 fl Created | ||
| # 1996-03-20 fl Properly derived from PcxImageFile. | ||
| # 1998-07-15 fl Renamed offset attribute to avoid name clash | ||
| # 2002-07-30 fl Fixed file handling | ||
| # | ||
| # Copyright (c) 1997-98 by Secret Labs AB. | ||
| # Copyright (c) 1995-96 by Fredrik Lundh. | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
| from PIL import Image, _binary | ||
| from PIL.PcxImagePlugin import PcxImageFile | ||
|
|
||
| __version__ = "0.2" | ||
|
|
||
| MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then? | ||
|
|
||
| i32 = _binary.i32le | ||
|
|
||
|
|
||
| def _accept(prefix): | ||
| return len(prefix) >= 4 and i32(prefix) == MAGIC | ||
|
|
||
|
|
||
| ## | ||
| # Image plugin for the Intel DCX format. | ||
|
|
||
| class DcxImageFile(PcxImageFile): | ||
|
|
||
| format = "DCX" | ||
| format_description = "Intel DCX" | ||
|
|
||
| def _open(self): | ||
|
|
||
| # Header | ||
| s = self.fp.read(4) | ||
| if i32(s) != MAGIC: | ||
| raise SyntaxError("not a DCX file") | ||
|
|
||
| # Component directory | ||
| self._offset = [] | ||
| for i in range(1024): | ||
| offset = i32(self.fp.read(4)) | ||
| if not offset: | ||
| break | ||
| self._offset.append(offset) | ||
|
|
||
| self.__fp = self.fp | ||
| self.seek(0) | ||
|
|
||
| @property | ||
| def n_frames(self): | ||
| return len(self._offset) | ||
|
|
||
| @property | ||
| def is_animated(self): | ||
| return len(self._offset) > 1 | ||
|
|
||
| def seek(self, frame): | ||
| if frame >= len(self._offset): | ||
| raise EOFError("attempt to seek outside DCX directory") | ||
| self.frame = frame | ||
| self.fp = self.__fp | ||
| self.fp.seek(self._offset[frame]) | ||
| PcxImageFile._open(self) | ||
|
|
||
| def tell(self): | ||
| return self.frame | ||
|
|
||
|
|
||
| Image.register_open(DcxImageFile.format, DcxImageFile, _accept) | ||
|
|
||
| Image.register_extension(DcxImageFile.format, ".dcx") |
| @@ -0,0 +1,193 @@ | ||
| # | ||
| # The Python Imaging Library. | ||
| # $Id$ | ||
| # | ||
| # EXIF tags | ||
| # | ||
| # Copyright (c) 2003 by Secret Labs AB | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
| ## | ||
| # This module provides constants and clear-text names for various | ||
| # well-known EXIF tags. | ||
| ## | ||
|
|
||
| ## | ||
| # Maps EXIF tags to tag names. | ||
|
|
||
| TAGS = { | ||
|
|
||
| # possibly incomplete | ||
| 0x00fe: "NewSubfileType", | ||
| 0x00ff: "SubfileType", | ||
| 0x0100: "ImageWidth", | ||
| 0x0101: "ImageLength", | ||
| 0x0102: "BitsPerSample", | ||
| 0x0103: "Compression", | ||
| 0x0106: "PhotometricInterpretation", | ||
| 0x0107: "Threshholding", | ||
| 0x0108: "CellWidth", | ||
| 0x0109: "CellLenght", | ||
| 0x010a: "FillOrder", | ||
| 0x010d: "DocumentName", | ||
| 0x011d: "PageName", | ||
| 0x010e: "ImageDescription", | ||
| 0x010f: "Make", | ||
| 0x0110: "Model", | ||
| 0x0111: "StripOffsets", | ||
| 0x0112: "Orientation", | ||
| 0x0115: "SamplesPerPixel", | ||
| 0x0116: "RowsPerStrip", | ||
| 0x0117: "StripByteConunts", | ||
| 0x0118: "MinSampleValue", | ||
| 0x0119: "MaxSampleValue", | ||
| 0x011a: "XResolution", | ||
| 0x011b: "YResolution", | ||
| 0x011c: "PlanarConfiguration", | ||
| 0x0120: "FreeOffsets", | ||
| 0x0121: "FreeByteCounts", | ||
| 0x0122: "GrayResponseUnit", | ||
| 0x0123: "GrayResponseCurve", | ||
| 0x0128: "ResolutionUnit", | ||
| 0x012d: "TransferFunction", | ||
| 0x0131: "Software", | ||
| 0x0132: "DateTime", | ||
| 0x013b: "Artist", | ||
| 0x013c: "HostComputer", | ||
| 0x013e: "WhitePoint", | ||
| 0x013f: "PrimaryChromaticities", | ||
| 0x0140: "ColorMap", | ||
| 0x0152: "ExtraSamples", | ||
| 0x0201: "JpegIFOffset", | ||
| 0x0202: "JpegIFByteCount", | ||
| 0x0211: "YCbCrCoefficients", | ||
| 0x0212: "YCbCrSubSampling", | ||
| 0x0213: "YCbCrPositioning", | ||
| 0x0214: "ReferenceBlackWhite", | ||
| 0x1000: "RelatedImageFileFormat", | ||
| 0x1001: "RelatedImageWidth", | ||
| 0x1002: "RelatedImageLength", | ||
| 0x828d: "CFARepeatPatternDim", | ||
| 0x828e: "CFAPattern", | ||
| 0x828f: "BatteryLevel", | ||
| 0x8298: "Copyright", | ||
| 0x829a: "ExposureTime", | ||
| 0x829d: "FNumber", | ||
| 0x8769: "ExifOffset", | ||
| 0x8773: "InterColorProfile", | ||
| 0x8822: "ExposureProgram", | ||
| 0x8824: "SpectralSensitivity", | ||
| 0x8825: "GPSInfo", | ||
| 0x8827: "ISOSpeedRatings", | ||
| 0x8828: "OECF", | ||
| 0x8829: "Interlace", | ||
| 0x882a: "TimeZoneOffset", | ||
| 0x882b: "SelfTimerMode", | ||
| 0x9000: "ExifVersion", | ||
| 0x9003: "DateTimeOriginal", | ||
| 0x9004: "DateTimeDigitized", | ||
| 0x9101: "ComponentsConfiguration", | ||
| 0x9102: "CompressedBitsPerPixel", | ||
| 0x9201: "ShutterSpeedValue", | ||
| 0x9202: "ApertureValue", | ||
| 0x9203: "BrightnessValue", | ||
| 0x9204: "ExposureBiasValue", | ||
| 0x9205: "MaxApertureValue", | ||
| 0x9206: "SubjectDistance", | ||
| 0x9207: "MeteringMode", | ||
| 0x9208: "LightSource", | ||
| 0x9209: "Flash", | ||
| 0x920a: "FocalLength", | ||
| 0x920b: "FlashEnergy", | ||
| 0x920c: "SpatialFrequencyResponse", | ||
| 0x920d: "Noise", | ||
| 0x9211: "ImageNumber", | ||
| 0x9212: "SecurityClassification", | ||
| 0x9213: "ImageHistory", | ||
| 0x9214: "SubjectLocation", | ||
| 0x9215: "ExposureIndex", | ||
| 0x9216: "TIFF/EPStandardID", | ||
| 0x927c: "MakerNote", | ||
| 0x9286: "UserComment", | ||
| 0x9290: "SubsecTime", | ||
| 0x9291: "SubsecTimeOriginal", | ||
| 0x9292: "SubsecTimeDigitized", | ||
| 0xa000: "FlashPixVersion", | ||
| 0xa001: "ColorSpace", | ||
| 0xa002: "ExifImageWidth", | ||
| 0xa003: "ExifImageHeight", | ||
| 0xa004: "RelatedSoundFile", | ||
| 0xa005: "ExifInteroperabilityOffset", | ||
| 0xa20b: "FlashEnergy", | ||
| 0xa20c: "SpatialFrequencyResponse", | ||
| 0xa20e: "FocalPlaneXResolution", | ||
| 0xa20f: "FocalPlaneYResolution", | ||
| 0xa210: "FocalPlaneResolutionUnit", | ||
| 0xa214: "SubjectLocation", | ||
| 0xa215: "ExposureIndex", | ||
| 0xa217: "SensingMethod", | ||
| 0xa300: "FileSource", | ||
| 0xa301: "SceneType", | ||
| 0xa302: "CFAPattern", | ||
| 0xa401: "CustomRendered", | ||
| 0xa402: "ExposureMode", | ||
| 0xa403: "WhiteBalance", | ||
| 0xa404: "DigitalZoomRatio", | ||
| 0xa405: "FocalLengthIn35mmFilm", | ||
| 0xa406: "SceneCaptureType", | ||
| 0xa407: "GainControl", | ||
| 0xa408: "Contrast", | ||
| 0xa409: "Saturation", | ||
| 0xa40a: "Sharpness", | ||
| 0xa40b: "DeviceSettingDescription", | ||
| 0xa40c: "SubjectDistanceRange", | ||
| 0xa420: "ImageUniqueID", | ||
| 0xa430: "CameraOwnerName", | ||
| 0xa431: "BodySerialNumber", | ||
| 0xa432: "LensSpecification", | ||
| 0xa433: "LensMake", | ||
| 0xa434: "LensModel", | ||
| 0xa435: "LensSerialNumber", | ||
| 0xa500: "Gamma", | ||
|
|
||
| } | ||
|
|
||
| ## | ||
| # Maps EXIF GPS tags to tag names. | ||
|
|
||
| GPSTAGS = { | ||
| 0: "GPSVersionID", | ||
| 1: "GPSLatitudeRef", | ||
| 2: "GPSLatitude", | ||
| 3: "GPSLongitudeRef", | ||
| 4: "GPSLongitude", | ||
| 5: "GPSAltitudeRef", | ||
| 6: "GPSAltitude", | ||
| 7: "GPSTimeStamp", | ||
| 8: "GPSSatellites", | ||
| 9: "GPSStatus", | ||
| 10: "GPSMeasureMode", | ||
| 11: "GPSDOP", | ||
| 12: "GPSSpeedRef", | ||
| 13: "GPSSpeed", | ||
| 14: "GPSTrackRef", | ||
| 15: "GPSTrack", | ||
| 16: "GPSImgDirectionRef", | ||
| 17: "GPSImgDirection", | ||
| 18: "GPSMapDatum", | ||
| 19: "GPSDestLatitudeRef", | ||
| 20: "GPSDestLatitude", | ||
| 21: "GPSDestLongitudeRef", | ||
| 22: "GPSDestLongitude", | ||
| 23: "GPSDestBearingRef", | ||
| 24: "GPSDestBearing", | ||
| 25: "GPSDestDistanceRef", | ||
| 26: "GPSDestDistance", | ||
| 27: "GPSProcessingMethod", | ||
| 28: "GPSAreaInformation", | ||
| 29: "GPSDateStamp", | ||
| 30: "GPSDifferential", | ||
| 31: "GPSHPositioningError", | ||
| } |
| @@ -0,0 +1,76 @@ | ||
| # | ||
| # The Python Imaging Library | ||
| # $Id$ | ||
| # | ||
| # FITS stub adapter | ||
| # | ||
| # Copyright (c) 1998-2003 by Fredrik Lundh | ||
| # | ||
| # See the README file for information on usage and redistribution. | ||
| # | ||
|
|
||
| from PIL import Image, ImageFile | ||
|
|
||
| _handler = None | ||
|
|
||
| ## | ||
| # Install application-specific FITS image handler. | ||
| # | ||
| # @param handler Handler object. | ||
|
|
||
|
|
||
| def register_handler(handler): | ||
| global _handler | ||
| _handler = handler | ||
|
|
||
| # -------------------------------------------------------------------- | ||
| # Image adapter | ||
|
|
||
|
|
||
| def _accept(prefix): | ||
| return prefix[:6] == b"SIMPLE" | ||
|
|
||
|
|
||
| class FITSStubImageFile(ImageFile.StubImageFile): | ||
|
|
||
| format = "FITS" | ||
| format_description = "FITS" | ||
|
|
||
| def _open(self): | ||
|
|
||
| offset = self.fp.tell() | ||
|
|
||
| if not _accept(self.fp.read(6)): | ||
| raise SyntaxError("Not a FITS file") | ||
|
|
||
| # FIXME: add more sanity checks here; mandatory header items | ||
| # include SIMPLE, BITPIX, NAXIS, etc. | ||
|
|
||
| self.fp.seek(offset) | ||
|
|
||
| # make something up | ||
| self.mode = "F" | ||
| self.size = 1, 1 | ||
|
|
||
| loader = self._load() | ||
| if loader: | ||
| loader.open(self) | ||
|
|
||
| def _load(self): | ||
| return _handler | ||
|
|
||
|
|
||
| def _save(im, fp, filename): | ||
| if _handler is None or not hasattr("_handler", "save"): | ||
| raise IOError("FITS save handler not installed") | ||
| _handler.save(im, fp, filename) | ||
|
|
||
|
|
||
| # -------------------------------------------------------------------- | ||
| # Registry | ||
|
|
||
| Image.register_open(FITSStubImageFile.format, FITSStubImageFile, _accept) | ||
| Image.register_save(FITSStubImageFile.format, _save) | ||
|
|
||
| Image.register_extension(FITSStubImageFile.format, ".fit") | ||
| Image.register_extension(FITSStubImageFile.format, ".fits") |