How to use the pyvips.ffi.NULL function in pyvips

To help you get started, we’ve selected a few pyvips 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 libvips / libvips / doc / gen-function-list.py View on Github external
def add_nickname(gtype, a, b):
        nickname = nickname_find(gtype)
        try:
            # can fail for abstract types
            intro = Introspect.get(nickname)

            # we are only interested in non-deprecated operations
            if (intro.flags & _OPERATION_DEPRECATED) == 0:
                all_nicknames.append(nickname)
        except Error:
            pass

        type_map(gtype, add_nickname)

        return ffi.NULL
github libvips / pyvips / pyvips / gobject.py View on Github external
process.

        You can pass the result pointer to the Python constructor for the
        object you are building. You will need to call VipsObject.build() to
        finish construction.

        Returns:
            A pointer to a new GObject.

        Raises:
            :class:`.Error`

        """

        pointer = gobject_lib.g_object_new(gtype, ffi.NULL)
        if pointer == ffi.NULL:
            raise Error("can't create {0}".format(type_name(gtype)))

        return pointer
github libvips / pyvips / pyvips / vstreamo.py View on Github external
def new_to_file(filename):
        """Make a new stream to write to a file.

        Make a new stream that will write to the named file. For example::

            streamo = pyvips.Streamo.new_to_file("myfile.jpg")

        You can pass this stream to (for example) :meth:`write_to_stream`.

        """

        # logger.debug('VipsStreamo.new_to_file: filename = %s', filename)

        pointer = vips_lib.vips_streamo_new_to_file(_to_bytes(filename))
        if pointer == ffi.NULL:
            raise Error("can't create output stream from filename {0}"
                        .format(filename))

        return Streamo(pointer)
github libvips / pyvips / pyvips / voperation.py View on Github external
def add_nickname(gtype, a, b):
            nickname = nickname_find(gtype)
            try:
                Operation.generate_sphinx(nickname)
                all_nicknames.append(nickname)
            except Error:
                pass

            type_map(gtype, add_nickname)

            return ffi.NULL
github libvips / pyvips / pyvips / gobject.py View on Github external
if name not in _marshalers:
            raise Error('unsupported signal "{0}"'.format(name))

        go = ffi.cast('GObject *', self.pointer)
        handle = ffi.new_handle(callback)
        # we need to keep refs to the ffi handle and the callback to prevent
        # them being GCed
        # the callback might be a bound method (a closure) rather than a simple
        # function, so it can vanish
        self._handles.append(handle)
        self._handles.append(callback)

        gobject_lib.g_signal_connect_data(go, _to_bytes(name),
                                          _marshalers[name],
                                          handle, ffi.NULL, 0)
github libvips / pyvips / pyvips / base.py View on Github external
def get_suffixes():
    """Get a list of all the filename suffixes supported by libvips.

    Returns:
        [string]

    """

    names = []

    if at_least_libvips(8, 8):
        array = vips_lib.vips_foreign_get_suffixes()
        i = 0
        while array[i] != ffi.NULL:
            name = _to_string(array[i])
            if name not in names:
                names.append(name)
            glib_lib.g_free(array[i])
            i += 1
        glib_lib.g_free(array)

    return names
github libvips / pyvips / pyvips / voperation.py View on Github external
if result != 0:
                raise Error('unable to get arguments from operation')
            p_names = p_names[0]
            p_flags = p_flags[0]
            n_args = p_n_args[0]

            for i in range(0, n_args):
                add_args(_to_string(p_names[i]), p_flags[i])
        else:
            def add_construct(self, pspec, argument_class,
                              argument_instance, a, b):
                add_args(_to_string(pspec.name), argument_class.flags)
                return ffi.NULL

            cb = ffi.callback('VipsArgumentMapFn', add_construct)
            vips_lib.vips_argument_map(op.vobject, cb, ffi.NULL, ffi.NULL)

        # logger.debug('arguments = %s', self.arguments)

        # build a hash from arg name to detailed arg information
        self.details = {}
        for name, flags in arguments:
            self.details[name] = {
                "name": name,
                "flags": flags,
                "blurb": op.get_blurb(name),
                "type": op.get_typeof(name)
            }

        # lists of arg names by category
        self.required_input = []
        self.optional_input = []
github libvips / pyvips / pyvips / vimage.py View on Github external
optional appended arguments.

        Other arguments depend upon the save operation.

        Returns:
            None

        Raises:
            :class:`.Error`

        """
        vips_filename = _to_bytes(vips_filename)
        filename = vips_lib.vips_filename_get_filename(vips_filename)
        options = vips_lib.vips_filename_get_options(vips_filename)
        name = vips_lib.vips_foreign_find_save(filename)
        if name == ffi.NULL:
            raise Error('unable to write to file {0}'.format(vips_filename))

        return pyvips.Operation.call(_to_string(ffi.string(name)), self,
                                     filename, string_options=_to_string(
                                         ffi.string(options)
                                     ), **kwargs)
github libvips / pyvips / pyvips / vregion.py View on Github external
def new(image):
        """Make a region on an image.

        Returns:
            A new :class:`.Region`.

        Raises:
            :class:`.Error`

        """

        pointer = vips_lib.vips_region_new(image.pointer)
        if pointer == ffi.NULL:
            raise Error('unable to make region')

        return pyvips.Region(pointer)