How to use the imageio.formats.add_format function in imageio

To help you get started, we’ve selected a few imageio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imageio / imageio / imageio / plugins / feisem.py View on Github external
except ValueError:
                                    continue
                                else:
                                    break
                            md[current_tag][key] = val
            if not md["root"] and len(md) == 1:
                raise ValueError("Input file %s contains no FEI metadata." % filename)
            self._meta.update(md)
            return md


# Register plugin
format = FEISEMFormat(
    "fei", "FEI-SEM TIFF format", extensions=[".tif", ".tiff"], modes="iv"
)
formats.add_format(format)
github imageio / imageio / imageio / plugins / pillow.py View on Github external
def register_pillow_formats():

    for id, summary, ext in pillow_formats:
        if id in IGNORE_FORMATS:
            continue
        FormatCls = SPECIAL_FORMATS.get(id, PillowFormat)
        summary = FormatCls._description or summary
        format = FormatCls(id + "-PIL", summary, ext, FormatCls._modes)
        format._plugin_id = id
        if FormatCls is PillowFormat or not FormatCls.__doc__:
            format.__doc__ = pillow_docs[id] + GENERIC_DOCS
        formats.add_format(format)
github imageio / imageio / imageio / plugins / animatedgif.py View on Github external
sub1.set_image_data(im)
            # Quantize it if its RGB or RGBA
            sub2 = sub1
            if im.ndim == 3 and im.shape[2] in (3, 4):
                sub2 = sub1.quantize(self._quantizer, self._palettesize)
            sub2.set_meta_data(meta)
            # Add
            self._bm.append_bitmap(sub2)
            sub1.close()
            sub2.close()
        
        def set_meta_data(self, meta):
            self._meta.update(meta)


formats.add_format(AnimatedGifFormat('ANIGIF', 'Animated gif', '.gif'))
github imageio / imageio / imageio / plugins / simpleitk.py View on Github external
def _close(self):
            pass

        def _append_data(self, im, meta):
            _itk_img = _itk.GetImageFromArray(im)
            _write_function(_itk_img, self.request.get_local_filename())

        def set_meta_data(self, meta):
            error_msg = "The itk plugin does not support meta data, currently."
            raise RuntimeError(error_msg)


# Register
title = "Insight Segmentation and Registration Toolkit (ITK) format"
format = ItkFormat("itk", title, " ".join(ALL_FORMATS), "iIvV")
formats.add_format(format)
github imageio / imageio / imageio / plugins / freeimage.py View on Github external
def _create_predefined_freeimage_formats():

    for name, i, des, ext in fiformats:
        # name = NAME_MAP.get(name, name)
        # Get class for format
        FormatClass = SPECIAL_CLASSES.get(name.lower(), FreeimageFormat)
        if FormatClass:
            # Create Format and add
            format = FormatClass(name + "-FI", des, ext, FormatClass._modes)
            format._fif = i
            formats.add_format(format)
github imageio / imageio / imageio / plugins / spe.py View on Github external
second element is the y axis value.
    """
    l = []
    a = a[["startx", "starty", "endx", "endy", "groupx", "groupy"]]
    for sx, sy, ex, ey, gx, gy in a:
        d = {
            "top_left": [int(sx), int(sy)],
            "bottom_right": [int(ex), int(ey)],
            "bin": [int(gx), int(gy)],
        }
        l.append(d)
    return l


fmt = SpeFormat("spe", "SPE file format", ".spe", "iIvV")
formats.add_format(fmt, overwrite=True)
github imageio / imageio / imageio / plugins / bsdf.py View on Github external
file = self.request.get_file()
                self._serializer.save(file, ob)
            else:
                self._stream.append(ob)

        def set_meta_data(self, meta):  # pragma: no cover
            raise RuntimeError("The BSDF format only supports " "per-image meta data.")


format = BsdfFormat(
    "bsdf",  # short name
    "Format based on the Binary Structured Data Format",
    ".bsdf",
    "iIvV",
)
formats.add_format(format)
github imageio / imageio / imageio / plugins / freeimage.py View on Github external
for i in range(lib.FreeImage_GetFIFCount()):
        if lib.FreeImage_IsPluginEnabled(i):
            # Get info
            name = lib.FreeImage_GetFormatFromFIF(i).decode("ascii")
            des = lib.FreeImage_GetFIFDescription(i).decode("ascii")
            ext = lib.FreeImage_GetFIFExtensionList(i).decode("ascii")
            fiformats.append((name, i, des, ext))
            # name = NAME_MAP.get(name, name)
            # Get class for format
            FormatClass = SPECIAL_CLASSES.get(name.lower(), FreeimageFormat)
            if not FormatClass:
                continue
            # Create Format and add
            format = FormatClass(name + "-FI", des, ext, FormatClass._modes)
            format._fif = i
            formats.add_format(format, overwrite=True)
github imageio / imageio / imageio / plugins / lytro.py View on Github external
def _create_predefined_lytro_formats():
    for name, des, ext, i in file_formats:
        # Get format class for format
        format_class = SPECIAL_CLASSES.get(name.lower(), LytroFormat)
        if format_class:
            # Create Format and add
            format = format_class(name, des, ext, i)
            formats.add_format(format=format)
github imageio / imageio / imageio / plugins / swf.py View on Github external
<title>Show Flash animation %s</title>


    

"""

# Register. You register an *instance* of a Format class. Here specify:
format = SWFFormat(
    "swf",  # shot name
    "Shockwave flash",  # one line descr.
    ".swf",  # list of extensions as a space separated string
    "I",  # modes, characters in iIvV
)
formats.add_format(format)