File: use-vips-func.c

package info (click to toggle)
vips 8.18.0-2
  • links: PTS
  • area: main
  • in suites: forky
  • size: 53,448 kB
  • sloc: ansic: 172,621; cpp: 12,257; python: 5,077; sh: 773; perl: 40; makefile: 25; javascript: 6
file content (43 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Example showing how to call a couple of vips functions using an input
 * image file and creating an output file
 * also gathers some info on the input image
 */
#include <stdio.h>
#include <vips/vips.h>

int
main(int argc, char **argv)
{
	VipsImage *in;
	double mean;
	VipsImage *out;

	if (VIPS_INIT(argv[0]))
		vips_error_exit(NULL);

	if (argc != 3)
		vips_error_exit("usage: %s infile outfile", argv[0]);

	if (!(in = vips_image_new_from_file(argv[1], NULL)))
		vips_error_exit(NULL);

	printf("image width = %d\n", vips_image_get_width(in));

	if (vips_avg(in, &mean, NULL))
		vips_error_exit(NULL);

	printf("mean pixel value = %g\n", mean);

	/* generate photo nexative - replace with other vips_ funcs */
	if (vips_invert(in, &out, NULL))
		vips_error_exit(NULL);

	g_object_unref(in);

	if (vips_image_write_to_file(out, argv[2], NULL))
		vips_error_exit(NULL);

	g_object_unref(out);

	return 0;
}