(data)
return source
Make a new source from a memory object.

        Make a new source that is attached to the memory object. For example::

            source = pyvips.Source.new_from_memory("myfile.jpg")

        You can pass this source to (for example) :meth:`new_from_source`.

        The memory object can be anything that supports the Python buffer or
        memoryview protocol.
Make a new source from a memory object.
Make a new source from a memory object .
def new_from_memory(data):
        """Make a new source from a memory object.

        Make a new source that is attached to the memory object. For example::

            source = pyvips.Source.new_from_memory("myfile.jpg")

        You can pass this source to (for example) :meth:`new_from_source`.

        The memory object can be anything that supports the Python buffer or
        memoryview protocol.

        """

        # logger.debug('VipsSource.new_from_memory:')

        # py3:
        #   - memoryview has .nbytes for number of bytes in object
        #   - len() returns number of elements in top array
        # py2:
        #   - buffer has no nbytes member
        #   - but len() gives number of bytes in object
        start = ffi.from_buffer(data)
        nbytes = data.nbytes if hasattr(data, 'nbytes') else len(data)

        pointer = vips_lib.vips_source_new_from_memory(start, nbytes)
        if pointer == ffi.NULL:
            raise Error("can't create input source from memory")

        source = Source(pointer)

        # keep a secret reference to the input data to make sure it's not GCed
        source._references = [data]

        return source
def new_from_memory ( data ) : # logger.debug('VipsSource.new_from_memory:') # py3: #   - memoryview has .nbytes for number of bytes in object #   - len() returns number of elements in top array # py2: #   - buffer has no nbytes member #   - but len() gives number of bytes in object start = ffi . from_buffer ( data ) nbytes = data . nbytes if hasattr ( data , 'nbytes' ) else len ( data ) pointer = vips_lib . vips_source_new_from_memory ( start , nbytes ) if pointer == ffi . NULL : raise Error ( "can't create input source from memory" ) source = Source ( pointer ) # keep a secret reference to the input data to make sure it's not GCed source . _references = [ data ] return source