### Class

# Vips ForeignSave

#### Description [src]

    abstract class Vips.ForeignSave : Vips.Foreign
    {
      gboolean strip,
      VipsForeignKeep keep,
      char* profile,
      VipsArrayDouble* background,
      int page_height,
      VipsImage* in,
      VipsImage* ready
    }

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

## Writing a new saver

Call your saver in the class’ `Vips.ObjectClass.build` method after chaining up. The prepared image should be ready for you to save in `ready`.

As a complete example, here’s the code for the CSV saver, minus the calls to the actual save routines.

    typedef struct _VipsForeignSaveCsv {
        VipsForeignSave parent_object;

        char *filename;
        const char *separator;
    } VipsForeignSaveCsv;

    typedef VipsForeignSaveClass VipsForeignSaveCsvClass;

    G_DEFINE_TYPE(VipsForeignSaveCsv, vips_foreign_save_csv,
      VIPS_TYPE_FOREIGN_SAVE);

    static int
    vips_foreign_save_csv_build(VipsObject *object)
    {
        VipsForeignSave *save = (VipsForeignSave *) object;
        VipsForeignSaveCsv *csv = (VipsForeignSaveCsv *) object;

        if (VIPS_OBJECT_CLASS(vips_foreign_save_csv_parent_class)
                ->build(object))
            return -1;

        if (vips__csv_write(save->ready, csv->filename, csv->separator))
          return -1;

        return 0;
    }

    static void
    vips_foreign_save_csv_class_init(VipsForeignSaveCsvClass *class)
    {
        GObjectClass *gobject_class = G_OBJECT_CLASS(class);
        VipsObjectClass *object_class = (VipsObjectClass *) class;
        VipsForeignClass *foreign_class = (VipsForeignClass *) class;
        VipsForeignSaveClass *save_class = (VipsForeignSaveClass *) class;

        gobject_class->set_property = vips_object_set_property;
        gobject_class->get_property = vips_object_get_property;

        object_class->nickname = "csvsave";
        object_class->description = _("save image to csv file");
        object_class->build = vips_foreign_save_csv_build;

        foreign_class->suffs = vips__foreign_csv_suffs;

        save_class->saveable = VIPS_FOREIGN_SAVEABLE_MONO;
        // no need to define ->format_table, we don't want the input
        // cast for us

        VIPS_ARG_STRING(class, "filename", 1,
            _("Filename"),
            _("Filename to save to"),
            VIPS_ARGUMENT_REQUIRED_INPUT,
            G_STRUCT_OFFSET(VipsForeignSaveCsv, filename),
            NULL);

        VIPS_ARG_STRING(class, "separator", 13,
            _("Separator"),
            _("Separator characters"),
            VIPS_ARGUMENT_OPTIONAL_INPUT,
            G_STRUCT_OFFSET(VipsForeignSaveCsv, separator),
            "\t");
    }

    static void
    vips_foreign_save_csv_init(VipsForeignSaveCsv *csv)
    {
        csv->separator = g_strdup("\t");
    }

#### Hierarchy

#### Ancestors

- VipsForeign
- VipsOperation
- VipsObject
- GObject

#### 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

###### Vips.ForeignSave:background

No description available.

###### Vips.ForeignSave:in

No description available.

###### Vips.ForeignSave:keep

No description available.

###### Vips.ForeignSave:page-height

No description available.

###### Vips.ForeignSave:profile

No description available.

###### Vips.ForeignSave:strip

No description available.

##### 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 VipsForeignSaveClass {
      VipsForeignClass parent_class;
      VipsForeignSaveable saveable;
      VipsBandFormat* format_table;
      VipsForeignCoding coding;

    }

No description available.

###### Class members

`parent_class: VipsForeignClass`

  No description available.

`saveable: VipsForeignSaveable`

  No description available.

`format_table: VipsBandFormat*`

  No description available.

`coding: VipsForeignCoding`

  No description available.