How to use the pyvips._to_string 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 / pyvips / pyvips / vimage.py View on Github external
Raises:
            :class:`.Error`

        """
        vips_filename = _to_bytes(vips_filename)
        pointer = vips_lib.vips_filename_get_filename(vips_filename)
        filename = _to_string_copy(pointer)

        pointer = vips_lib.vips_filename_get_options(vips_filename)
        options = _to_string_copy(pointer)

        pointer = vips_lib.vips_foreign_find_save(vips_filename)
        if pointer == ffi.NULL:
            raise Error('unable to write to file {0}'.format(vips_filename))
        name = _to_string(pointer)

        return pyvips.Operation.call(name, self, filename,
                                     string_options=options, **kwargs)
github libvips / pyvips / pyvips / base.py View on Github external
def values_for_enum(gtype):
    """Get all values for a enum (gtype)."""

    g_type_class = gobject_lib.g_type_class_ref(gtype)
    g_enum_class = ffi.cast('GEnumClass *', g_type_class)

    values = []

    # -1 since we always have a "last" member.
    for i in range(0, g_enum_class.n_values - 1):
        value = _to_string(g_enum_class.values[i].value_nick)
        values.append(value)

    return values
github libvips / pyvips / pyvips / base.py View on Github external
def path_filename7(filename):
    return _to_string(vips_lib.vips_path_filename7(_to_bytes(filename)))
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 / vimage.py View on Github external
Returns:
            A new :class:`.Image`.

        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_load(filename)
        if name == ffi.NULL:
            raise Error('unable to load from file {0}'.format(vips_filename))

        return pyvips.Operation.call(_to_string(ffi.string(name)),
                                     _to_string(ffi.string(filename)),
                                     string_options=_to_string(
                                         ffi.string(options)
                                     ), **kwargs)
github libvips / pyvips / pyvips / base.py View on Github external
def path_mode7(filename):
    return _to_string(vips_lib.vips_path_mode7(_to_bytes(filename)))
github libvips / pyvips / pyvips / vimage.py View on Github external
access (Access): Hint the expected access pattern for the image.
            fail (bool): If set True, the loader will fail with an error on the
                first serious error in the image. By default, libvips will
                attempt to read everything it can from a damaged image.

        Returns:
            A new :class:`Image`.

        Raises:
            :class:`.Error`

        """
        pointer = vips_lib.vips_foreign_find_load_stream(streami.pointer)
        if pointer == ffi.NULL:
            raise Error('unable to load from stream')
        name = _to_string(pointer)

        return pyvips.Operation.call(name, streami,
                                     string_options=options, **kwargs)
github libvips / pyvips / pyvips / vimage.py View on Github external
access (Access): Hint the expected access pattern for the image.
            fail (bool): If set True, the loader will fail with an error on the
                first serious error in the image. By default, libvips will
                attempt to read everything it can from a damaged image.

        Returns:
            A new :class:`Image`.

        Raises:
            :class:`.Error`

        """
        pointer = vips_lib.vips_foreign_find_load_buffer(data, len(data))
        if pointer == ffi.NULL:
            raise Error('unable to load from buffer')
        name = _to_string(pointer)

        return pyvips.Operation.call(name, data,
                                     string_options=options, **kwargs)
github libvips / pyvips / pyvips / base.py View on Github external
def nickname_find(gtype):
    """Return the nickname for a GType."""

    return _to_string(vips_lib.vips_nickname_find(gtype))
github libvips / pyvips / pyvips / vimage.py View on Github external
Returns:
            A new :class:`.Image`.

        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_load(filename)
        if name == ffi.NULL:
            raise Error('unable to load from file {0}'.format(vips_filename))

        return pyvips.Operation.call(_to_string(ffi.string(name)),
                                     _to_string(ffi.string(filename)),
                                     string_options=_to_string(
                                         ffi.string(options)
                                     ), **kwargs)