Esempio n. 1
0
    def save(self, data):
        if _im is None:
            raise NotImplementedError

        d = data[0]
        if isinstance(d, _RGB):
            s = list(d.shape)
            s.append(3)
#            c = _core.ndarray(s, buffer=d.data, dtype=_core._uint8)
            c = _core.zeros(s, dtype=_core._uint8)
#            print d.red
            c[...,0] = d.get_red(dtype=_core._uint8)
            c[...,1] = d.get_green(dtype=_core._uint8)
            c[...,2] = d.get_blue(dtype=_core._uint8)
            d = c
        try:
            if d.dtype == _core.int64:
                im = _im.fromarray(d, mode='I')
            else:
                im = _im.fromarray(d)
        except:
            if d.dtype == _core._uint16: # trap a known PIL 1.1.7 TIFF bug
                im = _im.frombuffer("I;16", tuple(reversed(d.shape)), d.data, 'raw', "I;16", 0, 1)
            else:
                raise
        im.save(self.name)
Esempio n. 2
0
    def save(self, data):
        if _im is None:
            raise NotImplementedError

        d = data[0]
        if isinstance(d, _RGB):
            s = list(d.shape)
            s.append(3)
            #            c = _core.ndarray(s, buffer=d.data, dtype=_core._uint8)
            c = _core.zeros(s, dtype=_core._uint8)
            #            print d.red
            c[..., 0] = d.get_red(dtype=_core._uint8)
            c[..., 1] = d.get_green(dtype=_core._uint8)
            c[..., 2] = d.get_blue(dtype=_core._uint8)
            d = c
        try:
            if d.dtype == _core.int64:
                im = _im.fromarray(d, mode='I')
            else:
                im = _im.fromarray(d)
        except:
            if d.dtype == _core._uint16:  # trap a known PIL 1.1.7 TIFF bug
                im = _im.frombuffer("I;16", tuple(reversed(d.shape)), d.data,
                                    'raw', "I;16", 0, 1)
            else:
                raise
        im.save(self.name)
Esempio n. 3
0
    def save(self, data):
        if _im is None:
            raise NotImplementedError

        d = data[0]
        if isinstance(d, _RGB):
            s = list(d.shape)
            s.append(3)
            c = _core.zeros(s, dtype=_core._uint8)
            c[...,0] = d['r']
            c[...,1] = d['g']
            c[...,2] = d['b']
            d = c
        im = _im.fromarray(d)
        im.save(self.name)
Esempio n. 4
0
    def save(self, data):
        if _im is None:
            raise NotImplementedError

        d = data[0]
        if isinstance(d, _RGB):
            s = list(d.shape)
            s.append(3)
#            c = _core.ndarray(s, buffer=d.data, dtype=_core._uint8)
            c = _core.zeros(s, dtype=_core._uint8)
#            print d.red
            c[...,0] = d.get_red(dtype=_core._uint8)
            c[...,1] = d.get_green(dtype=_core._uint8)
            c[...,2] = d.get_blue(dtype=_core._uint8)
            d = c
        im = _im.fromarray(d)
        im.save(self.name)
Esempio n. 5
0
    def save(self, data):
        if _im is None:
            raise NotImplementedError

        d = data[0]
        if isinstance(d, _RGB):
            s = list(d.shape)
            s.append(3)
            #            c = _core.ndarray(s, buffer=d.data, dtype=_core._uint8)
            c = _core.zeros(s, dtype=_core._uint8)
            #            print d.red
            c[..., 0] = d.get_red(dtype=_core._uint8)
            c[..., 1] = d.get_green(dtype=_core._uint8)
            c[..., 2] = d.get_blue(dtype=_core._uint8)
            d = c
        if d.dtype == _core.int64:
            im = _im.fromarray(d, mode='I')
        else:
            im = _im.fromarray(d)
        im.save(self.name)