Example #1
0
 def get_dimensions(self):
     width = ffi.new("int*")
     height = ffi.new("int*")
     in_data_len = len(self._data)
     in_data_p = ffi.new("unsigned char[]", in_data_len)
     inbuf = ffi.buffer(in_data_p, in_data_len)
     inbuf[:] = self._data
     img = ffi.gc(lib.epeg_memory_open(in_data_p, in_data_len),
                  lib.epeg_close)
     lib.epeg_size_get(img, width, height)
     return (width[0], height[0])
Example #2
0
 def get_dimensions(self):
     width = ffi.new("int*")
     height = ffi.new("int*")
     in_data_len = len(self._data)
     in_data_p = ffi.new("unsigned char[]", in_data_len)
     inbuf = ffi.buffer(in_data_p, in_data_len)
     inbuf[:] = self._data
     img = ffi.gc(lib.epeg_memory_open(in_data_p, in_data_len),
                  lib.epeg_close)
     lib.epeg_size_get(img, width, height)
     return (width[0], height[0])
Example #3
0
    def scale(self, width, height, quality=75):
        in_data_len = len(self._data)
        in_data_p = ffi.new("unsigned char[]", in_data_len)
        inbuf = ffi.buffer(in_data_p, in_data_len)
        inbuf[:] = self._data
        img = ffi.gc(lib.epeg_memory_open(in_data_p, in_data_len),
                     lib.epeg_close)
        lib.epeg_decode_size_set(img, width, height)
        lib.epeg_quality_set(img, quality)

        pdata = ffi.gc(ffi.new("unsigned char **"), _epeg_free_buffer)
        psize = ffi.new("int*")
        lib.epeg_memory_output_set(img, pdata, psize)
        lib.epeg_encode(img)

        _weak_keydict[pdata[0]] = pdata
        return bytearray(ffi.buffer(pdata[0], psize[0])[:])
Example #4
0
    def scale(self, width, height, quality=75):
        in_data_len = len(self._data)
        in_data_p = ffi.new("unsigned char[]", in_data_len)
        inbuf = ffi.buffer(in_data_p, in_data_len)
        inbuf[:] = self._data
        img = ffi.gc(lib.epeg_memory_open(in_data_p, in_data_len),
                     lib.epeg_close)
        lib.epeg_decode_size_set(img, width, height)
        lib.epeg_quality_set(img, quality)

        pdata = ffi.gc(ffi.new("unsigned char **"), _epeg_free_buffer)
        psize = ffi.new("int*")
        lib.epeg_memory_output_set(img, pdata, psize)
        lib.epeg_encode(img)

        _weak_keydict[pdata[0]] = pdata
        return bytearray(ffi.buffer(pdata[0], psize[0])[:])