### Class

# Vips Foreign

#### Description [src]

    abstract class Vips.Foreign : Vips.Operation
    {
      /* No available fields */
    }

An abstract base class to load and save images in a variety of formats.

## Load and save

You can load and save from and to files, memory areas, and the libvips IO abstractions, `VipsSource` and `VipsTarget`.

Use `vips_foreign_find_load()` `vips_foreign_find_load_buffer()` and `vips_foreign_find_load_source()` to find a loader for an object. Use `vips_foreign_find_save()`, `vips_foreign_find_save_buffer()` and `vips_foreign_find_save_target()` to find a saver for a format. You can then run these operations using `vips_call()` and friends to perform the load or save.

`vips_image_write_to_file()` and `vips_image_new_from_file()` and friends use these functions to automate file load and save.

You can also invoke the operations directly, for example:

    vips_tiffsave(my_image, "frank.anything",
        "compression", VIPS_FOREIGN_TIFF_COMPRESSION_JPEG,
        NULL);

## Image metadata

All loaders attach all image metadata as libvips properties on load.

You can change metadata with `vips_image_set_int()` and friends.

During save, you can use `keep` to specify which metadata to retain, defaults to all, see `VipsForeignKeep`. Setting `profile` will automatically keep the ICC profile.

## Many page images

By default, libvips will only load the first page of many page or animated images. Use `page` and `n` to set the start page and the number of pages to load. Set `n` to -1 to load all pages.

Many page images are loaded as a tall, thin strip of pages.

Use `vips_image_get_page_height()` and `vips_image_get_n_pages()` to find the page height and number of pages of a loaded image.

Use `page_height` to set the page height for image save.

## Alpha save

Not all image formats support alpha. If you try to save an image with an alpha channel to a format that does not support it, the alpha will be automatically flattened out. Use `background` (default 0) to set the colour that alpha should be flattened against.

## Adding new formats

To add support for a new file format to vips, simply define a new subclass of `VipsForeignLoad` or `VipsForeignSave`.

If you define a new operation which is a subclass of `VipsForeign`, support for it automatically appears in all libvips user-interfaces. It will also be transparently supported by `vips_image_new_from_file()` and friends.

#### Hierarchy

#### Ancestors

- VipsOperation
- VipsObject
- GObject

#### Descendants

- VipsForeignLoad
- VipsForeignSave

#### Functions

###### vips_foreign_find_load

Searches for an operation you could use to load `filename`. Any trailing options on `filename` are stripped and ignored.

###### vips_foreign_find_load_buffer

Searches for an operation you could use to load a memory buffer. To see the range of buffer loaders supported by your vips, try something like:.

###### vips_foreign_find_load_source

Searches for an operation you could use to load a source. To see the range of source loaders supported by your vips, try something like:.

###### vips_foreign_find_save

Searches for an operation you could use to write to `filename`. Any trailing options on `filename` are stripped and ignored.

###### vips_foreign_find_save_buffer

Searches for an operation you could use to write to a buffer in `suffix` format.

###### vips_foreign_find_save_target

Searches for an operation you could use to write to a target in `suffix` format.

###### vips_foreign_get_suffixes

Get a `NULL`-terminated array listing all the supported suffixes.

###### vips_foreign_is_a

Return `TRUE` if `filename` can be loaded by `loader`. `loader` is something like “tiffload” or “VipsForeignLoadTiff”.

###### vips_foreign_is_a_buffer

Return `TRUE` if `data` can be loaded by `loader`. `loader` is something like “tiffload_buffer” or “VipsForeignLoadTiffBuffer”.

###### vips_foreign_is_a_source

Return `TRUE` if `source` can be loaded by `loader`. `loader` is something like “tiffload_source” or “VipsForeignLoadTiffSource”.

###### vips_foreign_map

Apply a function to every `VipsForeign` that VIPS knows about. Foreigns are presented to the function in priority order.

#### Instance methods

##### Methods inherited from VipsOperation (3)

###### vips_operation_call_valist

No description available.

###### vips_operation_get_flags

Returns the set of flags for this operation.

###### vips_operation_invalidate

No description available.

##### Methods inherited from VipsObject (27)

Please see VipsObject for a full list of methods.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

##### Properties inherited from VipsObject (2)

###### Vips.Object:description

No description available.

###### Vips.Object:nickname

No description available.

#### Signals

##### Signals inherited from VipsOperation (1)

###### VipsOperation::invalidate

No description available.

##### Signals inherited from VipsObject (4)

###### VipsObject::close

The ::close signal is emitted once during object close. The object is dying and may not work.

###### VipsObject::postbuild

The ::postbuild signal is emitted once just after successful object construction. Return non-zero to cause object construction to fail.

###### VipsObject::postclose

The ::postclose signal is emitted once after object close. The object pointer is still valid, but nothing else.

###### VipsObject::preclose

The ::preclose signal is emitted once just before object close starts. The object is still alive.

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct VipsForeignClass {
      VipsOperationClass parent_class;
      int priority;
      const char** suffs;

    }

No description available.

###### Class members

`parent_class: VipsOperationClass`

  No description available.

`priority: int`

  No description available.

`suffs: const char**`

  No description available.