Top | Description | Object Hierarchy | Properties | ![]() | ![]() | ![]() | ![]() |
VipsAccess | access | Read / Write |
gboolean | disc | Read / Write |
gboolean | fail | Read / Write |
VipsFailOn | fail-on | Read / Write |
VipsForeignFlags | flags | Read / Write |
gboolean | memory | Read / Write |
VipsImage * | out | Read / Write |
gboolean | revalidate | Read / Write |
gboolean | sequential | Read / Write |
VipsArrayDouble * | background | Read / Write |
VipsImage * | in | Read / Write |
VipsForeignKeep | keep | Read / Write |
int | page-height | Read / Write |
char * | profile | Read / Write |
gboolean | strip | Read / Write |
GEnum├── VipsFailOn├── VipsForeignDzContainer├── VipsForeignDzDepth├── VipsForeignDzLayout├── VipsForeignHeifCompression├── VipsForeignHeifEncoder├── VipsForeignPpmFormat├── VipsForeignSubsample├── VipsForeignTiffCompression├── VipsForeignTiffPredictor├── VipsForeignTiffResunit├── VipsForeignWebpPreset╰── VipsSaveableGFlags├── VipsForeignFlags├── VipsForeignKeep╰── VipsForeignPngFilter GObject╰──VipsObject╰──VipsOperation╰── VipsForeign├── VipsForeignLoad╰── VipsForeignSave
This set of operations load and save images in a variety of formats.
You can load and save from and to files, memory areas, and the libvips IOabstractions,VipsSource andVipsTarget.
Usevips_foreign_find_load()
,vips_foreign_find_load_buffer()
andvips_foreign_find_load_source()
to find a loader for an object. Usevips_foreign_find_save()
,vips_foreign_find_save_buffer()
andvips_foreign_find_save_target()
to find a saver for a format. You can thenrun these operations usingvips_call()
and friends to perform the load orsave.
vips_image_write_to_file() andvips_image_new_from_file()
and friends usethese functions to automate file load and save.
You can also invoke the operations directly, for example:
123 | vips_tiffsave(my_image,"frank.anything","compression",VIPS_FOREIGN_TIFF_COMPRESSION_JPEG,NULL); |
All loaders attach all image metadata as libvips properties on load.
You can change metadata withvips_image_set_int()
and friends.
During save, you can usekeep
to specify which metadata to retain,defaults to all, seeVipsForeignKeep. Settingprofile
willautomatically keep the ICC profile.
By default, libvips will only load the first page of many page or animatedimages. Usepage
andn
to set the start page and the number of pages toload. Setn
to -1 to load all pages.
Many page images are loaded as a tall, thin strip of pages.
Usevips_image_get_page_height()
andvips_image_get_n_pages()
to find thepage height and number of pages of a loaded image.
Usepage_height
to set the page height for image save.
Not all image formats support alpha. If you try to save an image with analpha channel to a format that does not support it, the alpha will beautomatically flattened out. Usebackground
(default 0) to set the colourthat alpha should be flattened against.
To add support for a new file format to vips, simply define a new subclassofVipsForeignLoad orVipsForeignSave.
If you define a new operation which is a subclass ofVipsForeign, supportfor it automatically appears in all VIPS user-interfaces. It will also betransparently supported byvips_image_new_from_file()
and friends.
Add a new loader to VIPS by subclassingVipsForeignLoad. Subclasses need toimplement at least
.header()
must set at least the header fields ofheader()
out
.
, if defined,must load the pixels toload()
real
.
The suffix list is used to select a format to save a file in, and to pick aloader if you don't defineis_a()
.
You should also definenickname
anddescription
inVipsObject.
As a complete example, here's code for a PNG loader, minus the actualcalls to libpng.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 | typedefstruct_VipsForeignLoadPng{VipsForeignLoadparent_object;char*filename;}VipsForeignLoadPng;typedefVipsForeignLoadClassVipsForeignLoadPngClass;G_DEFINE_TYPE(VipsForeignLoadPng,vips_foreign_load_png,VIPS_TYPE_FOREIGN_LOAD);staticVipsForeignFlagsvips_foreign_load_png_get_flags_filename(constchar*filename){VipsForeignFlagsflags;flags=0;if(vips__png_isinterlaced(filename))flags=VIPS_FOREIGN_PARTIAL;elseflags=VIPS_FOREIGN_SEQUENTIAL;returnflags;}staticVipsForeignFlagsvips_foreign_load_png_get_flags(VipsForeignLoad*load){VipsForeignLoadPng*png=(VipsForeignLoadPng*)load;returnvips_foreign_load_png_get_flags_filename(png->filename);}staticintvips_foreign_load_png_header(VipsForeignLoad*load){VipsForeignLoadPng*png=(VipsForeignLoadPng*)load;if(vips__png_header(png->filename,load->out))return-1;return0;}staticintvips_foreign_load_png_load(VipsForeignLoad*load){VipsForeignLoadPng*png=(VipsForeignLoadPng*)load;if(vips__png_read(png->filename,load->real))return-1;return0;}staticvoidvips_foreign_load_png_class_init(VipsForeignLoadPngClass*class){GObjectClass*gobject_class=G_OBJECT_CLASS(class);VipsObjectClass*object_class=(VipsObjectClass*)class;VipsForeignClass*foreign_class=(VipsForeignClass*)class;VipsForeignLoadClass*load_class=(VipsForeignLoadClass*)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),NULL);}staticvoidvips_foreign_load_png_init(VipsForeignLoadPng*png){} |
Call your saver in the class'
method after chaining up. Theprepared image should be ready for you to save inbuild()
ready
.
As a complete example, here's the code for the CSV saver, minus the callsto the actual save routines.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | typedefstruct_VipsForeignSaveCsv{VipsForeignSaveparent_object;char*filename;constchar*separator;}VipsForeignSaveCsv;typedefVipsForeignSaveClassVipsForeignSaveCsvClass;G_DEFINE_TYPE(VipsForeignSaveCsv,vips_foreign_save_csv,VIPS_TYPE_FOREIGN_SAVE);staticintvips_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;return0;}staticvoidvips_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_SAVEABLE_MONO;// no need to define ->format_table, we don't want the input// cast for usVIPS_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");}staticvoidvips_foreign_save_csv_init(VipsForeignSaveCsv*csv){csv->separator=g_strdup("\t");} |
void *vips_foreign_map (constchar *base
,VipsSListMap2Fn fn
,void *a
,void *b
);
Apply a function to everyVipsForeignClass that VIPS knows about. Foreignsare presented to the function in priority order.
Like all VIPS map functions, iffn
returnsNULL
, iteration continues. Ifit returns non-NULL
, iteration terminates and that value is returned. Themap function returnsNULL
if all calls returnNULL
.
See also:vips_slist_map()
.
base | base class to search below (eg. "VipsForeignLoad") | |
fn | function to apply to eachVipsForeignClass. | [scope call] |
a | user data | |
b | user data |
constchar *vips_foreign_find_load (constchar *filename
);
Searches for an operation you could use to loadfilename
. Any trailingoptions onfilename
are stripped and ignored.
See also:vips_foreign_find_load_buffer()
,vips_image_new_from_file()
.
constchar *vips_foreign_find_load_buffer (constvoid *data
,size_t size
);
Searches for an operation you could use to load a memory buffer. To see therange of buffer loaders supported by your vips, try something like:
vips -l | grep load_buffer
See also:vips_image_new_from_buffer()
.
data | start ofmemory buffer. | [array length=size][element-type guint8][transfer none] |
size | number of bytes in | [type gsize] |
constchar *vips_foreign_find_load_source (VipsSource *source
);
Searches for an operation you could use to load a source. To see therange of source loaders supported by your vips, try something like:
vips -l | grep load_source
See also:vips_image_new_from_source()
.
VipsForeignFlagsvips_foreign_flags (constchar *loader
,constchar *filename
);
Return the flags forfilename
usingloader
.loader
is something like "tiffload" or "VipsForeignLoadTiff".
gbooleanvips_foreign_is_a (constchar *loader
,constchar *filename
);
ReturnTRUE
iffilename
can be loaded byloader
.loader
is somethinglike "tiffload" or "VipsForeignLoadTiff".
gbooleanvips_foreign_is_a_buffer (constchar *loader
,constvoid *data
,size_t size
);
ReturnTRUE
ifdata
can be loaded byloader
.loader
is somethinglike "tiffload_buffer" or "VipsForeignLoadTiffBuffer".
loader | name of loader to use for test | |
data | pointer to the buffer to test. | [array length=size][element-type guint8] |
size | size of the buffer to test. | [type gsize] |
gbooleanvips_foreign_is_a_source (constchar *loader
,VipsSource *source
);
ReturnTRUE
ifsource
can be loaded byloader
.loader
is somethinglike "tiffload_source" or "VipsForeignLoadTiffSource".
voidvips_foreign_load_invalidate (VipsImage *image
);
Loaders can call this on the image they are making if they see a read errorfrom the load library. It signals "invalidate" on the load operation andwill cause it to be dropped from cache.
If we know a file will cause a read error, we don't want to cache thefailing operation, we want to make sure the image will really be openedagain if our caller tries again. For example, a broken file might bereplaced by a working one.
constchar *vips_foreign_find_save (constchar *filename
);
Searches for an operation you could use to write tofilename
.Any trailing options onfilename
are stripped and ignored.
See also:vips_foreign_find_save_buffer()
,vips_image_write_to_file()
.
gchar **vips_foreign_get_suffixes (void
);
Get aNULL
-terminated array listing all the supported suffixes.
This is not the same as all the supported file types, since libvipsdetects image format for load by testing the first few bytes.
Usevips_foreign_find_load()
to detect type for a specific file.
Free the return result withg_strfreev()
.
constchar *vips_foreign_find_save_buffer (constchar *suffix
);
Searches for an operation you could use to write to a buffer insuffix
format.
See also:vips_image_write_to_buffer()
.
constchar *vips_foreign_find_save_target (constchar *suffix
);
Searches for an operation you could use to write to a target insuffix
format.
See also:vips_image_write_to_buffer()
.
intvips_vipsload (constchar *filename
,VipsImage **out
,...
);
Read in a vips image.
See also:vips_vipssave()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_vipsload_source (VipsSource *source
,VipsImage **out
,...
);
Exactly asvips_vipsload()
, but read from a source.
source | source to load from | |
out | decompressed image. | [out] |
... |
|
intvips_vipssave (VipsImage *in
,constchar *filename
,...
);
Writein
tofilename
in VIPS format.
See also:vips_vipsload()
.
intvips_vipssave_target (VipsImage *in
,VipsTarget *target
,...
);
Asvips_vipssave()
, but save to a target.
intvips_openslideload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
level
:gint
, load this level
associated
:gchararray
, load this associated image
attach_associated
:gboolean
, attach all associated images as metadata
autocrop
:gboolean
, crop to image bounds
rgb
:gboolean
, output RGB (not RGBA) pixels
Read a virtual slide supported by the OpenSlide library into a VIPS image.OpenSlide supports images in Aperio, Hamamatsu, MIRAX, Sakura, Trestle,and Ventana formats.
To facilitate zooming, virtual slide formats include multiple scaled-downversions of the high-resolution image. These are typically called"levels". By default,vips_openslideload()
reads the highest-resolutionlevel (level 0). Setlevel
to the level number you want.
In addition to the slide image itself, virtual slide formats sometimesinclude additional images, such as a scan of the slide's barcode.OpenSlide calls these "associated images". To read an associated image,setassociated
to the image's name.A slide's associated images are listed in the"slide-associated-images" metadata item.
If you setattach_associated
, then all associated images are attached asmetadata items. Usevips_image_get_image()
onout
to retrieve them. Imagesare attached as "openslide-associated-XXXXX", where XXXXX is the name of theassociated image.
By default, the output of this operator is RGBA. Setrgb
to enable RGBoutput.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_openslideload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
level
:gint
, load this level
associated
:gchararray
, load this associated image
attach_associated
:gboolean
, attach all associated images as metadata
autocrop
:gboolean
, crop to image bounds
rgb
:gboolean
, output RGB (not RGBA) pixels
Exactly asvips_openslideload()
, but read from a source.
source | source to load from | |
out | decompressed image. | [out] |
... |
|
intvips_jpegload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
shrink
:gint
, shrink by this much on load
fail_on
:VipsFailOn, types of read error to fail on
autorotate
:gboolean
, rotate image upright during load
Read a JPEG file into a VIPS image. It can read most 8-bit JPEG images,including CMYK and YCbCr.
shrink
means shrink by this integer factor during load. Possible valuesare 1, 2, 4 and 8. Shrinking during read is very much faster thandecompressing the whole image and then shrinking later.
Usefail_on
to set the type of error that will cause load to fail. Bydefault, loaders are permissive, that is,VIPS_FAIL_ON_NONE.
Settingautorotate
toTRUE
will make the loader interpret theorientation tag and automatically rotate the image appropriately duringload.
Ifautorotate
isFALSE
, the metadata fieldVIPS_META_ORIENTATION is setto the value of the orientation tag. Applications may read and interpretthis fieldas they wish later in processing. Seevips_autorot()
. Saveoperations will useVIPS_META_ORIENTATION, if present, to set theorientation of output images.
Example:
1234 | vips_jpegload("fred.jpg",&out,"shrink",8,"fail_on",VIPS_FAIL_ON_TRUNCATED,NULL); |
Any embedded ICC profiles are ignored: you always just get the RGB fromthe file. Instead, the embedded profile will be attached to the image asVIPS_META_ICC_NAME. You need to use something likevips_icc_import()
to get CIE values from the file.
EXIF metadata is attached asVIPS_META_EXIF_NAME, IPTC asVIPS_META_IPTC_NAME, and XMP asVIPS_META_XMP_NAME.
The int metadata item "jpeg-multiscan" is set to the result ofjpeg_has_multiple_scans()
. Interlaced jpeg images need a large amount ofmemory to load, so this field gives callers a chance to handle theseimages differently.
The string-valued field "jpeg-chroma-subsample" gives the chroma subsamplein standard notation. 4:4:4 means no subsample, 4:2:0 means YCbCr withCb and Cr subsampled horizontally and vertically, 4:4:4:4 means a CMYKimage with no subsampling.
The EXIF thumbnail, if present, is attached to the image as"jpeg-thumbnail-data". Seevips_image_get_blob()
.
See also:vips_jpegload_buffer()
,vips_image_new_from_file()
,vips_autorot()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_jpegload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
shrink
:gint
, shrink by this much on load
fail_on
:VipsFailOn, types of read error to fail on
autorotate
:gboolean
, use exif Orientation tag to rotate the imageduring load
Read a JPEG-formatted memory block into a VIPS image. Exactly asvips_jpegload()
, but read from a memory buffer.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_jpegload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_jpegload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
shrink
:gint
, shrink by this much on load
fail_on
:VipsFailOn, types of read error to fail on
autorotate
:gboolean
, use exif Orientation tag to rotate the imageduring load
Read a JPEG-formatted memory block into a VIPS image. Exactly asvips_jpegload()
, but read from a source.
See also:vips_jpegload()
.
source | source to load | |
out | image to write. | [out] |
... |
|
intvips_jpegsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
Q
:gint
, quality factor
optimize_coding
:gboolean
, compute optimal Huffman coding tables
interlace
:gboolean
, write an interlaced (progressive) jpeg
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
trellis_quant
:gboolean
, apply trellis quantisation to each 8x8 block
overshoot_deringing
:gboolean
, overshoot samples with extreme values
optimize_scans
:gboolean
, split DCT coefficients into separate scans
quant_table
:gint
, quantization table index
restart_interval
:gint
, restart interval in mcu
Asvips_jpegsave()
, but save to a target.
See also:vips_jpegsave()
,vips_image_write_to_target()
.
intvips_jpegsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
Q
:gint
, quality factor
optimize_coding
:gboolean
, compute optimal Huffman coding tables
interlace
:gboolean
, write an interlaced (progressive) jpeg
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
trellis_quant
:gboolean
, apply trellis quantisation to each 8x8 block
overshoot_deringing
:gboolean
, overshoot samples with extreme values
optimize_scans
:gboolean
, split DCT coefficients into separate scans
quant_table
:gint
, quantization table index
restart_interval
:gint
, restart interval in mcu
Write a VIPS image to a file as JPEG.
UseQ
to set the JPEG compression factor. Default 75.
Ifoptimize_coding
is set, the Huffman tables are optimized. This isslightly slower and produces slightly smaller files.
Ifinterlace
is set, the jpeg files will be interlaced (progressive jpeg,in jpg parlance). These files may be better for display over a slow networkconnection, but need much more memory to encode and decode.
Chroma subsampling is normally automatically disabled for Q >= 90. You canforce the subsampling mode withsubsample_mode
.
Iftrellis_quant
is set and the version of libjpeg supports it(e.g. mozjpeg >= 3.0), apply trellis quantisation to each 8x8 block.Reduces file size but increases compression time.
Ifovershoot_deringing
is set and the version of libjpeg supports it(e.g. mozjpeg >= 3.0), apply overshooting to samples with extreme valuesfor example 0 and 255 for 8-bit. Overshooting may reduce ringing artifactsfrom compression, in particular in areas where black text appears on awhite background.
Ifoptimize_scans
is set and the version of libjpeg supports it(e.g. mozjpeg >= 3.0), split the spectrum of DCT coefficients intoseparate scans. Reduces file size but increases compression time.
Ifquant_table
is set and the version of libjpeg supports it(e.g. mozjpeg >= 3.0) it selects the quantization table to use:
0 — Tables from JPEG Annex K (vips and libjpeg default)
1 — Flat table
2 — Table tuned for MSSIM on Kodak image set
3 — Table from ImageMagick by N. Robidoux (current mozjpeg default)
4 — Table tuned for PSNR-HVS-M on Kodak image set
5 — Table from Relevance of Human Vision to JPEG-DCT Compression (1992)
6 — Table from DCTune Perceptual Optimization of Compressed DentalX-Rays (1997)
7 — Table from A Visual Detection Model for DCT CoefficientQuantization (1993)
8 — Table from An Improved Detection Model for DCT CoefficientQuantization (1993)
Quantization table 0 is the default in vips and libjpeg(-turbo), but ittends to favor detail over color accuracy, producing colored patches andstripes as well as heavy banding in flat areas at high compression ratios.Quantization table 2 is a good candidate to try if the default quantizationtable produces banding or color shifts and is well suited for hires images.Quantization table 3 is the default in mozjpeg and has been tuned to producegood results at the default quality setting; banding at high compression.Quantization table 4 is the most accurate at the cost of compression ratio.Tables 5-7 are based on older research papers, but generally achieve worsecompression ratios and/or quality than 2 or 4.
For maximum compression with mozjpeg, a useful set of options isstrip,optimize-coding, interlace, optimize-scans, trellis-quant, quant_table=3
.
By default, the output stream won't have restart markers. If a non-zerorestart_interval is specified, a restart marker will be added after eachspecified number of MCU blocks. This makes the stream more recoverableif there are transmission errors, but also allows for some decoders to readpart of the JPEG without decoding the whole stream.
The image is automatically converted to RGB, Monochrome or CMYK beforesaving.
EXIF data is constructed fromVIPS_META_EXIF_NAME, thenmodified with any other related tags on the image before being written tothe file.VIPS_META_RESOLUTION_UNIT is used to set the EXIF resolutionunit.VIPS_META_ORIENTATION is used to set the EXIF orientation tag.
IPTC asVIPS_META_IPTC_NAME and XMP asVIPS_META_XMP_NAMEare coded and attached.
intvips_jpegsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
Q
:gint
, quality factor
optimize_coding
:gboolean
, compute optimal Huffman coding tables
interlace
:gboolean
, write an interlaced (progressive) jpeg
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
trellis_quant
:gboolean
, apply trellis quantisation to each 8x8 block
overshoot_deringing
:gboolean
, overshoot samples with extreme values
optimize_scans
:gboolean
, split DCT coefficients into separate scans
quant_table
:gint
, quantization table index
restart_interval
:gint
, restart interval in mcu
Asvips_jpegsave()
, but save to a memory buffer.
The address of the buffer is returned inobuf
, the length of the buffer inolen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_jpegsave()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_jpegsave_mime (VipsImage *in
,...
);
Optional arguments:
Q
:gint
, quality factor
optimize_coding
:gboolean
, compute optimal Huffman coding tables
interlace
:gboolean
, write an interlaced (progressive) jpeg
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
trellis_quant
:gboolean
, apply trellis quantisation to each 8x8 block
overshoot_deringing
:gboolean
, overshoot samples with extreme values
optimize_scans
:gboolean
, split DCT coefficients into separate scans
quant_table
:gint
, quantization table index
restart_interval
:gint
, restart interval in mcu
Asvips_jpegsave()
, but save as a mime jpeg on stdout.
See also:vips_jpegsave()
,vips_image_write_to_file()
.
intvips_webpload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (frame) to read
n
:gint
, load this many pages
scale
:gdouble
, scale by this much on load
Exactly asvips_webpload()
, but read from a source.
See also:vips_webpload()
source | source to load from | |
out | image to write. | [out] |
... |
|
intvips_webpload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (frame) to read
n
:gint
, load this many pages
scale
:gdouble
, scale by this much on load
Read a WebP file into a VIPS image.
Usepage
to select a page to render, numbering from zero.
Usen
to select the number of pages to render. The default is 1. Pages arerendered in a vertical column, with each individual page aligned to theleft. Set to -1 to mean "until the end of the document". Usevips_grid()
to change page layout.
Usescale
to specify a scale-on-load factor. For example, 2.0 to doublethe size on load. Animated webp images don't support shrink-on-load, so afurther resize may be necessary.
The loader supports ICC, EXIF and XMP metadata.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_webpload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (frame) to read
n
:gint
, load this many pages
scale
:gdouble
, scale by this much on load
Read a WebP-formatted memory block into a VIPS image. Exactly asvips_webpload()
, but read from a memory buffer.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_webpload()
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_webpsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
Q
:gint
, quality factor
lossless
:gboolean
, enables lossless compression
preset
:VipsForeignWebpPreset, choose lossy compression preset
smart_subsample
:gboolean
, enables high quality chroma subsampling
smart_deblock
:gboolean
, enables auto-adjusting of the deblocking filter
near_lossless
:gboolean
, preprocess in lossless mode (controlled by Q)
alpha_q
:gint
, set alpha quality in lossless mode
effort
:gint
, level of CPU effort to reduce file size
target_size
:gint
, desired target size in bytes
passes
:gint
, number of entropy-analysis passes
min_size
:gboolean
, minimise size
mixed
:gboolean
, allow both lossy and lossless encoding
kmin
:gint
, minimum number of frames between keyframes
kmax
:gint
, maximum number of frames between keyframes
Asvips_webpsave()
, but save to a target.
See also:vips_webpsave()
.
intvips_webpsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
Q
:gint
, quality factor
lossless
:gboolean
, enables lossless compression
preset
:VipsForeignWebpPreset, choose lossy compression preset
smart_subsample
:gboolean
, enables high quality chroma subsampling
smart_deblock
:gboolean
, enables auto-adjusting of the deblocking filter
near_lossless
:gboolean
, preprocess in lossless mode (controlled by Q)
alpha_q
:gint
, set alpha quality in lossless mode
effort
:gint
, level of CPU effort to reduce file size
target_size
:gint
, desired target size in bytes
passes
:gint
, number of entropy-analysis passes
min_size
:gboolean
, minimise size
mixed
:gboolean
, allow both lossy and lossless encoding
kmin
:gint
, minimum number of frames between keyframes
kmax
:gint
, maximum number of frames between keyframes
Write an image to a file in WebP format.
By default, images are saved in lossy format, withQ
giving the WebP quality factor. It has the range 0 - 100, with thedefault 75.
Usepreset
to hint the image type to the lossy compressor. The default isVIPS_FOREIGN_WEBP_PRESET_DEFAULT.
Setsmart_subsample
to enable high quality chroma subsampling.
Setsmart_deblock
to enable auto-adjusting of the deblocking filter. Thiscan improve image quality, especially on low-contrast edges, but encodingcan take significantly longer.
Usealpha_q
to set the quality for the alpha channel in lossy mode. It hasthe range 1 - 100, with the default 100.
Useeffort
to control how much CPU time to spend attempting toreduce file size. A higher value means more effort and therefore CPU timeshould be spent. It has the range 0-6 and a default value of 4.
Usetarget_size
to set the desired target size in bytes.
Usepasses
to set the number of entropy-analysis passes, by default 1,unlesstarget_size
is set, in which case the default is 3. It is notrecommended to setpasses
unless you settarget_size
. Doing so willresult in longer encoding times for no benefit.
Setlossless
to use lossless compression, or combinenear_lossless
withQ
80, 60, 40 or 20 to apply increasing amounts of preprocessingwhich improves the near-lossless compression ratio by up to 50%.
For animated webp output,min_size
will try to optimize for minimum size.
For animated webp output,kmax
sets the maximum number of frames betweenkeyframes. Setting 0 means only keyframes.kmin
sets the minimum number offrames between frames. Setting 0 means no keyframes. By default, keyframesare disabled.
For animated webp output,mixed
tries to improve the file size by mixingboth lossy and lossless encoding.
Use the metadata itemsloop
anddelay
to set the number ofloops for the animation and the frame delays.
See also:vips_webpload()
,vips_image_write_to_file()
.
intvips_webpsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
Q
:gint
, quality factor
lossless
:gboolean
, enables lossless compression
preset
:VipsForeignWebpPreset, choose lossy compression preset
smart_subsample
:gboolean
, enables high quality chroma subsampling
smart_deblock
:gboolean
, enables auto-adjusting of the deblocking filter
near_lossless
:gboolean
, preprocess in lossless mode (controlled by Q)
alpha_q
:gint
, set alpha quality in lossless mode
effort
:gint
, level of CPU effort to reduce file size
target_size
:gint
, desired target size in bytes
passes
:gint
, number of entropy-analysis passes
min_size
:gboolean
, minimise size
mixed
:gboolean
, allow both lossy and lossless encoding
kmin
:gint
, minimum number of frames between keyframes
kmax
:gint
, maximum number of frames between keyframes
Asvips_webpsave()
, but save to a memory buffer.
The address of the buffer is returned inbuf
, the length of the buffer inlen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_webpsave()
.
in | image to save | |
buf | return output buffer here. | [out][array length=len][element-type guint8] |
len | return output length here | |
... |
|
intvips_webpsave_mime (VipsImage *in
,...
);
Optional arguments:
Q
:gint
, quality factor
lossless
:gboolean
, enables lossless compression
preset
:VipsForeignWebpPreset, choose lossy compression preset
smart_subsample
:gboolean
, enables high quality chroma subsampling
smart_deblock
:gboolean
, enables auto-adjusting of the deblocking filter
near_lossless
:gboolean
, preprocess in lossless mode (controlled by Q)
alpha_q
:gint
, set alpha quality in lossless mode
effort
:gint
, level of CPU effort to reduce file size
target_size
:gint
, desired target size in bytes
passes
:gint
, number of entropy-analysis passes
min_size
:gboolean
, minimise size
mixed
:gboolean
, allow both lossy and lossless encoding
kmin
:gint
, minimum number of frames between keyframes
kmax
:gint
, maximum number of frames between keyframes
Asvips_webpsave()
, but save as a mime webp on stdout.
See also:vips_webpsave()
,vips_image_write_to_file()
.
intvips_tiffload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page
n
:gint
, load this many pages
autorotate
:gboolean
, use orientation tag to rotate the imageduring load
subifd
:gint
, select this subifd index
Read a TIFF file into a VIPS image. It is a full baseline TIFF 6 reader,with extensions for tiled images, multipage images, XYZ and LAB colourspace, pyramidal images and JPEG compression, including CMYK and YCbCr.
page
means load this page from the file. By default the first page (page0) is read.
n
means load this many pages. By default a single page is read. All thepages must have the same dimensions, and they are loaded as a tall, thin"toilet roll" image. TheVIPS_META_PAGE_HEIGHT metadatatag gives the height in pixels of each page. Use -1 to load all pages.
Settingautorotate
toTRUE
will make the loader interpret theorientation tag and automatically rotate the image appropriately duringload.
Ifautorotate
isFALSE
, the metadata fieldVIPS_META_ORIENTATION is setto the value of the orientation tag. Applications may read and interpretthis fieldas they wish later in processing. Seevips_autorot()
. Saveoperations will useVIPS_META_ORIENTATION, if present, to set theorientation of output images.
Ifautorotate
is TRUE, the image will be rotated upright during load andno metadata attached. This can be very slow.
Ifsubifd
is -1 (the default), the main image is selected for each page.If it is 0 or greater and there is a SUBIFD tag, the indexed SUBIFD isselected. This can be used to read lower resolution layers frombioformats-style image pyramids.
Any ICC profile is read and attached to the VIPS image asVIPS_META_ICC_NAME. Any XMP metadata is read and attached to the imageasVIPS_META_XMP_NAME. Any IPTC is attached asVIPS_META_IPTC_NAME. Theimage description isattached asVIPS_META_IMAGEDESCRIPTION. Data in the photoshop tag isattached asVIPS_META_PHOTOSHOP_NAME.
See also:vips_image_new_from_file()
,vips_autorot()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_tiffload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page
n
:gint
, load this many pages
autorotate
:gboolean
, use orientation tag to rotate the imageduring load
subifd
:gint
, select this subifd index
Read a TIFF-formatted memory block into a VIPS image. Exactly asvips_tiffload()
, but read from a memory source.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_tiffload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_tiffload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page
n
:gint
, load this many pages
autorotate
:gboolean
, use orientation tag to rotate the imageduring load
subifd
:gint
, select this subifd index
Exactly asvips_tiffload()
, but read from a source.
See also:vips_tiffload()
.
source | source to load | |
out | image to write. | [out] |
... |
|
intvips_tiffsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
compression
: use thisVipsForeignTiffCompression
Q
:gint
quality factor
predictor
: use thisVipsForeignTiffPredictor
tile
:gboolean
, setTRUE
to write a tiled tiff
tile_width
:gint
for tile size
tile_height
:gint
for tile size
pyramid
:gboolean
, write an image pyramid
bitdepth
:int
, change bit depth to 1,2, or 4 bit
miniswhite
:gboolean
, write 1-bit images as MINISWHITE
resunit
:VipsForeignTiffResunit for resolution unit
xres
:gdouble
horizontal resolution in pixels/mm
yres
:gdouble
vertical resolution in pixels/mm
bigtiff
:gboolean
, write a BigTiff file
properties
:gboolean
, setTRUE
to write an IMAGEDESCRIPTION tag
region_shrink
:VipsRegionShrink How to shrink each 2x2 region.
level
:gint
, Zstd or Deflate (zlib) compression level
lossless
:gboolean
, WebP lossless mode
depth
:VipsForeignDzDepth how deep to make the pyramid
subifd
:gboolean
write pyr layers as sub-ifds
premultiply
:gboolean
write premultiplied alpha
Write a VIPS image to a file as TIFF.
Ifin
has theVIPS_META_PAGE_HEIGHT metadata item, this is assumed to be a"toilet roll" image. It will bewritten as series of pages, eachVIPS_META_PAGE_HEIGHT pixels high.
Usecompression
to set the tiff compression. Currently jpeg, packbits,fax4, lzw, none, deflate, webp and zstd are supported. The default is nocompression.JPEG compression is a good lossy compressor for photographs, packbits isgood for 1-bit images, and deflate is the best lossless compression TIFFcan do.
XYZ images are automatically saved as libtiff LOGLUV with SGILOG compression.Float LAB images are saved as float CIELAB. Setbitdepth
to save as 8-bitCIELAB.
UseQ
to set the JPEG compression factor. Default 75.
Userlevel
to set the ZSTD (1-22) or Deflate (1-9) compression level. Uselossless
toset WEBP lossless mode on. UseQ
to set the WEBP compression level.
Usepredictor
to set the predictor for lzw, deflate and zstd compression.It defaults toVIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL, meaning horizontaldifferencing. Please refer to the libtiffspecifications for further discussion of various predictors.
Settile
to TRUE to write a tiled tiff. By default tiff are written instrips. Usetile_width
andtile_height
to set the tile size. The defaiultis 128 by 128.
Setpyramid
to write the image as a set of images, one per page, ofdecreasing size. Useregion_shrink
to set how images will be shrunk: bydefault each 2x2 block is just averaged, but you can set MODE or MEDIAN aswell.
By default, the pyramid stops when the image is small enough to fit in onetile. Usedepth
to stop when the image fits in one pixel, or to only writea single layer.
Setbitdepth
to save 8-bit uchar images as 1, 2 or 4-bit TIFFs.In case of depth 1: Values >128 are written as white, values <=128 as black.Normally vips will write MINISBLACK TIFFs where black is a 0 bit, but if yousetminiswhite
, it will use 0 for a white bit. Many pre-press applicationsonly work with images which use this sense.miniswhite
only affects one-bitimages, it does nothing for greyscale images.In case of depth 2: The same holds but values < 64 are written as black.For 64 <= values < 128 they are written as dark grey, for 128 <= values < 192they are written as light gray and values above are written as white.In caseminiswhite
is set to true this behavior is inverted.In case of depth 4: values < 16 are written as black, and so on for thelighter shades. In caseminiswhite
is set to true this behavior is inverted.
Useresunit
to override the default resolution unit.The defaultresolution unit is taken from the header fieldVIPS_META_RESOLUTION_UNIT. If this field is not set, thenVIPS defaults to cm.
Usexres
andyres
to override the default horizontal and verticalresolutions. By default these values are taken from the VIPS image header.libvips resolution is always in pixels per millimetre.
Setbigtiff
to attempt to write a bigtiff. Bigtiff is a variant of the TIFFformat that allows more than 4GB in a file.
Setproperties
to write all vips metadata to the IMAGEDESCRIPTION tag asxml. Ifproperties
is not set, the value ofVIPS_META_IMAGEDESCRIPTION isused instead.
The value ofVIPS_META_XMP_NAME is written tothe XMP tag.VIPS_META_ORIENTATION (if set) is used to set the value ofthe orientationtag.VIPS_META_IPTC (if set) is used to set the value of the IPTC tag.VIPS_META_PHOTOSHOP_NAME (if set) is used to set the value of the PHOTOSHOPtag.
By default, pyramid layers are saved as consecutive pages.Setsubifd
to save pyramid layers as sub-directories of the main image.Setting this option can improve compatibility with formats like OME.
Setpremultiply
to save with premultiplied alpha. Some programs, such asInDesign, will only work with premultiplied alpha.
See also:vips_tiffload()
,vips_image_write_to_file()
.
intvips_tiffsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
compression
: use thisVipsForeignTiffCompression
Q
:gint
quality factor
predictor
: use thisVipsForeignTiffPredictor
tile
:gboolean
, setTRUE
to write a tiled tiff
tile_width
:gint
for tile size
tile_height
:gint
for tile size
pyramid
:gboolean
, write an image pyramid
bitdepth
:int
, set write bit depth to 1, 2, 4 or 8
miniswhite
:gboolean
, write 1-bit images as MINISWHITE
resunit
:VipsForeignTiffResunit for resolution unit
xres
:gdouble
horizontal resolution in pixels/mm
yres
:gdouble
vertical resolution in pixels/mm
bigtiff
:gboolean
, write a BigTiff file
properties
:gboolean
, setTRUE
to write an IMAGEDESCRIPTION tag
region_shrink
:VipsRegionShrink How to shrink each 2x2 region.
level
:gint
, Zstd or Deflate (zlib) compression level
lossless
:gboolean
, WebP lossless mode
depth
:VipsForeignDzDepth how deep to make the pyramid
subifd
:gboolean
write pyr layers as sub-ifds
premultiply
:gboolean
write premultiplied alpha
Asvips_tiffsave()
, but save to a memory buffer.
The address of the buffer is returned inbuf
, the length of the buffer inlen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_tiffsave()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_tiffsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
compression
: use thisVipsForeignTiffCompression
Q
:gint
quality factor
predictor
: use thisVipsForeignTiffPredictor
tile
:gboolean
, setTRUE
to write a tiled tiff
tile_width
:gint
for tile size
tile_height
:gint
for tile size
pyramid
:gboolean
, write an image pyramid
bitdepth
:int
, set write bit depth to 1, 2, 4 or 8
miniswhite
:gboolean
, write 1-bit images as MINISWHITE
resunit
:VipsForeignTiffResunit for resolution unit
xres
:gdouble
horizontal resolution in pixels/mm
yres
:gdouble
vertical resolution in pixels/mm
bigtiff
:gboolean
, write a BigTiff file
properties
:gboolean
, setTRUE
to write an IMAGEDESCRIPTION tag
region_shrink
:VipsRegionShrink How to shrink each 2x2 region.
level
:gint
, Zstd or Deflate (zlib) compression level
lossless
:gboolean
, WebP lossless mode
depth
:VipsForeignDzDepth how deep to make the pyramid
subifd
:gboolean
write pyr layers as sub-ifds
premultiply
:gboolean
write premultiplied alpha
Asvips_tiffsave()
, but save to a target.
See also:vips_tiffsave()
,vips_image_write_to_target()
.
intvips_openexrload (constchar *filename
,VipsImage **out
,...
);
Read a OpenEXR file into a VIPS image.
The reader can handle scanline and tiled OpenEXR images. It can't handleOpenEXR colour management, image attributes, many pixel formats, anythingother than RGBA.
This reader uses the rather limited OpenEXR C API. It should really beredone in C++.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_fitsload (constchar *filename
,VipsImage **out
,...
);
Read a FITS image file into a VIPS image.
This operation can read images with up to three dimensions. Any higherdimensions must be empty.
It can read 8, 16 and 32-bit integer images, signed and unsigned, float anddouble.
FITS metadata is attached with the "fits-" prefix.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_fitssave (VipsImage *in
,constchar *filename
,...
);
Write a VIPS image to a file in FITS format.
See also:vips_image_write_to_file()
.
intvips_analyzeload (constchar *filename
,VipsImage **out
,...
);
Load an Analyze 6.0 file. Iffilename
is "fred.img", this will look foran image header called "fred.hdr" and pixel data in "fred.img". You canalso load "fred" or "fred.hdr".
Images areloaded lazilly and byte-swapped, if necessary. The Analyze metadata is readand attached.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_rawload (constchar *filename
,VipsImage **out
,int width
,int height
,int bands
,...
);
Optional arguments:
offset
:guint64
, offset in bytes from start of file
format
:VipsBandFormat, set image format
interpretation
:VipsInterpretation, set image interpretation
This operation mmaps the file, setting upout
so that access to thatimage will read from the file.
By default, it assumes uchar pixels. Useformat
to select something else.
The image will be tagged asVIPS_INTERPRETATION_MULTIBAND. Useinterpretation
to select something else.
Usevips_byteswap()
to reverse the byte ordering if necessary.
See also:vips_image_new_from_file()
,vips_copy()
,vips_byteswap()
.
filename | file to load | |
out | output image. | [out] |
width | width of image in pixels | |
height | height of image in pixels | |
bands | number of image bands | |
... |
|
intvips_rawsave (VipsImage *in
,constchar *filename
,...
);
Writes the pixels inin
to the filefilename
with no header or othermetadata.
See also:vips_image_write_to_file()
.
intvips_rawsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Asvips_rawsave()
, but save to a memory buffer.
The address of the buffer is returned inbuf
, the length of the buffer inlen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_rawsave()
,vips_image_write_to_memory()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_rawsave_target (VipsImage *in
,VipsTarget *target
,...
);
Asvips_rawsave()
, but save to a target.
See also:vips_rawsave()
.
intvips_csvload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
skip
: skip this many lines at start of file
lines
: read this many lines from file
whitespace
: set of whitespace characters
separator
: set of separator characters
fail_on
:VipsFailOn, types of read error to fail on
Load a CSV (comma-separated values) file. The output image is always 1band (monochrome),VIPS_FORMAT_DOUBLE. Usevips_bandfold()
to turnRGBRGBRGB mono images into colour images.
Items in lines can be either floating point numbers in the C locale, orstrings enclosed in double-quotes ("), or empty.You can use abackslash()
within the quotes to escape special characters,such as quote marks.
skip
sets the number of lines to skip at the start of the file.Default zero.
lines
sets the number of lines to read from the file. Default -1,meaning read all lines to end of file.
whitespace
sets the skippable whitespace characters.Defaultspace.Whitespace characters are always run together.
separator
sets the characters that separate fields.Default ;,tab. Separators are never run together.
Usefail_on
to set the type of error that will cause load to fail. Bydefault, loaders are permissive, that is,VIPS_FAIL_ON_NONE.
See also:vips_image_new_from_file()
,vips_bandfold()
.
filename | file to load | |
out | output image. | [out] |
... |
|
intvips_csvload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
skip
: skip this many lines at start of file
lines
: read this many lines from file
whitespace
: set of whitespace characters
separator
: set of separator characters
fail_on
:VipsFailOn, types of read error to fail on
Exactly asvips_csvload()
, but read from a source.
See also:vips_csvload()
.
source | source to load | |
out | output image. | [out] |
... |
|
intvips_csvsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
separator
: separator string
Writes the pixels inin
to thefilename
as CSV (comma-separated values).The image is writtenone line of text per scanline. Complex numbers are written as"(real,imaginary)" and will need extra parsing I guess. Only the first bandis written.
separator
gives the string to use to separate numbers in the output.The default is "\t" (tab).
See also:vips_image_write_to_file()
.
intvips_csvsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
separator
: separator string
Asvips_csvsave()
, but save to a target.
See also:vips_csvsave()
.
intvips_matrixload (constchar *filename
,VipsImage **out
,...
);
Reads a matrix from a file.
Matrix files have a simple format that's supposed to be easy to create witha text editor or a spreadsheet.
The first line has four numbers for width, height, scale andoffset (scale and offset may be omitted, in which case they default to 1.0and 0.0). Scale must be non-zero. Width and height must be positiveintegers. The numbers are separated by any mixture of spaces, commas,tabs and quotation marks ("). The scale and offset fields may befloating-point, and must use '.'as a decimal separator.
Subsequent lines each hold one row of matrix data, with numbers againseparated by any mixture of spaces, commas,tabs and quotation marks ("). The numbers may be floating-point, and mustuse '.'as a decimal separator.
Extra characters at the ends of lines or at the end of the file areignored.
See also:vips_matrixload()
.
filename | file to load | |
out | output image. | [out] |
... |
|
intvips_matrixload_source (VipsSource *source
,VipsImage **out
,...
);
Exactly asvips_matrixload()
, but read from a source.
See also:vips_matrixload()
.
source | source to load | |
out | output image. | [out] |
... |
|
intvips_matrixsave (VipsImage *in
,constchar *filename
,...
);
Writein
tofilename
in matrix format. Seevips_matrixload()
for adescription of the format.
See also:vips_matrixload()
.
intvips_matrixsave_target (VipsImage *in
,VipsTarget *target
,...
);
Asvips_matrixsave()
, but save to a target.
See also:vips_matrixsave()
.
intvips_matrixprint (VipsImage *in
,...
);
Printin
tostdout
in matrix format. Seevips_matrixload()
for adescription of the format.
See also:vips_matrixload()
.
intvips_magickload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load from this page
n
:gint
, load this many pages
density
: string, canvas resolution for rendering vector formats like SVG
Read in an image using libMagick, the ImageMagick library. This library canread more than 80 file formats, including SVG, BMP, EPS, DICOM and manyothers.The reader can handle any ImageMagick image, including the float and doubleformats. It will work with any quantum size, including HDR. Any metadataattached to the libMagick image is copied on to the VIPS image.
The reader should also work with most versions of GraphicsMagick. See the"--with-magickpackage" configure option.
The file format is usually guessed from the filename suffix, or sniffedfrom the file contents.
Normally it will only load the first image in a many-image sequence (suchas a GIF or a PDF). Usepage
andn
to set the start page and number ofpages to load. Setn
to -1 to load all pages frompage
onwards.
density
is "WxH" in DPI, e.g. "600x300" or "600" (default is "72x72"). Seethedensitydocson the imagemagick website.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_magickload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load from this page
n
:gint
, load this many pages
density
: string, canvas resolution for rendering vector formats like SVG
Read an image memory block using libMagick into a VIPS image. Exactly asvips_magickload()
, but read from a memory source.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_magickload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area | |
out | image to write. | [out] |
... |
|
intvips_magicksave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
quality
:gint
, quality factor
format
:gchararray
, format to save as
optimize_gif_frames
:gboolean
, apply GIF frames optimization
optimize_gif_transparency
:gboolean
, apply GIF transparency optimization
bitdepth
:gint
, number of bits per pixel
Write an image using libMagick.
Usequality
to set the quality factor. Default 0.
Useformat
to explicitly set the save format, for example, "BMP". Otherwisethe format is guessed from the filename suffix.
Ifoptimize_gif_frames
is set, GIF frames are cropped to the smallest sizewhile preserving the results of the GIF animation. This takes some time forcomputation but saves some time on encoding and produces smaller files insome cases.
Ifoptimize_gif_transparency
is set, pixels that don't change the imagethrough animation are made transparent. This takes some time for computationbut saves some time on encoding and produces smaller files in some cases.
bitdepth
specifies the number of bits per pixel. The image will be quantizedand dithered if the value is within the valid range (1 to 8).
See also:vips_magicksave_buffer()
,vips_magickload()
.
intvips_magicksave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
quality
:gint
, quality factor
format
:gchararray
, format to save as
optimize_gif_frames
:gboolean
, apply GIF frames optimization
optimize_gif_transparency
:gboolean
, apply GIF transparency optimization
bitdepth
:gint
, number of bits per pixel
Asvips_magicksave()
, but save to a memory buffer.
The address of the buffer is returned inobuf
, the length of the buffer inolen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_magicksave()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_pngload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
fail_on
:VipsFailOn, types of read error to fail on
unlimited
:gboolean
, Remove all denial of service limits
Exactly asvips_pngload()
, but read from a source.
See also:vips_pngload()
.
source | source to load from | |
out | image to write. | [out] |
... |
|
intvips_pngload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
fail_on
:VipsFailOn, types of read error to fail on
unlimited
:gboolean
, remove all denial of service limits
Read a PNG file into a VIPS image. It can read all png images, including 8-and 16-bit images, 1 and 3 channel, with and without an alpha channel.
Any ICC profile is read and attached to the VIPS image. It also supportsXMP metadata.
Usefail_on
to set the type of error that will cause load to fail. Bydefault, loaders are permissive, that is,VIPS_FAIL_ON_NONE.
By default, the PNG loader limits the number of text and data chunks toblock some denial of service attacks. Setunlimited
to disable theselimits.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_pngload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
fail_on
:VipsFailOn, types of read error to fail on
unlimited
:gboolean
, Remove all denial of service limits
Exactly asvips_pngload()
, but read from a PNG-formatted memory block.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_pngload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_pngsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
compression
: compression level
interlace
: interlace image
filter
: libpng row filter flag(s)
palette
: enable quantisation to 8bpp palette
Q
: quality for 8bpp quantisation
dither
: amount of dithering for 8bpp quantization
bitdepth
:gint
, set write bit depth to 1, 2, 4, 8 or 16
effort
:gint
, quantisation CPU effort
Asvips_pngsave()
, but save to a target.
See also:vips_pngsave()
,vips_image_write_to_target()
.
intvips_pngsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
compression
:gint
, compression level
interlace
:gboolean
, interlace image
filter
:VipsForeignPngFilter row filter flag(s)
palette
:gboolean
, enable quantisation to 8bpp palette
Q
:gint
, quality for 8bpp quantisation
dither
:gdouble
, amount of dithering for 8bpp quantization
bitdepth
:gint
, set write bit depth to 1, 2, 4, 8 or 16
effort
:gint
, quantisation CPU effort
Write a VIPS image to a file as PNG.
compression
means compress with this much effort (0 - 9). Default 6.
Setinterlace
toTRUE
to interlace the image with ADAM7interlacing. Bewarethan an interlaced PNG can be up to 7 times slower to write than anon-interlaced image.
Usefilter
to specify one or more filters, defaults to none,seeVipsForeignPngFilter.
The image is automatically converted to RGB, RGBA, Monochrome or Mono +alpha before saving. Images with more than one byte per band element aresaved as 16-bit PNG, others are saved as 8-bit PNG.
Setpalette
toTRUE
to enable palette mode for RGB or RGBA images. Apalette will be computed with enough space forbitdepth
(1, 2, 4 or 8)bits. UseQ
to set the optimisation effort,dither
to set the degree ofFloyd-Steinberg dithering andeffort
to control the CPU effort(1 is the fastest, 10 is the slowest, 7 is the default).This feature requires libvips to be compiled with libimagequant.
The defaultbitdepth
is either 8 or 16 depending on the interpretation.You can also setbitdepth
for mono and mono + alpha images, and the imagewill be quantized.
XMP metadata is written to the XMP chunk. PNG comments are written toseparate text chunks.
See also:vips_image_new_from_file()
.
intvips_pngsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
compression
:gint
, compression level
interlace
:gboolean
, interlace image
filter
:VipsForeignPngFilter row filter flag(s)
palette
:gboolean
, enable quantisation to 8bpp palette
Q
:gint
, quality for 8bpp quantisation
dither
:gdouble
, amount of dithering for 8bpp quantization
bitdepth
:gint
, set write bit depth to 1, 2, 4, 8 or 16
effort
:gint
, quantisation CPU effort
Asvips_pngsave()
, but save to a memory buffer.
The address of the buffer is returned inbuf
, the length of the buffer inlen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_pngsave()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_ppmload (constchar *filename
,VipsImage **out
,...
);
Read a PPM/PBM/PGM/PFM file into a VIPS image.
It can read 1, 8, 16 and 32 bit images, colour or monochrome,stored in binary or in ASCII. One bit images become 8 bit VIPS images,with 0 and 255 for 0 and 1.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | output image. | [out] |
... |
|
intvips_ppmload_source (VipsSource *source
,VipsImage **out
,...
);
Exactly asvips_ppmload()
, but read from a source.
See also:vips_ppmload()
.
source | source to load | |
out | output image. | [out] |
... |
|
intvips_ppmsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
format
:VipsForeignPpmFormat, format to save in
ascii
:gboolean
, save as ASCII rather than binary
bitdepth
:gint
, bitdepth to save at
Write a VIPS image to a file as PPM. It can write 1, 8, 16 or32 bit unsigned integer images, float images, colour or monochrome,stored as binary or ASCII.Integer images of more than 8 bits can only be stored in ASCII.
When writing float (PFM) images the scale factor is set from the"pfm-scale" metadata.
Setascii
toTRUE
to write as human-readable ASCII. Normally data iswritten in binary.
Setbitdepth
to 1 to write a one-bit image.
format
defaults to the sub-type for this filename suffix.
See also:vips_image_write_to_file()
.
intvips_ppmsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
format
:VipsForeignPpmFormat, format to save in
ascii
:gboolean
, save as ASCII rather than binary
bitdepth
:gint
, bitdepth to save at
Asvips_ppmsave()
, but save to a target.
See also:vips_ppmsave()
.
intvips_matload (constchar *filename
,VipsImage **out
,...
);
Read a Matlab save file into a VIPS image.
This operation searches the savefile for the first array variable with between 1 and 3 dimensions and loadsit as an image. It will not handle complex images. It does not handlesparse matrices.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | output image. | [out] |
... |
|
intvips_radload_source (VipsSource *source
,VipsImage **out
,...
);
Exactly asvips_radload()
, but read from a source.
See also:vips_radload()
.
source | source to load from | |
out | output image. | [out] |
... |
|
intvips_radload (constchar *filename
,VipsImage **out
,...
);
Read a Radiance (HDR) file into a VIPS image.
Radiance files are read asVIPS_CODING_RAD. They have one byte for each ofred, green and blue, and one byte of shared exponent. Some operations (likevips_extract_area()
) can work directly with images in this format, butmmany (all the arithmetic operations, for example) will not. UnpackVIPS_CODING_RAD images to 3 band float withvips_rad2float()
ifyou want to do arithmetic on them.
This operation ignores some header fields, like VIEW and DATE. It will notrotate/flip as the FORMAT string asks.
Sections of this reader from Greg Ward and Radiance with kind permission.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | output image. | [out] |
... |
|
intvips_radload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Exactly asvips_radload()
, but read from a HDR-formatted memory block.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_radload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_radsave (VipsImage *in
,constchar *filename
,...
);
Write a VIPS image in Radiance (HDR) format.
Sections of this reader from Greg Ward and Radiance with kind permission.
See also:vips_image_write_to_file()
.
intvips_radsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Asvips_radsave()
, but save to a memory buffer.
The address of the buffer is returned inbuf
, the length of the buffer inlen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_radsave()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_radsave_target (VipsImage *in
,VipsTarget *target
,...
);
Asvips_radsave()
, but save to a target.
See also:vips_radsave()
.
intvips_pdfload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page, numbered from zero
n
:gint
, load this many pages
dpi
:gdouble
, render at this DPI
scale
:gdouble
, scale render by this factor
background
:VipsArrayDouble background colour
password
:gchararray
PDF password
Render a PDF file into a VIPS image.
The output image is always RGBA --- CMYK PDFs will beconverted. If you need CMYK bitmaps, you should usevips_magickload()
instead.
Usepage
to select a page to render, numbering from zero.
Usen
to select the number of pages to render. The default is 1. Pages arerendered in a vertical column, with each individual page aligned to theleft. Set to -1 to mean "until the end of the document". Usevips_grid()
to change page layout.
Usedpi
to set the rendering resolution. The default is 72. Additionally,you can scale by settingscale
. If you set both, they combine.
Usebackground
to set the background RGBA colour. The default is 255(solid white), use eg. 0 for a transparent background.
Usepassword
to supply a decryption password.
The operation fills a number of header fields with metadata, for example"pdf-author". They may be useful.
This function only reads the image header and does not render any pixeldata. Rendering occurs when pixels are accessed.
See also:vips_image_new_from_file()
,vips_magickload()
.
filename | file to load | |
out | output image. | [out] |
... |
|
intvips_pdfload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page, numbered from zero
n
:gint
, load this many pages
dpi
:gdouble
, render at this DPI
scale
:gdouble
, scale render by this factor
background
:VipsArrayDouble background colour
Read a PDF-formatted memory buffer into a VIPS image. Exactly asvips_pdfload()
, but read from memory.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_pdfload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_pdfload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page, numbered from zero
n
:gint
, load this many pages
dpi
:gdouble
, render at this DPI
scale
:gdouble
, scale render by this factor
background
:VipsArrayDouble background colour
Exactly asvips_pdfload()
, but read from a source.
See also:vips_pdfload()
source | source to load from | |
out | image to write. | [out] |
... |
|
intvips_svgload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
dpi
:gdouble
, render at this DPI
scale
:gdouble
, scale render by this factor
unlimited
:gboolean
, allow SVGs of any size
Render a SVG file into a VIPS image. Rendering uses the librsvg libraryand should be fast.
Usedpi
to set the rendering resolution. The default is 72. You can alsoscale the rendering byscale
.
This function only reads the image header and does not render any pixeldata. Rendering occurs when pixels are accessed.
SVGs larger than 10MB are normally blocked for security. Setunlimited
toallow SVGs of any size.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | output image. | [out] |
... |
|
intvips_svgload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
dpi
:gdouble
, render at this DPI
scale
:gdouble
, scale render by this factor
unlimited
:gboolean
, allow SVGs of any size
Read a SVG-formatted memory block into a VIPS image. Exactly asvips_svgload()
, but read from a memory buffer.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_svgload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_svgload_string (constchar *str
,VipsImage **out
,...
);
Optional arguments:
dpi
:gdouble
, render at this DPI
scale
:gdouble
, scale render by this factor
unlimited
:gboolean
, allow SVGs of any size
Exactly asvips_svgload()
, but read from a string. This function takes acopy of the string.
See also:vips_svgload()
.
str | string to load | |
out | image to write. | [out] |
... |
|
intvips_svgload_source (VipsSource *source
,VipsImage **out
,...
);
Exactly asvips_svgload()
, but read from a source.
See also:vips_svgload()
.
source | source to load from | |
out | image to write. | [out] |
... |
|
intvips_gifload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (frame) to read
n
:gint
, load this many pages
fail_on
:VipsFailOn, types of read error to fail on
Read a GIF file into a libvips image.
Usepage
to select a page to render, numbering from zero.
Usen
to select the number of pages to render. The default is 1. Pages arerendered in a vertical column. Set to -1 to mean "until the end of thedocument". Usevips_grid()
to change page layout.
Usefail_on
to set the type of error that will cause load to fail. Bydefault, loaders are permissive, that is,VIPS_FAIL_ON_NONE.
The output image is RGBA for GIFs containing transparent elements, RGBotherwise.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | output image. | [out] |
... |
|
intvips_gifload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (frame) to read
n
:gint
, load this many pages
fail_on
:VipsFailOn, types of read error to fail on
Exactly asvips_gifload()
, but read from a memory buffer.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_gifload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_gifload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (frame) to read
n
:gint
, load this many pages
fail_on
:VipsFailOn, types of read error to fail on
Exactly asvips_gifload()
, but read from a source.
See also:vips_gifload()
.
source | source to load | |
out | image to write. | [out] |
... |
|
intvips_gifsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
dither
:gdouble
, quantisation dithering level
effort
:gint
, quantisation CPU effort
bitdepth
:gint
, number of bits per pixel
interframe_maxerror
:gdouble
, maximum inter-frame error for transparency
reuse
:gboolean
, reuse palette from input
interlace
:gboolean
, write an interlaced (progressive) GIF
interpalette_maxerror
:gdouble
, maximum inter-palette error for palettereusage
Write to a file in GIF format.
Usedither
to set the degree of Floyd-Steinberg ditheringandeffort
to control the CPU effort (1 is the fastest,10 is the slowest, 7 is the default).
Usebitdepth
(from 1 to 8, default 8) to control the numberof colours in the palette. The first entry in the palette isalways reserved for transparency. For example, a bitdepth of4 will allow the output to contain up to 15 colours.
Useinterframe_maxerror
to set the threshold below which pixels areconsidered equal.Pixels which don't change from frame to frame can be made transparent,improving the compression rate. Default 0.
Useinterpalette_maxerror
to set the threshold below which thepreviously generated palette will be reused.
Ifreuse
is TRUE, the GIF will be saved with a single globalpalette taken from the metadata inin
, and no new palette optimisationwill be done.
Ifinterlace
is TRUE, the GIF file will be interlaced (progressive GIF).These files may be better for display over a slow networkconnection, but need more memory to encode.
See also:vips_image_new_from_file()
.
intvips_gifsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
dither
:gdouble
, quantisation dithering level
effort
:gint
, quantisation CPU effort
bitdepth
:gint
, number of bits per pixel
interframe_maxerror
:gdouble
, maximum inter-frame error for transparency
reuse
:gboolean
, reuse palette from input
interlace
:gboolean
, write an interlaced (progressive) GIF
interpalette_maxerror
:gdouble
, maximum inter-palette error for palettereusage
Asvips_gifsave()
, but save to a memory buffer.
The address of the buffer is returned inbuf
, the length of the buffer inlen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_gifsave()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_gifsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
dither
:gdouble
, quantisation dithering level
effort
:gint
, quantisation CPU effort
bitdepth
:gint
, number of bits per pixel
interframe_maxerror
:gdouble
, maximum inter-frame error for transparency
reuse
:gboolean
, reuse palette from input
interlace
:gboolean
, write an interlaced (progressive) GIF
interpalette_maxerror
:gdouble
, maximum inter-palette error for palettereusage
Asvips_gifsave()
, but save to a target.
See also:vips_gifsave()
,vips_image_write_to_target()
.
intvips_heifload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (top-level image number) to read
n
:gint
, load this many pages
thumbnail
:gboolean
, fetch thumbnail instead of image
unlimited
:gboolean
, remove all denial of service limits
Read a HEIF image file into a VIPS image.
Usepage
to select a page to render, numbering from zero. If neithern
norpage
are set,page
defaults to the primary page, otherwise to 0.
Usen
to select the number of pages to render. The default is 1. Pages arerendered in a vertical column. Set to -1 to mean "until the end of thedocument". Usevips_grid()
to reorganise pages.
HEIF images have a primary image. The metadata itemheif-primary
givesthe page number of the primary.
Ifthumbnail
isTRUE
, then fetch a stored thumbnail rather than theimage.
By default, input image dimensions are limited to 16384x16384.Ifunlimited
isTRUE
, this increases to the maximum of 65535x65535.
The bitdepth of the heic image is recorded in the metadata itemheif-bitdepth
.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_heifload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (top-level image number) to read
n
:gint
, load this many pages
thumbnail
:gboolean
, fetch thumbnail instead of image
unlimited
:gboolean
, remove all denial of service limits
Read a HEIF image file into a VIPS image.Exactly asvips_heifload()
, but read from a memory buffer.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
See also:vips_heifload()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_heifload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, page (top-level image number) to read
n
:gint
, load this many pages
thumbnail
:gboolean
, fetch thumbnail instead of image
unlimited
:gboolean
, remove all denial of service limits
Exactly asvips_heifload()
, but read from a source.
See also:vips_heifload()
.
source | source to load from | |
out | image to write. | [out] |
... |
|
intvips_heifsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
Q
:gint
, quality factor
bitdepth
:gint
, set write bit depth to 8, 10, or 12 bits
lossless
:gboolean
, enable lossless encoding
compression
:VipsForeignHeifCompression, write with this compression
effort
:gint
, encoding effort
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
encoder
:VipsForeignHeifEncoder, select encoder to use
Write a VIPS image to a file in HEIF format.
UseQ
to set the compression factor. Default 50, which seems to be roughlywhat the iphone uses. Q 30 gives about the same quality as JPEG Q 75.
Setlossless
TRUE
to switch to lossless compression.
Usecompression
to set the compression format e.g. HEVC, AVC, AV1 to use. It defaults to AV1if the target filename ends with ".avif", otherwise HEVC.
Useeffort
to control the CPU effort spent improving compression.This is currently only applicable to AV1 encoders. Defaults to 4, 0 isfastest, 9 is slowest.
Chroma subsampling is normally automatically disabled for Q >= 90. You canforce the subsampling mode withsubsample_mode
.
Usebitdepth
to set the bitdepth of the output file. HEIC supports atleast 8, 10 and 12 bits; other codecs may support more or fewer options.
Useencoder
to set the encode library to use, e.g. aom, SVT-AV1, rav1e etc.
See also:vips_image_write_to_file()
,vips_heifload()
.
intvips_heifsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
Q
:gint
, quality factor
bitdepth
:gint
, set write bit depth to 8, 10, or 12 bits
lossless
:gboolean
, enable lossless encoding
compression
:VipsForeignHeifCompression, write with this compression
effort
:gint
, encoding effort
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
encoder
:VipsForeignHeifEncoder, select encoder to use
Asvips_heifsave()
, but save to a memory buffer.
The address of the buffer is returned inobuf
, the length of the buffer inolen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_heifsave()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_heifsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
Q
:gint
, quality factor
bitdepth
:gint
, set write bit depth to 8, 10, or 12 bits
lossless
:gboolean
, enable lossless encoding
compression
:VipsForeignHeifCompression, write with this compression
effort
:gint
, encoding effort
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
encoder
:VipsForeignHeifEncoder, select encoder to use
Asvips_heifsave()
, but save to a target.
See also:vips_heifsave()
,vips_image_write_to_target()
.
intvips_niftiload (constchar *filename
,VipsImage **out
,...
);
Read a NIFTI image file into a VIPS image.
NIFTI metadata is attached with the "nifti-" prefix.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_niftiload_source (VipsSource *source
,VipsImage **out
,...
);
Exactly asvips_niftiload()
, but read from a source.
source | source to load from | |
out | decompressed image. | [out] |
... |
|
intvips_niftisave (VipsImage *in
,constchar *filename
,...
);
Write a VIPS image to a file in NIFTI format.
Use the various NIFTI suffixes to pick the nifti save format.
See also:vips_image_write_to_file()
,vips_niftiload()
.
intvips_jp2kload (constchar *filename
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page
fail_on
:VipsFailOn, types of read error to fail on
Read a JPEG2000 image. The loader supports 8, 16 and 32-bit int pixelvalues, signed and unsigned. It supports greyscale, RGB, YCC, CMYK andmultispectral colour spaces. It will read any ICC profile on the image.
It will only load images where all channels have the same format.
Usepage
to set the page to load, where page 0 is the base resolutionimage and higher-numbered pages are x2 reductions. Use the metadata item"n-pages" to find the number of pyramid layers.
Usefail_on
to set the type of error that will cause load to fail. Bydefault, loaders are permissive, that is,VIPS_FAIL_ON_NONE.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_jp2kload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page
fail_on
:VipsFailOn, types of read error to fail on
Exactly asvips_jp2kload()
, but read from a buffer.
You must not free the buffer whileout
is active. The“postclose” signal onout
is a good place to free.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_jp2kload_source (VipsSource *source
,VipsImage **out
,...
);
Optional arguments:
page
:gint
, load this page
fail_on
:VipsFailOn, types of read error to fail on
Exactly asvips_jp2kload()
, but read from a source.
source | source to load from | |
out | decompressed image. | [out] |
... |
|
intvips_jp2ksave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
Q
:gint
, quality factor
lossless
:gboolean
, enables lossless compression
tile_width
:gint
for tile size
tile_height
:gint
for tile size
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
Write a VIPS image to a file in JPEG2000 format.The saver supports 8, 16 and 32-bit int pixelvalues, signed and unsigned. It supports greyscale, RGB, CMYK andmultispectral images.
UseQ
to set the compression quality factor. The default valueproduces file with approximately the same size as regular JPEG Q 75.
Setlossless
to enable lossless compression.
Usetile_width
andtile_height
to set the tile size. The default is 512.
Chroma subsampling is normally disabled for compatibility. Setsubsample_mode
to auto to enable chroma subsample for Q < 90. Subsamplemode uses YCC rather than RGB colourspace, and many jpeg2000 decoders donot support this.
This operation always writes a pyramid.
See also:vips_image_write_to_file()
,vips_jp2kload()
.
intvips_jp2ksave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
Q
:gint
, quality factor
lossless
:gboolean
, enables lossless compression
tile_width
:gint
for tile size
tile_height
:gint
for tile size
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
Asvips_jp2ksave()
, but save to a target.
See also:vips_jp2ksave()
,vips_image_write_to_target()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_jp2ksave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
Q
:gint
, quality factor
lossless
:gboolean
, enables lossless compression
tile_width
:gint
for tile size
tile_height
:gint
for tile size
subsample_mode
:VipsForeignSubsample, chroma subsampling mode
Asvips_jp2ksave()
, but save to a target.
See also:vips_jp2ksave()
,vips_image_write_to_target()
.
intvips_jxlload_source (VipsSource *source
,VipsImage **out
,...
);
Exactly asvips_jxlload()
, but read from a source.
source | source to load from | |
out | decompressed image. | [out] |
... |
|
intvips_jxlload_buffer (void *buf
,size_t len
,VipsImage **out
,...
);
Exactly asvips_jxlload()
, but read from a buffer.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | image to write. | [out] |
... |
|
intvips_jxlload (constchar *filename
,VipsImage **out
,...
);
Read a JPEG-XL image.
The JPEG-XL loader and saver are experimental features and may changein future libvips versions.
See also:vips_image_new_from_file()
.
filename | file to load | |
out | decompressed image. | [out] |
... |
|
intvips_jxlsave (VipsImage *in
,constchar *filename
,...
);
Optional arguments:
tier
:gint
, decode speed tier
distance
:gdouble
, maximum encoding error
effort
:gint
, encoding effort
lossless
:gboolean
, enables lossless compression
Q
:gint
, quality setting
Write a VIPS image to a file in JPEG-XL format.
The JPEG-XL loader and saver are experimental features and may changein future libvips versions.
tier
sets the overall decode speed the encoder will target. Minimum is 0(highest quality), and maximum is 4 (lowest quality). Default is 0.
distance
sets the target maximum encoding error. Minimum is 0(highest quality), and maximum is 15 (lowest quality). Default is 1.0(visually lossless).
As a convenience, you can also useQ
to setdistance
.Q
usesapproximately the same scale as regular JPEG.
Setlossless
to enable lossless compression.
intvips_jxlsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
tier
:gint
, decode speed tier
distance
:gdouble
, maximum encoding error
effort
:gint
, encoding effort
lossless
:gboolean
, enables lossless compression
Q
:gint
, quality setting
Asvips_jxlsave()
, but save to a memory buffer.
See also:vips_jxlsave()
,vips_image_write_to_target()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_jxlsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
tier
:gint
, decode speed tier
distance
:gdouble
, maximum encoding error
effort
:gint
, encoding effort
lossless
:gboolean
, enables lossless compression
Q
:gint
, quality setting
Asvips_jxlsave()
, but save to a target.
See also:vips_jxlsave()
,vips_image_write_to_target()
.
intvips_dzsave (VipsImage *in
,constchar *name
,...
);
Optional arguments:
basename
:gchar
base part of name
layout
:VipsForeignDzLayout directory layout convention
suffix
:gchar
suffix for tiles
overlap
:gint
set tile overlap
tile_size
:gint
set tile size
background
:VipsArrayDouble background colour
depth
:VipsForeignDzDepth how deep to make the pyramid
centre
:gboolean
centre the tiles
angle
:VipsAngle rotate the image by this much
container
:VipsForeignDzContainer set container type
compression
:gint
zip deflate compression level
region_shrink
:VipsRegionShrink how to shrink each 2x2 region
skip_blanks
:gint
skip tiles which are nearly equal to the background
id
:gchar
id for IIIF properties
Q
:gint
, quality factor
Save an image as a set of tiles at various resolutions. By default dzsaveuses DeepZoom layout -- uselayout
to pick other conventions.
vips_dzsave() creates a directory calledname
to hold the tiles. Ifname
ends.zip
,vips_dzsave()
will create a zip file calledname
to hold thetiles. You can usecontainer
to force zip file output.
Usebasename
to set the name of the image we are creating. Thedefault value is set fromname
.
By default, tiles are written as JPEGs. UseQ
set set the JPEG qualityfactor.
You can setsuffix
to something like".png[bitdepth=4]"
to write tilesin another format.
In Google layout mode, edge tiles are expanded totile_size
bytile_size
pixels. Normally they are filled with white, but you can set another colourwithbackground
. Images are usually placed at the top-left of the tile,but you can have them centred by turning oncentre
.
You can set the size and overlap of tiles withtile_size
andoverlap
.They default to the correct settings for the selectedlayout
. The deepzoomdefaults produce 256x256 jpeg files for centre tiles, the most efficientsize.
Usedepth
to control how low the pyramid goes. This defaults to thecorrect setting for thelayout
you select.
You can rotate the image during write with theangle
argument. However,this will only work for images which support random access, like openslide,and not for things like JPEG. You'll need to rotate those imagesyourself withvips_rot()
. Note that theautorotate
option to the loadermay do what you need.
By default, all tiles are stripped since usually you do not want a copy ofall metadata in every tile. Setkeep
if you want to keep metadata.
Ifcontainer
is set tozip
, you can set a compression level from -1(use zlib default), 0 (store, compression disabled) to 9 (max compression).If no value is given, the default is to store files without compression.
You can useregion_shrink
to control the method for shrinking each 2x2region. This defaults to using the average of the 4 input pixels but you canalso use the median in cases where you want to preserve the range of values.
If you setskip_blanks
to a value greater than or equal to zero, tileswhich are all within that many pixel values to the background are skipped.This can save a lot of space for some image types. This option defaults to5 in Google layout mode, -1 otherwise.
In IIIF layout, you can set the base of theid
property ininfo.json
withid
. The default ishttps://example.com/iiif
.
Uselayout
VIPS_FOREIGN_DZ_LAYOUT_IIIF3 for IIIF v3 layout.
See also:vips_tiffsave()
.
intvips_dzsave_buffer (VipsImage *in
,void **buf
,size_t *len
,...
);
Optional arguments:
basename
:gchar
base part of name
layout
:VipsForeignDzLayout directory layout convention
suffix
:gchar
suffix for tiles
overlap
:gint
set tile overlap
tile_size
:gint
set tile size
background
:VipsArrayDouble background colour
depth
:VipsForeignDzDepth how deep to make the pyramid
centre
:gboolean
centre the tiles
angle
:VipsAngle rotate the image by this much
container
:VipsForeignDzContainer set container type
compression
:gint
zip deflate compression level
region_shrink
:VipsRegionShrink how to shrink each 2x2 region.
skip_blanks
:gint
skip tiles which are nearly equal to the background
id
:gchar
id for IIIF properties
Q
:gint
, quality factor
Asvips_dzsave()
, but save to a memory buffer.
Output is always in a zip container. Usebasename
to set the name of thedirectory that the zip will create when unzipped.
The address of the buffer is returned inbuf
, the length of the buffer inlen
. You are responsible for freeing the buffer withg_free()
when youare done with it.
See also:vips_dzsave()
,vips_image_write_to_file()
.
in | image to save | |
buf | return output buffer here. | [array length=len][element-type guint8] |
len | return output length here. | [type gsize] |
... |
|
intvips_dzsave_target (VipsImage *in
,VipsTarget *target
,...
);
Optional arguments:
basename
:gchar
base part of name
layout
:VipsForeignDzLayout directory layout convention
suffix
:gchar
suffix for tiles
overlap
:gint
set tile overlap
tile_size
:gint
set tile size
background
:VipsArrayDouble background colour
depth
:VipsForeignDzDepth how deep to make the pyramid
centre
:gboolean
centre the tiles
angle
:VipsAngle rotate the image by this much
container
:VipsForeignDzContainer set container type
compression
:gint
zip deflate compression level
region_shrink
:VipsRegionShrink how to shrink each 2x2 region.
skip_blanks
:gint
skip tiles which are nearly equal to the background
id
:gchar
id for IIIF properties
Q
:gint
, quality factor
Asvips_dzsave()
, but save to a target.
See also:vips_dzsave()
,vips_image_write_to_target()
.
Some hints about the image loader.
VIPS_FOREIGN_PARTIAL means that the image can be read directly from thefile without needing to be unpacked to a temporary image first.
VIPS_FOREIGN_SEQUENTIAL means that the loader supports lazy reading, butonly top-to-bottom (sequential) access. Formats like PNG can read sets ofscanlines, for example, but only in order.
If neither PARTIAL or SEQUENTIAL is set, the loader only supports wholeimage read. Setting both PARTIAL and SEQUENTIAL is an error.
VIPS_FOREIGN_BIGENDIAN means that image pixels are most-significant bytefirst. Depending on the native byte order of the host machine, you mayneed to swap bytes. Seevips_copy()
.
How sensitive loaders are to errors, from never stop (very insensitive), tostop on the smallest warning (very sensitive).
Each one implies the ones before it, soVIPS_FAIL_ON_ERROR impliesVIPS_FAIL_ON_TRUNCATED.
Which metadata to retain.
Tune lossy encoder settings for different image types.
The compression types supported by the tiff writer.
UseQ
to set the jpeg compression level, default 75.
Usepredictor
to set the lzw or deflate prediction, default horizontal.
Uselossless
to set WEBP lossless compression.
Uselevel
to set webp and zstd compression level.
The predictor can help deflate and lzw compression. The values are fixed bythe tiff library.
http://www.w3.org/TR/PNG-Filters.htmlThe values mirror those of png.h in libpng.
The netpbm file format to save as.
VIPS_FOREIGN_PPM_FORMAT_PBM images are single bit.
VIPS_FOREIGN_PPM_FORMAT_PGM images are 8, 16, or 32-bits, one band.
VIPS_FOREIGN_PPM_FORMAT_PPM images are 8, 16, or 32-bits, three bands.
VIPS_FOREIGN_PPM_FORMAT_PFM images are 32-bit float pixels.
VIPS_FOREIGN_PPM_FORMAT_PNM images are anymap images -- the image formatis used to pick the saver.
What directory layout and metadata standard to use.
The compression format to use inside a HEIF container.
This is assumed to use the same numbering asheif_compression_format
.
“access”
property“access”VipsAccess
Required access pattern for this file.
Owner: VipsForeignLoad
Flags: Read / Write
Default value: VIPS_ACCESS_RANDOM
“disc”
property “disc”gboolean
Open to disc.
Owner: VipsForeignLoad
Flags: Read / Write
Default value: TRUE
“fail”
property “fail”gboolean
Fail on first warning.
Owner: VipsForeignLoad
Flags: Read / Write
Default value: FALSE
“fail-on”
property“fail-on”VipsFailOn
Error level to fail on.
Owner: VipsForeignLoad
Flags: Read / Write
Default value: VIPS_FAIL_ON_NONE
“flags”
property“flags”VipsForeignFlags
Flags for this file.
Owner: VipsForeignLoad
Flags: Read / Write
“memory”
property “memory”gboolean
Force open via memory.
Owner: VipsForeignLoad
Flags: Read / Write
Default value: FALSE
“revalidate”
property “revalidate”gboolean
Don't use a cached result for this operation.
Owner: VipsForeignLoad
Flags: Read / Write
Default value: FALSE
“sequential”
property “sequential”gboolean
Sequential read only.
Owner: VipsForeignLoad
Flags: Read / Write
Default value: FALSE
“background”
property“background”VipsArrayDouble *
Background value.
Owner: VipsForeignSave
Flags: Read / Write
“keep”
property“keep”VipsForeignKeep
Which metadata to retain.
Owner: VipsForeignSave
Flags: Read / Write
Default value: VIPS_FOREIGN_KEEP_EXIF | VIPS_FOREIGN_KEEP_XMP | VIPS_FOREIGN_KEEP_IPTC | VIPS_FOREIGN_KEEP_ICC | VIPS_FOREIGN_KEEP_OTHER
“page-height”
property “page-height”int
Set page height for multipage save.
Owner: VipsForeignSave
Flags: Read / Write
Allowed values: [0,100000000]
Default value: 0
“profile”
property “profile”char *
Filename of ICC profile to embed.
Owner: VipsForeignSave
Flags: Read / Write
Default value: NULL