vips.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. #include "vips.h"
  2. #include <string.h>
  3. #define VIPS_SUPPORT_SMARTCROP \
  4. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 5))
  5. #define VIPS_SUPPORT_HASALPHA \
  6. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 5))
  7. #define VIPS_SUPPORT_GIF \
  8. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 3))
  9. #define VIPS_SUPPORT_SVG \
  10. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 3))
  11. #define VIPS_SUPPORT_TIFF \
  12. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 6))
  13. #define VIPS_SUPPORT_MAGICK \
  14. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 7))
  15. #define VIPS_SUPPORT_PNG_QUANTIZATION \
  16. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 7))
  17. #define VIPS_SUPPORT_WEBP_SCALE_ON_LOAD \
  18. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
  19. #define VIPS_SUPPORT_WEBP_ANIMATION \
  20. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
  21. #define VIPS_SUPPORT_HEIF \
  22. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
  23. #define VIPS_SUPPORT_BUILTIN_ICC \
  24. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
  25. #define VIPS_SUPPORT_COMPOSITE \
  26. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 6))
  27. #define VIPS_SUPPORT_FIND_TRIM \
  28. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 6))
  29. #define EXIF_ORIENTATION "exif-ifd0-Orientation"
  30. #if (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
  31. #define VIPS_BLOB_DATA_TYPE const void *
  32. #else
  33. #define VIPS_BLOB_DATA_TYPE void *
  34. #endif
  35. int
  36. vips_initialize() {
  37. return vips_init("imgproxy");
  38. }
  39. void
  40. clear_image(VipsImage **in) {
  41. if (G_IS_OBJECT(*in)) g_clear_object(in);
  42. }
  43. void
  44. g_free_go(void **buf) {
  45. g_free(*buf);
  46. }
  47. void
  48. swap_and_clear(VipsImage **in, VipsImage *out) {
  49. clear_image(in);
  50. *in = out;
  51. }
  52. int
  53. vips_type_find_load_go(int imgtype) {
  54. switch (imgtype)
  55. {
  56. case (JPEG):
  57. return vips_type_find("VipsOperation", "jpegload_buffer");
  58. case (PNG):
  59. return vips_type_find("VipsOperation", "pngload_buffer");
  60. case (WEBP):
  61. return vips_type_find("VipsOperation", "webpload_buffer");
  62. case (GIF):
  63. return vips_type_find("VipsOperation", "gifload_buffer");
  64. case (SVG):
  65. return vips_type_find("VipsOperation", "svgload_buffer");
  66. case (HEIC):
  67. return vips_type_find("VipsOperation", "heifload_buffer");
  68. case (BMP):
  69. return vips_type_find("VipsOperation", "magickload_buffer");
  70. case (TIFF):
  71. return vips_type_find("VipsOperation", "tiffload_buffer");
  72. }
  73. return 0;
  74. }
  75. int
  76. vips_type_find_save_go(int imgtype) {
  77. switch (imgtype)
  78. {
  79. case (JPEG):
  80. return vips_type_find("VipsOperation", "jpegsave_buffer");
  81. case (PNG):
  82. return vips_type_find("VipsOperation", "pngsave_buffer");
  83. case (WEBP):
  84. return vips_type_find("VipsOperation", "webpsave_buffer");
  85. case (GIF):
  86. return vips_type_find("VipsOperation", "magicksave_buffer");
  87. case (ICO):
  88. return vips_type_find("VipsOperation", "magicksave_buffer");
  89. case (HEIC):
  90. return vips_type_find("VipsOperation", "heifsave_buffer");
  91. case (BMP):
  92. return vips_type_find("VipsOperation", "magicksave_buffer");
  93. case (TIFF):
  94. return vips_type_find("VipsOperation", "tiffsave_buffer");
  95. }
  96. return 0;
  97. }
  98. int
  99. vips_jpegload_go(void *buf, size_t len, int shrink, VipsImage **out) {
  100. if (shrink > 1)
  101. return vips_jpegload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, "shrink", shrink, NULL);
  102. return vips_jpegload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
  103. }
  104. int
  105. vips_pngload_go(void *buf, size_t len, VipsImage **out) {
  106. return vips_pngload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
  107. }
  108. int
  109. vips_webpload_go(void *buf, size_t len, double scale, int pages, VipsImage **out) {
  110. return vips_webpload_buffer(
  111. buf, len, out,
  112. "access", VIPS_ACCESS_SEQUENTIAL,
  113. #if VIPS_SUPPORT_WEBP_SCALE_ON_LOAD
  114. "scale", scale,
  115. #else
  116. "shrink", (int)(1.0 / scale),
  117. #endif
  118. #if VIPS_SUPPORT_WEBP_ANIMATION
  119. "n", pages,
  120. #endif
  121. NULL
  122. );
  123. }
  124. int
  125. vips_gifload_go(void *buf, size_t len, int pages, VipsImage **out) {
  126. #if VIPS_SUPPORT_GIF
  127. return vips_gifload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, "n", pages, NULL);
  128. #else
  129. vips_error("vips_gifload_go", "Loading GIF is not supported (libvips 8.3+ reuired)");
  130. return 1;
  131. #endif
  132. }
  133. int
  134. vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out) {
  135. #if VIPS_SUPPORT_SVG
  136. return vips_svgload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, "scale", scale, NULL);
  137. #else
  138. vips_error("vips_svgload_go", "Loading SVG is not supported (libvips 8.5+ reuired)");
  139. return 1;
  140. #endif
  141. }
  142. int
  143. vips_heifload_go(void *buf, size_t len, VipsImage **out) {
  144. #if VIPS_SUPPORT_HEIF
  145. return vips_heifload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
  146. #else
  147. vips_error("vips_heifload_go", "Loading HEIF is not supported (libvips 8.8+ reuired)");
  148. return 1;
  149. #endif
  150. }
  151. int
  152. vips_bmpload_go(void *buf, size_t len, VipsImage **out) {
  153. #if VIPS_SUPPORT_MAGICK
  154. return vips_magickload_buffer(buf, len, out, NULL);
  155. #else
  156. vips_error("vips_bmpload_go", "Loading BMP is not supported");
  157. return 1;
  158. #endif
  159. }
  160. int
  161. vips_tiffload_go(void *buf, size_t len, VipsImage **out) {
  162. #if VIPS_SUPPORT_TIFF
  163. return vips_tiffload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
  164. #else
  165. vips_error("vips_tiffload_go", "Loading TIFF is not supported (libvips 8.6+ reuired)");
  166. return 1;
  167. #endif
  168. }
  169. int
  170. vips_get_orientation(VipsImage *image) {
  171. #ifdef VIPS_META_ORIENTATION
  172. int orientation;
  173. if (
  174. vips_image_get_typeof(image, VIPS_META_ORIENTATION) == G_TYPE_INT &&
  175. vips_image_get_int(image, VIPS_META_ORIENTATION, &orientation) == 0
  176. ) return orientation;
  177. #else
  178. const char *orientation;
  179. if (
  180. vips_image_get_typeof(image, EXIF_ORIENTATION) == VIPS_TYPE_REF_STRING &&
  181. vips_image_get_string(image, EXIF_ORIENTATION, &orientation) == 0
  182. ) return atoi(orientation);
  183. #endif
  184. return 1;
  185. }
  186. int
  187. vips_support_smartcrop() {
  188. return VIPS_SUPPORT_SMARTCROP;
  189. }
  190. VipsBandFormat
  191. vips_band_format(VipsImage *in) {
  192. return in->BandFmt;
  193. }
  194. gboolean
  195. vips_support_webp_animation() {
  196. return VIPS_SUPPORT_WEBP_ANIMATION;
  197. }
  198. gboolean
  199. vips_is_animated(VipsImage * in) {
  200. return( vips_image_get_typeof(in, "page-height") != G_TYPE_INVALID &&
  201. vips_image_get_typeof(in, "gif-delay") != G_TYPE_INVALID &&
  202. vips_image_get_typeof(in, "gif-loop") != G_TYPE_INVALID );
  203. }
  204. gboolean
  205. vips_image_hasalpha_go(VipsImage * in) {
  206. #if VIPS_SUPPORT_HASALPHA
  207. return vips_image_hasalpha(in);
  208. #else
  209. return( in->Bands == 2 ||
  210. (in->Bands == 4 && in->Type != VIPS_INTERPRETATION_CMYK) ||
  211. in->Bands > 4 );
  212. #endif
  213. }
  214. int
  215. vips_copy_go(VipsImage *in, VipsImage **out) {
  216. return vips_copy(in, out, NULL);
  217. }
  218. int
  219. vips_cast_go(VipsImage *in, VipsImage **out, VipsBandFormat format) {
  220. return vips_cast(in, out, format, NULL);
  221. }
  222. int
  223. vips_rad2float_go(VipsImage *in, VipsImage **out) {
  224. return vips_rad2float(in, out, NULL);
  225. }
  226. int
  227. vips_resize_go(VipsImage *in, VipsImage **out, double scale) {
  228. return vips_resize(in, out, scale, NULL);
  229. }
  230. int
  231. vips_resize_with_premultiply(VipsImage *in, VipsImage **out, double scale) {
  232. VipsBandFormat format;
  233. VipsImage *tmp1, *tmp2;
  234. format = vips_band_format(in);
  235. if (vips_premultiply(in, &tmp1, NULL))
  236. return 1;
  237. if (vips_resize(tmp1, &tmp2, scale, NULL)) {
  238. clear_image(&tmp1);
  239. return 1;
  240. }
  241. swap_and_clear(&tmp1, tmp2);
  242. if (vips_unpremultiply(tmp1, &tmp2, NULL)) {
  243. clear_image(&tmp1);
  244. return 1;
  245. }
  246. swap_and_clear(&tmp1, tmp2);
  247. if (vips_cast(tmp1, out, format, NULL)) {
  248. clear_image(&tmp1);
  249. return 1;
  250. }
  251. clear_image(&tmp1);
  252. return 0;
  253. }
  254. int
  255. vips_icc_is_srgb_iec61966(VipsImage *in) {
  256. VIPS_BLOB_DATA_TYPE data;
  257. size_t data_len;
  258. // 1998-12-01
  259. static char date[] = { 7, 206, 0, 2, 0, 9 };
  260. // 2.1
  261. static char version[] = { 2, 16, 0, 0 };
  262. if (vips_image_get_blob(in, VIPS_META_ICC_NAME, &data, &data_len))
  263. return FALSE;
  264. // Less than header size
  265. if (data_len < 128)
  266. return FALSE;
  267. // Predict it is sRGB IEC61966 2.1 by checking some header fields
  268. return ((memcmp(data + 48, "IEC ", 4) == 0) && // Device manufacturer
  269. (memcmp(data + 52, "sRGB", 4) == 0) && // Device model
  270. (memcmp(data + 80, "HP ", 4) == 0) && // Profile creator
  271. (memcmp(data + 24, date, 6) == 0) && // Date of creation
  272. (memcmp(data + 8, version, 4) == 0)); // Version
  273. }
  274. int
  275. vips_has_embedded_icc(VipsImage *in) {
  276. return vips_image_get_typeof(in, VIPS_META_ICC_NAME) != 0;
  277. }
  278. int
  279. vips_support_builtin_icc() {
  280. return VIPS_SUPPORT_BUILTIN_ICC;
  281. }
  282. int
  283. vips_icc_import_go(VipsImage *in, VipsImage **out, char *profile) {
  284. if (vips_icc_import(in, out, "input_profile", profile, "embedded", TRUE, "pcs", VIPS_PCS_XYZ, NULL))
  285. return 1;
  286. vips_image_remove(*out, VIPS_META_ICC_NAME);
  287. return 0;
  288. }
  289. int
  290. vips_colourspace_go(VipsImage *in, VipsImage **out, VipsInterpretation cs) {
  291. return vips_colourspace(in, out, cs, NULL);
  292. }
  293. int
  294. vips_rot_go(VipsImage *in, VipsImage **out, VipsAngle angle) {
  295. return vips_rot(in, out, angle, NULL);
  296. }
  297. int
  298. vips_flip_horizontal_go(VipsImage *in, VipsImage **out) {
  299. return vips_flip(in, out, VIPS_DIRECTION_HORIZONTAL, NULL);
  300. }
  301. int
  302. vips_smartcrop_go(VipsImage *in, VipsImage **out, int width, int height) {
  303. #if VIPS_SUPPORT_SMARTCROP
  304. return vips_smartcrop(in, out, width, height, NULL);
  305. #else
  306. vips_error("vips_smartcrop_go", "Smart crop is not supported (libvips 8.5+ reuired)");
  307. return 1;
  308. #endif
  309. }
  310. int
  311. vips_gaussblur_go(VipsImage *in, VipsImage **out, double sigma) {
  312. return vips_gaussblur(in, out, sigma, NULL);
  313. }
  314. int
  315. vips_sharpen_go(VipsImage *in, VipsImage **out, double sigma) {
  316. return vips_sharpen(in, out, "sigma", sigma, NULL);
  317. }
  318. int
  319. vips_flatten_go(VipsImage *in, VipsImage **out, double r, double g, double b) {
  320. VipsArrayDouble *bg = vips_array_double_newv(3, r, g, b);
  321. int res = vips_flatten(in, out, "background", bg, NULL);
  322. vips_area_unref((VipsArea *)bg);
  323. return res;
  324. }
  325. int
  326. vips_extract_area_go(VipsImage *in, VipsImage **out, int left, int top, int width, int height) {
  327. return vips_extract_area(in, out, left, top, width, height, NULL);
  328. }
  329. int
  330. vips_trim(VipsImage *in, VipsImage **out, double threshold) {
  331. #if VIPS_SUPPORT_FIND_TRIM
  332. VipsImage *tmp;
  333. if (vips_image_hasalpha(in)) {
  334. if (vips_flatten(in, &tmp, NULL))
  335. return 1;
  336. } else {
  337. if (vips_copy(in, &tmp, NULL))
  338. return 1;
  339. }
  340. double *bg;
  341. int bgn;
  342. if (vips_getpoint(tmp, &bg, &bgn, 0, 0, NULL)) {
  343. clear_image(&tmp);
  344. return 1;
  345. }
  346. VipsArrayDouble *bga = vips_array_double_new(bg, bgn);
  347. int left, top, width, height;
  348. if (vips_find_trim(tmp, &left, &top, &width, &height, "background", bga, "threshold", threshold, NULL)) {
  349. clear_image(&tmp);
  350. vips_area_unref((VipsArea *)bga);
  351. g_free(bg);
  352. return 1;
  353. }
  354. clear_image(&tmp);
  355. vips_area_unref((VipsArea *)bga);
  356. g_free(bg);
  357. if (width == 0 || height == 0) {
  358. return vips_copy(in, out, NULL);
  359. }
  360. return vips_extract_area(in, out, left, top, width, height, NULL);
  361. #else
  362. vips_error("vips_trim", "Trim is not supported (libvips 8.6+ reuired)");
  363. return 1;
  364. #endif
  365. }
  366. int
  367. vips_replicate_go(VipsImage *in, VipsImage **out, int width, int height) {
  368. VipsImage *tmp;
  369. if (vips_replicate(in, &tmp, 1 + width / in->Xsize, 1 + height / in->Ysize, NULL))
  370. return 1;
  371. if (vips_extract_area(tmp, out, 0, 0, width, height, NULL)) {
  372. clear_image(&tmp);
  373. return 1;
  374. }
  375. clear_image(&tmp);
  376. return 0;
  377. }
  378. int
  379. vips_embed_go(VipsImage *in, VipsImage **out, int x, int y, int width, int height, double *bg, int bgn) {
  380. VipsArrayDouble *bga = vips_array_double_new(bg, bgn);
  381. int ret = vips_embed(
  382. in, out, x, y, width, height,
  383. "extend", VIPS_EXTEND_BACKGROUND,
  384. "background", bga,
  385. NULL
  386. );
  387. vips_area_unref((VipsArea *)bga);
  388. return ret;
  389. }
  390. int
  391. vips_ensure_alpha(VipsImage *in, VipsImage **out) {
  392. if (vips_image_hasalpha_go(in)) {
  393. return vips_copy(in, out, NULL);
  394. }
  395. return vips_bandjoin_const1(in, out, 255, NULL);
  396. }
  397. int
  398. vips_apply_watermark(VipsImage *in, VipsImage *watermark, VipsImage **out, double opacity) {
  399. #if VIPS_SUPPORT_COMPOSITE
  400. VipsImage *base = vips_image_new();
  401. VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 5);
  402. if (opacity < 1) {
  403. if (
  404. vips_extract_band(watermark, &t[0], 0, "n", watermark->Bands - 1, NULL) ||
  405. vips_extract_band(watermark, &t[1], watermark->Bands - 1, "n", 1, NULL) ||
  406. vips_linear1(t[1], &t[2], opacity, 0, NULL) ||
  407. vips_bandjoin2(t[0], t[2], &t[3], NULL)
  408. ) {
  409. clear_image(&base);
  410. return 1;
  411. }
  412. } else {
  413. if (vips_copy(watermark, &t[3], NULL)) {
  414. clear_image(&base);
  415. return 1;
  416. }
  417. }
  418. int res =
  419. vips_composite2(in, t[3], &t[4], VIPS_BLEND_MODE_OVER, "compositing_space", in->Type, NULL) ||
  420. vips_cast(t[4], out, vips_image_get_format(in), NULL);
  421. clear_image(&base);
  422. return res;
  423. #else
  424. vips_error("vips_apply_watermark", "Watermarking is not supported (libvips 8.6+ reuired)");
  425. return 1;
  426. #endif
  427. }
  428. int
  429. vips_arrayjoin_go(VipsImage **in, VipsImage **out, int n) {
  430. return vips_arrayjoin(in, out, n, "across", 1, NULL);
  431. }
  432. int
  433. vips_jpegsave_go(VipsImage *in, void **buf, size_t *len, int quality, int interlace, gboolean strip) {
  434. return vips_jpegsave_buffer(in, buf, len, "profile", "none", "Q", quality, "strip", strip, "optimize_coding", TRUE, "interlace", interlace, NULL);
  435. }
  436. int
  437. vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace, int quantize, int colors) {
  438. return vips_pngsave_buffer(
  439. in, buf, len,
  440. "profile", "none",
  441. "filter", VIPS_FOREIGN_PNG_FILTER_NONE,
  442. "interlace", interlace,
  443. #if VIPS_SUPPORT_PNG_QUANTIZATION
  444. "palette", quantize,
  445. "colours", colors,
  446. #endif // VIPS_SUPPORT_PNG_QUANTIZATION
  447. NULL);
  448. }
  449. int
  450. vips_webpsave_go(VipsImage *in, void **buf, size_t *len, int quality, gboolean strip) {
  451. return vips_webpsave_buffer(in, buf, len, "Q", quality, "strip", strip, NULL);
  452. }
  453. int
  454. vips_gifsave_go(VipsImage *in, void **buf, size_t *len) {
  455. #if VIPS_SUPPORT_MAGICK
  456. return vips_magicksave_buffer(in, buf, len, "format", "gif", NULL);
  457. #else
  458. vips_error("vips_gifsave_go", "Saving GIF is not supported (libvips 8.7+ reuired)");
  459. return 1;
  460. #endif
  461. }
  462. int
  463. vips_icosave_go(VipsImage *in, void **buf, size_t *len) {
  464. #if VIPS_SUPPORT_MAGICK
  465. return vips_magicksave_buffer(in, buf, len, "format", "ico", NULL);
  466. #else
  467. vips_error("vips_icosave_go", "Saving ICO is not supported (libvips 8.7+ reuired)");
  468. return 1;
  469. #endif
  470. }
  471. int
  472. vips_heifsave_go(VipsImage *in, void **buf, size_t *len, int quality) {
  473. #if VIPS_SUPPORT_HEIF
  474. return vips_heifsave_buffer(in, buf, len, "Q", quality, NULL);
  475. #else
  476. vips_error("vips_heifsave_go", "Saving HEIF is not supported (libvips 8.8+ reuired)");
  477. return 1;
  478. #endif
  479. }
  480. int
  481. vips_tiffsave_go(VipsImage *in, void **buf, size_t *len, int quality) {
  482. #if VIPS_SUPPORT_TIFF
  483. return vips_tiffsave_buffer(in, buf, len, "Q", quality, NULL);
  484. #else
  485. vips_error("vips_tiffsave_go", "Saving TIFF is not supported (libvips 8.6+ reuired)");
  486. return 1;
  487. #endif
  488. }
  489. int
  490. vips_bmpsave_go(VipsImage *in, void **buf, size_t *len) {
  491. #if VIPS_SUPPORT_MAGICK
  492. return vips_magicksave_buffer(in, buf, len, "format", "bmp", "quality", NULL);
  493. #else
  494. vips_error("vips_bmpsave_go", "Saving BMP is not supported");
  495. return 1;
  496. #endif
  497. }
  498. void
  499. vips_cleanup() {
  500. vips_error_clear();
  501. vips_thread_shutdown();
  502. }