def __init__(self, imageURL, badgeURL): ''' Constructor ''' self.imageURL = imageURL self.badgeURL = badgeURL self.image = None self.badge = None Image.init()
def install_Image(lis): import Image # PIL uses lazy initialization. # you candecide if you want only the # default stuff: Image.preinit() # or just everything: Image.init() import sys for name in sys.modules: if name[-11:] == "ImagePlugin": lis.append(name)
def __init__(self, scriptaction): """ The constructor called if the Exporter class got instanciated and imports our needed modules to be sure there are available. """ try: import Kross except: raise "Failed to import the Kross module." try: import Krita except: raise "Failed to import the Krita module." try: import Image, ImageFile Image.init() except: raise "Failed to import the Python Imaging Library (PIL)." self.scriptaction = scriptaction self.showDialog()
has_bioformats = True except: has_bioformats = False import Image as PILImage import TiffImagePlugin as TIFF import cellprofiler.dib import matplotlib.image import scipy.io.matlab.mio import cellprofiler.cpmodule as cpmodule import cellprofiler.cpimage as cpimage import cellprofiler.measurements as cpm import cellprofiler.preferences as preferences import cellprofiler.settings as cps PILImage.init() FF_INDIVIDUAL_IMAGES = 'individual images' FF_STK_MOVIES = 'stk movies' FF_AVI_MOVIES = 'avi movies' FF_OTHER_MOVIES = 'tif,tiff,flex movies' if has_bioformats: FF_CHOICES = [FF_INDIVIDUAL_IMAGES, FF_STK_MOVIES, FF_AVI_MOVIES, FF_OTHER_MOVIES] else: FF_CHOICES = [FF_INDIVIDUAL_IMAGES, FF_STK_MOVIES] # The metadata choices: # M_NONE - don't extract metadata # M_FILE_NAME - extract metadata from the file name # M_PATH_NAME - extract metadata from the subdirectory path # M_BOTH - extract metadata from both the file name and path
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, v: print v sys.exit(1) printer = None # 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 printer = "lpr" elif o == "-P": # printer channel printer = "lpr -P%s" % a for file in argv: try:
def extensions(): '''Return accepted extensions for this loader''' PILImage.init() return tuple((ext_with_dot[1:] for ext_with_dot in PILImage.EXTENSION))
p = Picture(sha1hash = sha1hash, md5hash = md5hash, width=width, height=height, datasize = len(data), mimetype = mimetype, owner = owner, visibility = visibility, camera = camera, created_time = created_time, created_time_us = created_time.microsecond, orientation = orientation, **kwargs) p.save() try: m = Media.store(p.mediakey('orig'), data, sha1hash) except Exception, e: p.delete() raise e if tags: p.addtags(tags) return p PIL.init() # load all codecs for t in [ v for v in PIL.MIME.values() if v.startswith('image/') ]: register_importer(t, still_image_importer) __all__ = [ 'importer', 'ImageProcessor' ]