Vips.ForeignLoad¶
- Subclasses:
None
Methods¶
- Inherited:
Vips.Foreign (11), Vips.Operation (4), Vips.Object (27), GObject.Object (37)
- Structs:
Virtual Methods¶
- Inherited:
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w |
Required access pattern for this file |
||
r/w |
Open to disc |
||
r/w |
Fail on first warning |
||
r/w |
Error level to fail on |
||
r/w |
Flags for this file |
||
r/w |
Force open via memory |
||
r/w |
Output image |
||
r/w |
Don’t use a cached result for this operation |
||
r/w |
Sequential read only |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
access |
r |
||
disc |
r |
||
error |
r |
||
fail |
r |
||
fail_on |
r |
||
flags |
r |
||
memory |
r |
||
nocache |
r |
||
out |
r |
||
parent_object |
r |
||
real |
r |
||
revalidate |
r |
||
sequential |
r |
Class Details¶
- class Vips.ForeignLoad(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
An abstract base class to load images in a variety of formats.
- Writing a new loader
Add a new loader to libvips by subclassing [class`ForeignLoad`]. Subclasses need to implement at least [vfunc`ForeignLoad`.header].
[vfunc`ForeignLoad`.header] must set at least the header fields of
out. [vfunc`ForeignLoad`.load], if defined, must load the pixels toreal.The suffix list is used to select a format to save a file in, and to pick a loader if you don’t define [func`Foreign`.is_a].
You should also define [property`Object`:py:data::nickname<Vips.ForeignLoad.props.nickname>] and [property`Object`:py:data::description<Vips.ForeignLoad.props.description>] in [class`Object`].
As a complete example, here’s code for a PNG loader, minus the actual calls to libpng.
```c typedef struct _VipsForeignLoadPng {
Vips.ForeignLoadparent_object;str*filename; } VipsForeignLoadPng;typedef
Vips.ForeignLoadClassVipsForeignLoadPngClass;G_DEFINE_TYPE(VipsForeignLoadPng, vips_foreign_load_png, VIPS_TYPE_FOREIGN_LOAD);
static
Vips.ForeignFlagsvips_foreign_load_png_get_flags_filename(conststr*filename) {Vips.ForeignFlagsflags;flags = 0; if (vips__png_isinterlaced(filename)) flags =
Vips.ForeignFlags.PARTIAL; else flags =Vips.ForeignFlags.SEQUENTIAL;return flags; }
static
Vips.ForeignFlagsvips_foreign_load_png_get_flags(Vips.ForeignLoad*load) { VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;return vips_foreign_load_png_get_flags_filename(png->filename); }
static int vips_foreign_load_png_header(
Vips.ForeignLoad*load) { VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;if (vips__png_header(png->filename, load->out)) return -1;
return 0; }
static int vips_foreign_load_png_load(
Vips.ForeignLoad*load) { VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;if (vips__png_read(png->filename, load->real)) return -1;
return 0; }
static void vips_foreign_load_png_class_init(VipsForeignLoadPngClass *class) {
GObject.ObjectClass*gobject_class = G_OBJECT_CLASS(class);Vips.ObjectClass*object_class = (Vips.ObjectClass*) class;Vips.ForeignClass*foreign_class = (Vips.ForeignClass*) class;Vips.ForeignLoadClass*load_class = (Vips.ForeignLoadClass*) class;gobject_class->set_property =
Vips.Object.set_property; gobject_class->get_property =Vips.Object.get_property;object_class->nickname = “pngload”; object_class->description = _(“load png from file”);
foreign_class->suffs = vips__png_suffs;
load_class->is_a = vips__png_ispng; load_class->get_flags_filename = vips_foreign_load_png_get_flags_filename; load_class->get_flags = vips_foreign_load_png_get_flags; load_class->header = vips_foreign_load_png_header; load_class->load = vips_foreign_load_png_load;
VIPS_ARG_STRING(class, “filename”, 1, _(“Filename”), _(“Filename to load from”),
Vips.ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET(VipsForeignLoadPng, filename),None); }static void vips_foreign_load_png_init(VipsForeignLoadPng *png) { } ```
- do_get_flags() virtual¶
- Return type:
Property Details¶
- Vips.ForeignLoad.props.access¶
- Name:
access- Type:
- Default Value:
- Flags:
Required access pattern for this file
- Vips.ForeignLoad.props.disc¶
-
Open to disc
- Vips.ForeignLoad.props.fail¶
-
Fail on first warning
- Vips.ForeignLoad.props.fail_on¶
- Name:
fail-on- Type:
- Default Value:
- Flags:
Error level to fail on
- Vips.ForeignLoad.props.flags¶
- Name:
flags- Type:
- Default Value:
- Flags:
Flags for this file
- Vips.ForeignLoad.props.memory¶
-
Force open via memory
- Vips.ForeignLoad.props.out¶
- Name:
out- Type:
- Default Value:
- Flags:
Output image
- Vips.ForeignLoad.props.revalidate¶
-
Don’t use a cached result for this operation