Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/share/gtk-doc/html/libvips/ drwxr-xr-x | |
| Viewing file: Select action/file-type:
IntroductionVIPS comes with a convenient, high-level C API. You should read the API docs for full details, but this section will try to give a brief overview. Library startup
When your program starts, use
You can add the VIPS flags to your The VipsImage class
The basic data object is the VipsImage. You can create an
image from a file on disc or from an area of memory, either
as a C-style array, or as a formatted object, like JPEG. See
Once you have an image, you can get properties from it in the usual way.
You can use projection functions, like Reference counting
VIPS is based on the See VipsOperation for more detail on VIPS reference counting conventions. VIPS operations
Use things like const char *filename; VipsImage *in = vips_image_new_from_file (filename, NULL); const int x = 10; const int y = 10; const int width = 1000; const int height = 1000; VipsImage *out; if (vips_embed (in, &out, x, y, width, height, NULL)) error_handling();
Now Operations can take optional arguments. You give these as a set of NULL-terminated name-value pairs at the end of the call. For example, you can write: if (vips_embed (in, &out, x, y, width, height, "extend", VIPS_EXTEND_COPY, NULL)) error_handling();
And now the new edge pixels, which were black, will be filled with a copy
of the edge pixels of $ vips embed embed an image in a larger image usage: embed in out x y width height where: in - Input image, input VipsImage out - Output image, output VipsImage x - Left edge of input in output, input gint default: 0 min: -1000000000, max: 1000000000 y - Top edge of input in output, input gint default: 0 min: -1000000000, max: 1000000000 width - Image width in pixels, input gint default: 1 min: 1, max: 1000000000 height - Image height in pixels, input gint default: 1 min: 1, max: 1000000000 optional arguments: extend - How to generate the extra pixels, input VipsExtend default: black allowed: black, copy, repeat, mirror, white, background background - Colour for background pixels, input VipsArrayDouble operation flags: sequential-unbuffered See VipsOperation for more information on running operations on images. The API docs have a handy table of all vips operations, if you want to find out how to do something, try searching that.
When you are done, you can write
the final image to a disc file, to a formatted memory buffer, or to
C-style memory array. See Getting pixels
Use VipsRegion to read pixels out of images. You can use
Error handlingVIPS keeps a log of error message, see VIPS Error to find out how to get and clear the error log. ExampleOn *nix systems, you can compile the example code with something like: $ gcc -g -Wall myprog.c `pkg-config vips --cflags --libs` On Windows, you'll need to set the compiler flags by hand, perhaps: x86_64-w64-mingw32-gcc-win32 -mms-bitfields \ -Ic:/vips-8.6/include \ -Ic:/vips-8.6/include/glib-2.0 \ -Ic:/vips-8.6/lib/glib-2.0/include \ myprog.c \ -Lc:/vips-8.6/lib \ -lvips -lz -ljpeg -lstdc++ -lxml2 -lfftw3 -lm -lMagickWand -llcms2 \ -lopenslide -lcfitsio -lpangoft2-1.0 -ltiff -lpng14 -lexif \ -lMagickCore -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 \ -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl \ -o myprog.exe
Example 1. VIPS from C example
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0049 ]-- |