Vips.Image¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
Number of bands in image |
||
r/w |
Pixel coding |
||
r/w |
Preferred demand style for this image |
||
r/w |
Image filename |
||
r/w |
Pointer to foreign pixels |
||
r/w |
Pixel format in image |
||
r/w |
Image height in pixels |
||
r/w |
Pixel interpretation |
||
r/w |
Block evaluation on this image |
||
r/w |
Open mode |
||
r/w |
Offset in bytes from start of file |
||
r/w |
Image width in pixels |
||
r/w |
Horizontal offset of origin |
||
r/w |
Horizontal resolution in pixels/mm |
||
r/w |
Vertical offset of origin |
||
r/w |
Vertical resolution in pixels/mm |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
BandFmt |
r |
||
Bands |
r |
||
Bbits |
r |
||
Coding |
r |
||
Compression |
r |
||
Hist |
r |
||
Length |
r |
||
Level |
r |
||
Type |
r |
||
Xoffset |
r |
||
Xres |
r |
||
Xres_float |
r |
||
Xsize |
r |
||
Yoffset |
r |
||
Yres |
r |
||
Yres_float |
r |
||
Ysize |
r |
||
baseaddr |
r |
||
client1 |
r |
||
client2 |
r |
||
data |
r |
||
delete_on_close |
r |
||
delete_on_close_filename |
r |
||
dhint |
r |
||
downstream |
[ |
r |
|
dtype |
r |
||
fd |
r |
||
file_length |
r |
||
filename |
r |
||
generate_fn |
r |
||
hint_set |
r |
||
history_list |
[ |
r |
|
kill |
r |
||
length |
r |
||
magic |
r |
||
meta |
r |
||
meta_traverse |
[ |
r |
|
mode |
r |
||
parent_instance |
r |
||
progress_signal |
r |
||
regions |
[ |
r |
|
serial |
r |
||
sizeof_header |
r |
||
sslock |
r |
||
start_fn |
r |
||
stop_fn |
r |
||
time |
r |
||
upstream |
[ |
r |
|
windows |
[ |
r |
Class Details¶
- class Vips.Image(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
An image. These can represent an image on disc, a memory buffer, an image in the process of being written to disc or a partially evaluated image in memory.
- classmethod get_format_max(format)¶
- Parameters:
format (
Vips.BandFormat
) – the format- Returns:
the maximum numeric value possible for this format.
- Return type:
- classmethod memory()¶
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
A renamed vips_image_new_memory() … Some gobject binding systems do not like more than one _new() method.
See also: vips_image_new_memory().
- classmethod new()¶
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
Vips.Image.new
() creates a new, emptyVips.Image
. If you write to one of these images, vips will just attach some callbacks, no pixels will be generated.Write pixels to an image with vips_image_generate() or
Vips.Image.write_line
(). Write a whole image to another image withVips.Image.write
().
- classmethod new_from_file_RW(filename)¶
- Parameters:
filename (
str
) – filename to open- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
Opens the named file for simultaneous reading and writing. This will only work for VIPS files in a format native to your machine. It is only for paintbox-type applications.
See also: vips_draw_circle().
- classmethod new_from_file_raw(filename, xsize, ysize, bands, offset)¶
- Parameters:
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
This function maps the named file and returns a
Vips.Image
you can use to read it.It returns an 8-bit image with bands bands. If the image is not 8-bit, use vips_copy() to transform the descriptor after loading it.
See also: vips_copy(), vips_rawload(), vips_image_new_from_file().
- classmethod new_from_image(image, c)¶
- Parameters:
image (
Vips.Image
) – image to copyc ([
float
]) – array of constants
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
Creates a new image with width, height, format, interpretation, resolution and offset taken from image, but with number of bands taken from n and the value of each band element set from c.
See also:
Vips.Image.new_from_image1
()
- classmethod new_from_image1(image, c)¶
- Parameters:
image (
Vips.Image
) – image to copyc (
float
) – constants
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
Creates a new image with width, height, format, interpretation, resolution and offset taken from image, but with one band and each pixel having the value c.
See also:
Vips.Image.new_from_image
()
- classmethod new_from_memory(data, width, height, bands, format)¶
- Parameters:
data (
bytes
) – start of memory areawidth (
int
) – image widthheight (
int
) – image heightbands (
int
) – image bands (or bytes per pixel)format (
Vips.BandFormat
) – image format
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
This function wraps a
Vips.Image
around a memory area. The memory area must be a simple array, for example RGBRGBRGB, left-to-right, top-to-bottom. Use vips_image_new_from_buffer() to load an area of memory containing an image in a format.VIPS does not take responsibility for the area of memory, it’s up to you to make sure it’s freed when the image is closed. See for example
Vips.Object
::close
.Because VIPS is “borrowing” data from the caller, this function is extremely dangerous. Unless you are very careful, you will get crashes or memory corruption. Use
Vips.Image.new_from_memory_copy
() instead if you are at all unsure.Use vips_copy() to set other image properties.
See also:
Vips.Image.new
(),Vips.Image.write_to_memory
(),Vips.Image.new_from_memory_copy
().
- classmethod new_from_memory_copy(data, width, height, bands, format)¶
- Parameters:
data (
bytes
) – start of memory areawidth (
int
) – image widthheight (
int
) – image heightbands (
int
) – image bands (or bytes per pixel)format (
Vips.BandFormat
) – image format
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
Like
Vips.Image.new_from_memory
(), but VIPS will make a copy of the memory area. This means more memory use and an extra copy operation, but is much simpler and safer.See also:
Vips.Image.new_from_memory
().
- classmethod new_matrix(width, height)¶
- Parameters:
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
This convenience function makes an image which is a matrix: a one-band
Vips.BandFormat.DOUBLE
image held in memory.Use VIPS_IMAGE_ADDR(), or VIPS_MATRIX() to address pixels in the image.
Use
Vips.Image.set_double
() to set “scale” and “offset”, if required.See also: vips_image_new_matrixv()
- classmethod new_matrix_from_array(width, height, array)¶
- Parameters:
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
A binding-friendly version of vips_image_new_matrixv().
- classmethod new_temp_file(format)¶
- Parameters:
format (
str
) – format of file- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
Make a
Vips.Image
which, when written to, will create a temporary file on disc. The file will be automatically deleted when the image is destroyed. format is something like “%s.v” for a vips file.The file is created in the temporary directory. This is set with the environment variable TMPDIR. If this is not set, then on Unix systems, vips will default to /tmp. On Windows, vips uses GetTempPath() to find the temporary directory.
See also:
Vips.Image.new
().
- autorot_remove_angle()¶
Remove the orientation tag on self. Also remove any exif orientation tags. You must vips_copy() the image before calling this function since it modifies metadata.
- colourspace_issupported()¶
-
Test if self is in a colourspace that vips_colourspace() can process.
- copy_memory()¶
- Returns:
the new
Vips.Image
, orNone
on error.- Return type:
This function allocates memory, renders self into it, builds a new image around the memory area, and returns that.
If the image is already a simple area of memory, it just refs self and returns it.
Call this before using the draw operations to make sure you have a memory image that can be modified.
vips_copy() adds a null “copy” node to a pipeline. Use that instead if you want to change metadata and not pixels.
This operation is thread-safe, unlike
Vips.Image.wio_input
().If you are sure that self is not shared with another thread (perhaps you have made it yourself), use
Vips.Image.wio_input
() instead.See also:
Vips.Image.wio_input
().
- decode()¶
- Returns:
0 on success, or -1 on error.
- out:
write to this image
- Return type:
(
int
, out:Vips.Image
)
A convenience function to unpack to a format that we can compute with. out.coding is always
Vips.Coding.NONE
.This unpacks LABQ to plain LAB. Use vips_LabQ2LabS() for a bit more speed if you need it.
See also:
Vips.Image.encode
(), vips_LabQ2Lab(), vips_rad2float().
- decode_predict()¶
- Returns:
- bands:
predict bands here
- format:
predict format here
- Return type:
(
int
, bands:int
, format:Vips.BandFormat
)
We often need to know what an image will decode to without actually decoding it, for example, in arg checking.
See also:
Vips.Image.decode
().
- encode(coding)¶
- Parameters:
coding (
Vips.Coding
) – coding to apply- Returns:
0 on success, or -1 on error.
- out:
write to this image
- Return type:
(
int
, out:Vips.Image
)
A convenience function to pack to a coding. The inverse of
Vips.Image.decode
().See also:
Vips.Image.decode
().
- foreign_load_invalidate()¶
Loaders can call this on the image they are making if they see a read error from the load library. It signals “invalidate” on the load operation and will cause it to be dropped from cache.
If we know a file will cause a read error, we don’t want to cache the failing operation, we want to make sure the image will really be opened again if our caller tries again. For example, a broken file might be replaced by a working one.
- free_buffer(buffer)¶
-
Free the externally allocated buffer found in the input image. This function is intended to be used with g_signal_connect.
- get(name)¶
- Parameters:
name (
str
) – the name to fetch- Returns:
0 on success, -1 otherwise.
- value_copy:
the
GObject.Value
is copied into this
- Return type:
(
int
, value_copy:GObject.Value
)
Fill value_copy with a copy of the header field. value_copy must be zeroed but uninitialised.
This will return -1 and add a message to the error buffer if the field does not exist. Use
Vips.Image.get_typeof
() to test for the existence of a field first if you are not certain it will be there.For example, to read a double from an image (though of course you would use
Vips.Image.get_double
() in practice):GValue value = G_VALUE_INIT; double d; if (vips_image_get(image, name, &value)) return -1; if (G_VALUE_TYPE(&value) != G_TYPE_DOUBLE) { vips_error("mydomain", _("field \"%s\" is of type %s, not double"), name, g_type_name(G_VALUE_TYPE(&value))); g_value_unset(&value); return -1; } d = g_value_get_double(&value); g_value_unset(&value);
See also:
Vips.Image.get_typeof
(),Vips.Image.get_double
().
- get_area(name)¶
- Parameters:
name (
str
) – metadata name- Returns:
0 on success, -1 otherwise.
- data:
return metadata value
- Return type:
Gets data from self under the name name. A convenience function over
Vips.Image.get
(). UseVips.Image.get_typeof
() to test for the existence of a piece of metadata.See also:
Vips.Image.set_area
(),Vips.Image.get
(),Vips.Image.get_typeof
()
- get_array_double(name)¶
- Parameters:
name (
str
) – metadata name- Returns:
0 on success, -1 otherwise.
- out:
return pointer to array
- Return type:
Gets out from im under the name name. The field must be of type #VIPS_TYPE_ARRAY_INT.
Do not free out. out is valid as long as self is valid.
Use
Vips.Image.get_typeof
() to test for the existence of a piece of metadata.See also:
Vips.Image.get
(),Vips.Image.set_image
()
- get_array_int(name)¶
- Parameters:
name (
str
) – metadata name- Returns:
0 on success, -1 otherwise.
- out:
return pointer to array
- Return type:
Gets out from im under the name name. The field must be of type #VIPS_TYPE_ARRAY_INT.
Do not free out. out is valid as long as self is valid.
Use
Vips.Image.get_typeof
() to test for the existence of a piece of metadata.See also:
Vips.Image.get
(),Vips.Image.set_image
()
- get_as_string(name)¶
- Parameters:
name (
str
) – field name- Returns:
0 on success, -1 otherwise.
- out:
return field value as string
- Return type:
Returns name from self in out. This function will read any field, returning it as a printable string. You need to free the string with
GLib.free
() when you are done with it.This will base64-encode BLOBs, for example. Use vips_buf_appendgv() to make a string that’s for humans.
See also:
Vips.Image.get
(),Vips.Image.get_typeof
(), vips_buf_appendgv().
- get_blob(name)¶
- Parameters:
name (
str
) – metadata name- Returns:
0 on success, -1 otherwise.
- data:
pointer to area of memory
- Return type:
Gets data from self under the name name, optionally returns its length in length. Use
Vips.Image.get_typeof
() to test for the existence of a piece of metadata.See also:
Vips.Image.get
(),Vips.Image.get_typeof
(),Vips.Blob.get
(),
- get_coding()¶
- Returns:
the image coding
- Return type:
- get_concurrency(default_concurrency)¶
- Parameters:
default_concurrency (
int
) –- Returns:
the suggested concurrency for this image
- Return type:
Fetch and sanity-check #VIPS_CONCURRENCY. Default to 1 if not present or crazy.
- get_data()¶
-
Return a pointer to the image’s pixel data, if possible. This can involve allocating large amounts of memory and performing a long computation. Image pixels are laid out in band-packed rows.
Since this function modifies self, it is not threadsafe. Only call it on images which you are sure have not been shared with another thread.
See also:
Vips.Image.wio_input
(),Vips.Image.copy_memory
().
- get_double(name)¶
- Parameters:
name (
str
) – field name- Returns:
0 on success, -1 otherwise.
- out:
return field value
- Return type:
Gets out from im under the name name. The value will be transformed into a double, if possible.
See also:
Vips.Image.get
(),Vips.Image.get_typeof
()
- get_fields()¶
-
Get a
None
-terminated array listing all the metadata field names on self. Free the return result withGLib.strfreev
().This is handy for language bindings. From C, it’s usually more convenient to use
Vips.Image.map
().
- get_filename()¶
- get_format()¶
- Returns:
the format of each band element.
- Return type:
- get_history()¶
- Returns:
The history of self as a C string. Do not free!
- Return type:
This function reads the image history as a C string. The string is owned by VIPS and must not be freed.
VIPS tracks the history of each image, that is, the sequence of operations that generated that image. Applications built on VIPS need to call vips_image_history_printf() for each action they perform, setting the command-line equivalent for the action.
See also: vips_image_history_printf().
- get_image(name)¶
- Parameters:
name (
str
) – metadata name- Returns:
0 on success, -1 otherwise.
- out:
return metadata value
- Return type:
(
int
, out:Vips.Image
)
Gets out from im under the name name. The field must be of type #VIPS_TYPE_IMAGE. You must unref out with
GObject.Object.unref
().Use
Vips.Image.get_typeof
() to test for the existence of a piece of metadata.See also:
Vips.Image.get
(),Vips.Image.set_image
()
- get_int(name)¶
- Parameters:
name (
str
) – field name- Returns:
0 on success, -1 otherwise.
- out:
return field value
- Return type:
Gets out from im under the name name. The value will be transformed into an int, if possible.
See also:
Vips.Image.get
(),Vips.Image.get_typeof
()
- get_interpretation()¶
- Returns:
the
Vips.Interpretation
from the image header.- Return type:
Return the
Vips.Interpretation
set in the image header. UseVips.Image.guess_interpretation
() if you want a sanity-checked value.
- get_mode()¶
- Returns:
the image mode.
- Return type:
Image modes are things like
"t"
, meaning a memory buffer, and"p"
meaning a delayed computation.
- get_n_pages()¶
- Returns:
the number of pages in the image file
- Return type:
Fetch and sanity-check
Vips.META_N_PAGES
. Default to 1 if not present or crazy.This is the number of pages in the image file, not the number of pages that have been loaded into self.
- get_n_subifds()¶
- Returns:
the number of subifds in the image file
- Return type:
Fetch and sanity-check
Vips.META_N_SUBIFDS
. Default to 0 if not present or crazy.
- get_offset()¶
- Returns:
the offset.
- Return type:
Matrix images can have an optional
offset
field for use by integer convolution.
- get_orientation()¶
- Returns:
the image orientation.
- Return type:
Fetch and sanity-check
Vips.META_ORIENTATION
. Default to 1 (no rotate, no flip) if not present or crazy.
- get_orientation_swap()¶
- Returns:
if width/height will swap
- Return type:
Return
True
if applying the orientation would swap width and height.
- get_page_height()¶
- Returns:
the page height.
- Return type:
Multi-page images can have a page height. Fetch it, and sanity check it. If page-height is not set, it defaults to the image height.
- get_scale()¶
- Returns:
the scale.
- Return type:
Matrix images can have an optional
scale
field for use by integer convolution.
- get_string(name)¶
- Parameters:
name (
str
) – field name- Returns:
0 on success, -1 otherwise.
- out:
return field value
- Return type:
Gets out from im under the name name. The field must be of type
GObject.TYPE_STRING
, VIPS_TYPE_REF_STRING.Do not free out.
Use
Vips.Image.get_as_string
() to fetch any field as a string.See also:
Vips.Image.get
(),Vips.Image.get_typeof
()
- get_typeof(name)¶
- Parameters:
name (
str
) – the name to search for- Returns:
the
GObject.GType
of the field, or zero if there is no field of that name.- Return type:
Read the
GObject.GType
for a header field. Returns zero if there is no field of that name.See also:
Vips.Image.get
().
- guess_format()¶
- Returns:
a sensible
Vips.BandFormat
for the image.- Return type:
Return the
Vips.BandFormat
for an image, guessing a sane value if the set value looks crazy.For example, for a float image tagged as rgb16, we’d return ushort.
- guess_interpretation()¶
- Returns:
a sensible
Vips.Interpretation
for the image.- Return type:
Return the
Vips.Interpretation
for an image, guessing a sane value if the set value looks crazy.
- hasalpha()¶
- Return type:
Look at an image’s interpretation and see if it has extra alpha bands. For example, a 4-band #VIPS_INTERPRETATION_sRGB would, but a six-band
Vips.Interpretation.MULTIBAND
would not.Return
True
if self has an alpha channel.
- history_args(name, argv)¶
- Parameters:
- Returns:
0 on success, -1 on error.
- Return type:
Formats the name/argv as a single string and calls vips_image_history_printf(). A convenience function for command-line prorams.
See also:
Vips.Image.get_history
().
- icc_ac2rc(profile_filename)¶
- Parameters:
profile_filename (
str
) – use this profile- Returns:
0 on success, -1 on error.
- out:
output image
- Return type:
(
int
, out:Vips.Image
)
Transform an image from absolute to relative colorimetry using the MediaWhitePoint stored in the ICC profile.
See also: vips_icc_transform(), vips_icc_import().
- init_fields(xsize, ysize, bands, format, coding, interpretation, xres, yres)¶
- Parameters:
xsize (
int
) – image widthysize (
int
) – image heightbands (
int
) – image bandsformat (
Vips.BandFormat
) – band formatcoding (
Vips.Coding
) – image codinginterpretation (
Vips.Interpretation
) – image typexres (
float
) – horizontal resolution, pixels per millimetreyres (
float
) – vertical resolution, pixels per millimetre
A convenience function to set the header fields after creating an image. Normally you copy the fields from your input images with vips_image_pipelinev() and then make any adjustments you need, but if you are creating an image from scratch, for example vips_black() or vips_jpegload(), you do need to set all the fields yourself.
See also: vips_image_pipelinev().
- inplace()¶
- Returns:
0 on success, or -1 on error.
- Return type:
Gets self ready for an in-place operation, such as vips_draw_circle(). After calling this function you can both read and write the image with VIPS_IMAGE_ADDR().
This method is called for you by the base class of the draw operations, there’s no need to call it yourself.
Since this function modifies self, it is not thread-safe. Only call it on images which you are sure have not been shared with another thread. All in-place operations are inherently not thread-safe, so you need to take great care in any case.
See also: vips_draw_circle(),
Vips.Image.wio_input
().
- invalidate_all()¶
Invalidate all pixel caches on self and any downstream images, that is, images which depend on this image. Additionally, all operations which depend upon this image are dropped from the VIPS operation cache.
You should call this function after destructively modifying an image with something like vips_draw_circle().
The
Vips.Image
::invalidate
signal is emitted for all invalidated images.See also:
Vips.Region.invalidate
().
- isMSBfirst()¶
- Return type:
Return
True
if self is in most-significant- byte first form. This is the byte order used on the SPARC architecture and others.
- is_sequential()¶
-
True
if any of the images upstream from self were opened in sequential mode. Some operations change behaviour slightly in sequential mode to optimize memory behaviour.
- iskilled()¶
-
If self has been killed (see
Vips.Image.set_kill
()), set an error message, clear the Vips.Image.kill flag and returnTrue
. Otherwise returnFalse
.Handy for loops which need to run sets of threads which can fail.
See also:
Vips.Image.set_kill
().
- map(fn, a)¶
- Parameters:
fn (
Vips.ImageMapFn
orNone
) – function to call for each header field
- Returns:
None
on success, the failing pointer otherwise.- Return type:
This function calls fn for every header field, including every item of metadata.
Like all _map functions, the user function should return
None
to continue iteration, or a non-None
pointer to indicate early termination.See also:
Vips.Image.get_typeof
(),Vips.Image.get
().
- minimise_all()¶
Minimise memory use on this image and any upstream images, that is, images which this image depends upon. This function is called automatically at the end of a computation, but it might be useful to call at other times.
The
Vips.Image
::minimise
signal is emitted for all minimised images.
- pio_input()¶
- Returns:
0 on success, or -1 on error.
- Return type:
Check that an image is readable with
Vips.Region.prepare
() and friends. If it isn’t, try to transform the image so thatVips.Region.prepare
() can work.See also:
Vips.Image.pio_output
(),Vips.Region.prepare
().
- pio_output()¶
- Returns:
0 on success, or -1 on error.
- Return type:
Check that an image is writeable with vips_image_generate(). If it isn’t, try to transform the image so that vips_image_generate() can work.
See also:
Vips.Image.pio_input
().
- print_field(name)¶
- Parameters:
name (
str
) – field name
Prints field name to stdout as ASCII. Handy for debugging.
- remove(name)¶
- Parameters:
name (
str
) – the name to search for- Returns:
True
if an item of metadata of that name was found and removed- Return type:
Find and remove an item of metadata. Return
False
if no metadata of that name was found.See also:
Vips.Image.set
(),Vips.Image.get_typeof
().
- reorder_margin_hint(margin)¶
- Parameters:
margin (
int
) – the size of the margin this operation has added
Vips.Image.reorder_margin_hint
() sets a hint that self contains a margin, that is, that eachVips.Region.prepare
() on self will request a slightly larger region from it’s inputs. A good value for margin is (width * height) for the window the operation uses.This information is used by vips_image_prepare_many() to attempt to reorder computations to minimise recomputation.
See also: vips_image_prepare_many().
- reorder_prepare_many(regions, r)¶
- Parameters:
regions ([
Vips.Region
]) – the set of regions to prepare
- Returns:
0 on success, or -1 on error.
- Return type:
Vips.Image.reorder_prepare_many
() runsVips.Region.prepare
() on each region in regions, requesting the pixels in r.It tries to request the regions in the order which will cause least recomputation. This can give a large speedup, in some cases.
See also:
Vips.Region.prepare
(),Vips.Image.reorder_margin_hint
().
- set(name, value)¶
- Parameters:
name (
str
) – the name to give the metadatavalue (
GObject.Value
) – theGObject.Value
to copy into the image
Set a piece of metadata on self. Any old metadata with that name is destroyed. The
GObject.Value
is copied into the image, so you need to unset the value when you’re done with it.For example, to set an integer on an image (though you would use the convenience function
Vips.Image.set_int
() in practice), you would do:GValue value = G_VALUE_INIT; g_value_init(&value, G_TYPE_INT); g_value_set_int(&value, 42); vips_image_set(image, name, &value); g_value_unset(&value);
See also:
Vips.Image.get
().
- set_area(name, free_fn, *data)¶
- Parameters:
name (
str
) – metadata namefree_fn (
Vips.CallbackFn
orNone
) – free function for data
Attaches data as a metadata item on self under the name name. When VIPS no longer needs the metadata, it will be freed with free_fn.
See also:
Vips.Image.get_double
(),Vips.Image.set
()
- set_array_double(name, array)¶
-
Attaches array as a metadata item on self as name. A convenience function over
Vips.Image.set
().See also:
Vips.Image.get_image
(),Vips.Image.set
().
- set_array_int(name, array)¶
-
Attaches array as a metadata item on self as name. A convenience function over
Vips.Image.set
().See also:
Vips.Image.get_image
(),Vips.Image.set
().
- set_blob(name, free_fn, data)¶
- Parameters:
name (
str
) – metadata namefree_fn (
Vips.CallbackFn
orNone
) – free function for datadata (
bytes
) – pointer to area of memory
Attaches data as a metadata item on self under the name name.
See also:
Vips.Image.get_blob
(),Vips.Image.set
().
- set_blob_copy(name, data)¶
-
Attaches data as a metadata item on self under the name name, taking a copy of the memory area.
See also:
Vips.Image.get_blob
(),Vips.Image.set
().
- set_delete_on_close(delete_on_close)¶
- Parameters:
delete_on_close (
bool
) – format of file
Sets the delete_on_close flag for the image. If this flag is set, when self is finalized, the filename held in self->filename at the time of this call is deleted.
This function is clearly extremely dangerous, use with great caution.
See also:
Vips.Image.new_temp_file
().
- set_double(name, d)¶
-
Attaches d as a metadata item on self as name. A convenience function over
Vips.Image.set
().See also:
Vips.Image.get_double
(),Vips.Image.set
()
- set_image(name, im)¶
- Parameters:
name (
str
) – metadata nameim (
Vips.Image
) – metadata value
Attaches im as a metadata item on self as name. A convenience function over
Vips.Image.set
().See also:
Vips.Image.get_image
(),Vips.Image.set
().
- set_int(name, i)¶
-
Attaches i as a metadata item on self under the name name. A convenience function over
Vips.Image.set
().See also:
Vips.Image.get_int
(),Vips.Image.set
()
- set_kill(kill)¶
- Parameters:
kill (
bool
) – the kill state
Set the Vips.Image.kill flag on an image. Handy for stopping sets of threads.
See also:
Vips.Image.iskilled
().
- set_progress(progress)¶
- Parameters:
progress (
bool
) – turn progress reporting on or off
vips signals evaluation progress via the
Vips.Image
::preeval
,Vips.Image
::eval
andVips.Image
::posteval
signals. Progress is signalled on the most-downstream image for whichVips.Image.set_progress
() was called.
- set_string(name, str)¶
-
Attaches str as a metadata item on self as name. A convenience function over
Vips.Image.set
() using #VIPS_TYPE_REF_STRING.See also:
Vips.Image.get_double
(),Vips.Image.set
().
- wio_input()¶
- Returns:
0 on success, or -1 on error.
- Return type:
Check that an image is readable via the VIPS_IMAGE_ADDR() macro, that is, that the entire image is in memory and all pixels can be read with VIPS_IMAGE_ADDR(). If it isn’t, try to transform it so that VIPS_IMAGE_ADDR() can work.
Since this function modifies self, it is not thread-safe. Only call it on images which you are sure have not been shared with another thread. If the image might have been shared, use the less efficient
Vips.Image.copy_memory
() instead.See also:
Vips.Image.copy_memory
(),Vips.Image.pio_input
(),Vips.Image.inplace
(), VIPS_IMAGE_ADDR().
- write()¶
- Returns:
0 on success, or -1 on error.
- out:
write to this image
- Return type:
(
int
, out:Vips.Image
)
Write self to out. Use
Vips.Image.new
() and friends to create theVips.Image
you want to write to.See also:
Vips.Image.new
(), vips_copy(), vips_image_write_to_file().
- write_line(ypos, linebuffer)¶
- Parameters:
- Returns:
0 on success, or -1 on error.
- Return type:
Write a line of pixels to an image. This function must be called repeatedly with ypos increasing from 0 to
Vips.Image
::height
. linebuffer must be VIPS_IMAGE_SIZEOF_LINE() bytes long.See also: vips_image_generate().
- write_prepare()¶
- Returns:
0 on success, or -1 on error.
- Return type:
Call this after setting header fields (width, height, and so on) to allocate resources ready for writing.
Normally this function is called for you by vips_image_generate() or
Vips.Image.write_line
(). You will need to call it yourself if you plan to write directly to the ->data member of a memory image.
- write_to_memory()¶
- Returns:
return buffer start here
- Return type:
Writes self to memory as a simple, unformatted C-style array.
The caller is responsible for freeing this memory with
GLib.free
().See also: vips_image_write_to_buffer().
- do_eval(progress, data) virtual¶
- Parameters:
progress (
Vips.Progress
) –
- do_posteval(progress, data) virtual¶
- Parameters:
progress (
Vips.Progress
) –
- do_preeval(progress, data) virtual¶
- Parameters:
progress (
Vips.Progress
) –
Signal Details¶
- Vips.Image.signals.eval(image, progress)¶
- Signal Name:
eval
- Flags:
- Parameters:
image (
Vips.Image
) – The object which received the signalprogress (
Vips.Progress
) –Vips.Progress
for this image
The
::eval
signal is emitted once per work unit (typically a 128 x 128 area of pixels) during image computation.You can use this signal to update user-interfaces with progress feedback. Beware of updating too frequently: you will usually need some throttling mechanism.
Use
Vips.Image.set_progress
() to turn on progress reporting for an image.
- Vips.Image.signals.invalidate(image)¶
- Signal Name:
invalidate
- Flags:
- Parameters:
image (
Vips.Image
) – The object which received the signal
The
::invalidate
signal is emitted when an image or one of it’s upstream data sources has been destructively modified. SeeVips.Image.invalidate_all
().
- Vips.Image.signals.minimise(image)¶
- Signal Name:
minimise
- Flags:
- Parameters:
image (
Vips.Image
) – The object which received the signal
The
::minimise
signal is emitted when an image has been asked to minimise memory usage. All non-essential caches are dropped. SeeVips.Image.minimise_all
().
- Vips.Image.signals.posteval(image, progress)¶
- Signal Name:
posteval
- Flags:
- Parameters:
image (
Vips.Image
) – The object which received the signalprogress (
Vips.Progress
) –Vips.Progress
for this image
The
::posteval
signal is emitted once at the end of the computation of image. It’s a good place to shut down evaluation feedback.Use
Vips.Image.set_progress
() to turn on progress reporting for an image.
- Vips.Image.signals.preeval(image, progress)¶
- Signal Name:
preeval
- Flags:
- Parameters:
image (
Vips.Image
) – The object which received the signalprogress (
Vips.Progress
) –Vips.Progress
for this image
The
::preeval
signal is emitted once before computation of image starts. It’s a good place to set up evaluation feedback.Use
Vips.Image.set_progress
() to turn on progress reporting for an image.
- Vips.Image.signals.written(image)¶
- Signal Name:
written
- Flags:
- Parameters:
image (
Vips.Image
) – The object which received the signal- Returns:
set to non-zero to indicate error
- Return type:
result:
int
The
::written
signal is emitted just after an image has been written to. It is used by vips to implement things like write to foreign file formats.
Property Details¶
- Vips.Image.props.bands¶
-
Number of bands in image
- Vips.Image.props.coding¶
- Name:
coding
- Type:
- Default Value:
- Flags:
Pixel coding
- Vips.Image.props.demand¶
- Name:
demand
- Type:
- Default Value:
- Flags:
Preferred demand style for this image
- Vips.Image.props.filename¶
-
Image filename
- Vips.Image.props.foreign_buffer¶
-
Pointer to foreign pixels
- Vips.Image.props.format¶
- Name:
format
- Type:
- Default Value:
- Flags:
Pixel format in image
- Vips.Image.props.height¶
-
Image height in pixels
- Vips.Image.props.interpretation¶
- Name:
interpretation
- Type:
- Default Value:
- Flags:
Pixel interpretation
- Vips.Image.props.kill¶
-
Block evaluation on this image
- Vips.Image.props.sizeof_header¶
-
Offset in bytes from start of file
- Vips.Image.props.width¶
-
Image width in pixels
- Vips.Image.props.xoffset¶
-
Horizontal offset of origin
- Vips.Image.props.xres¶
-
Horizontal resolution in pixels/mm
- Vips.Image.props.yoffset¶
-
Vertical offset of origin