Vips.Target¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w |
Blob to save to |
||
r/w |
File descriptor should output to memory |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
blob |
r |
||
delete_on_close |
r |
||
delete_on_close_filename |
r |
||
ended |
r |
||
memory |
r |
||
memory_buffer |
r |
||
output_buffer |
r |
||
parent_object |
r |
||
position |
r |
||
write_point |
r |
Class Details¶
- class Vips.Target(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A [class`Target`] provides a unified interface for writing data to various output destinations.
This target could be a socket, file, memory area, or any other destination that accepts byte data.
- classmethod new_temp(based_on)¶
- Parameters:
based_on (
Vips.Target) – base the temporary target on this target- Returns:
a new target.
- Return type:
Create a temporary target – either a temporary file on disc, or an area in memory, depending on what sort of target based_on is.
::: seealso [ctor`Target`.new_to_file].
- classmethod new_to_descriptor(descriptor)¶
- Parameters:
descriptor (
int) – write to this file descriptor- Returns:
a new target.
- Return type:
Create a target attached to a file descriptor. descriptor is kept open until the target is finalized.
::: seealso [ctor`Target`.new_to_file].
- classmethod new_to_file(filename)¶
- Parameters:
filename (
str) – write to this file- Returns:
a new target.
- Return type:
Create a target attached to a file.
- classmethod new_to_memory()¶
- Returns:
a new target.
- Return type:
Create a target which will write to a memory area. Read from blob to get memory.
::: seealso [ctor`Target`.new_to_file].
- end()¶
- Returns:
0 on success, -1 on error.
- Return type:
Call this at the end of write to make the target do any cleaning up. You can call it many times.
After a target has been ended, further writes will do nothing.
- putc(ch)¶
-
Write a single character ch to self. See the macro [funcTARGET_PUTC] for a faster way to do this.
- read(buffer, length)¶
- Parameters:
- Returns:
the number of bytes read, 0 on end of file, -1 on error.
- Return type:
Read up to length bytes from self and store the bytes in buffer. Return the number of bytes actually read. If all bytes have been read from the file, return 0.
Arguments exactly as read()).
Reading from a target sounds weird, but libtiff needs this for multi-page writes. This method will fail for targets like pipes.
- seek(offset, whence)¶
- Parameters:
- Returns:
the new offset, -1 on error.
- Return type:
Seek the target. This behaves exactly as lseek()).
Seeking a target sounds weird, but libtiff needs this. This method will fail for targets like pipes.
- steal()¶
- Returns:
the data
- Return type:
Memory targets only (see [ctor`Target`.new_to_memory]). Steal all data written to the target so far, and call [method`Target`.end].
You must free the returned pointer with [func`GLib`.free].
The data is NOT automatically null-terminated. Use [method`Target`.putc] with a ‘\0’ before calling this to get a null-terminated string.
You can’t call this after [method`Target`.end], since that moves the data to a blob, and we can’t steal from that in case the pointer has been shared.
You can’t call this function more than once.
- steal_text()¶
- Returns:
target contents as a null-terminated string.
- Return type:
As [method`Target`.steal], but return a null-terminated string.
- write(data, length)¶
- Parameters:
- Returns:
0 on success, -1 on error.
- Return type:
Write length bytes from data to the output.
- write_amp(str)¶
-
Write str to self, but escape stuff that xml hates in text. Our argument string is utf-8.
XML rules:
We must escape &<>
Don’t escape \n, \t, \r
Do escape the other ASCII codes.
- writes(str)¶
-
Write a null-terminated string to self.
- do_end() virtual¶
- Returns:
0 on success, -1 on error.
- Return type:
Call this at the end of write to make the target do any cleaning up. You can call it many times.
After a target has been ended, further writes will do nothing.
- do_finish() virtual¶
- do_read(buffer, length) virtual¶
- Parameters:
- Returns:
the number of bytes read, 0 on end of file, -1 on error.
- Return type:
Read up to length bytes from target and store the bytes in buffer. Return the number of bytes actually read. If all bytes have been read from the file, return 0.
Arguments exactly as read()).
Reading from a target sounds weird, but libtiff needs this for multi-page writes. This method will fail for targets like pipes.
Property Details¶
- Vips.Target.props.blob¶
-
Blob to save to