vips.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. #include "vips.h"
  2. #include <string.h>
  3. #define VIPS_SUPPORT_AVIF_SPEED \
  4. (VIPS_MAJOR_VERSION > 8 || \
  5. (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION > 10) || \
  6. (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 10 && VIPS_MICRO_VERSION >= 2))
  7. #define VIPS_SUPPORT_AVIF_EFFORT \
  8. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 12))
  9. #define VIPS_SUPPORT_GIFSAVE \
  10. (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 12))
  11. #define VIPS_GIF_RESOLUTION_LIMITED \
  12. (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION <= 12)
  13. int
  14. vips_initialize() {
  15. return vips_init("imgproxy");
  16. }
  17. void
  18. clear_image(VipsImage **in) {
  19. if (G_IS_OBJECT(*in)) g_clear_object(in);
  20. }
  21. void
  22. g_free_go(void **buf) {
  23. g_free(*buf);
  24. }
  25. void
  26. swap_and_clear(VipsImage **in, VipsImage *out) {
  27. clear_image(in);
  28. *in = out;
  29. }
  30. int
  31. gif_resolution_limit() {
  32. #if VIPS_GIF_RESOLUTION_LIMITED
  33. // https://github.com/libvips/libvips/blob/v8.12.2/libvips/foreign/cgifsave.c#L437-L442
  34. return 2000 * 2000;
  35. #else
  36. return INT_MAX / 4;
  37. #endif
  38. }
  39. int
  40. vips_jpegload_go(void *buf, size_t len, int shrink, VipsImage **out) {
  41. if (shrink > 1)
  42. return vips_jpegload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, "shrink", shrink, NULL);
  43. return vips_jpegload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
  44. }
  45. int
  46. vips_pngload_go(void *buf, size_t len, VipsImage **out) {
  47. return vips_pngload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
  48. }
  49. int
  50. vips_webpload_go(void *buf, size_t len, double scale, int pages, VipsImage **out) {
  51. return vips_webpload_buffer(
  52. buf, len, out,
  53. "access", VIPS_ACCESS_SEQUENTIAL,
  54. "scale", scale,
  55. "n", pages,
  56. NULL
  57. );
  58. }
  59. int
  60. vips_gifload_go(void *buf, size_t len, int pages, VipsImage **out) {
  61. return vips_gifload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, "n", pages, NULL);
  62. }
  63. int
  64. vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out) {
  65. // libvips limits the minimal scale to 0.001, so we have to scale down dpi
  66. // for lower scale values
  67. double dpi = 72.0;
  68. if (scale < 0.001) {
  69. dpi *= VIPS_MAX(scale / 0.001, 0.001);
  70. scale = 0.001;
  71. }
  72. return vips_svgload_buffer(
  73. buf, len, out,
  74. "access", VIPS_ACCESS_SEQUENTIAL,
  75. "scale", scale,
  76. "dpi", dpi,
  77. NULL
  78. );
  79. }
  80. int
  81. vips_heifload_go(void *buf, size_t len, VipsImage **out, int thumbnail) {
  82. return vips_heifload_buffer(
  83. buf, len, out,
  84. "access", VIPS_ACCESS_SEQUENTIAL,
  85. "thumbnail", thumbnail,
  86. NULL
  87. );
  88. }
  89. int
  90. vips_tiffload_go(void *buf, size_t len, VipsImage **out) {
  91. return vips_tiffload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
  92. }
  93. int
  94. vips_black_go(VipsImage **out, int width, int height, int bands) {
  95. VipsImage *tmp;
  96. int res = vips_black(&tmp, width, height, "bands", bands, NULL) ||
  97. vips_copy(tmp, out, "interpretation", VIPS_INTERPRETATION_sRGB, NULL);
  98. clear_image(&tmp);
  99. return res;
  100. }
  101. int
  102. vips_get_orientation(VipsImage *image) {
  103. int orientation;
  104. if (
  105. vips_image_get_typeof(image, VIPS_META_ORIENTATION) == G_TYPE_INT &&
  106. vips_image_get_int(image, VIPS_META_ORIENTATION, &orientation) == 0
  107. ) return orientation;
  108. return 1;
  109. }
  110. int
  111. vips_get_palette_bit_depth(VipsImage *image) {
  112. int palette_bit_depth;
  113. if (
  114. vips_image_get_typeof(image, "palette-bit-depth") == G_TYPE_INT &&
  115. vips_image_get_int(image, "palette-bit-depth", &palette_bit_depth) == 0
  116. ) return palette_bit_depth;
  117. return 0;
  118. }
  119. VipsBandFormat
  120. vips_band_format(VipsImage *in) {
  121. return in->BandFmt;
  122. }
  123. gboolean
  124. vips_is_animated(VipsImage * in) {
  125. int n_pages;
  126. return( vips_image_get_typeof(in, "delay") != G_TYPE_INVALID &&
  127. vips_image_get_typeof(in, "loop") != G_TYPE_INVALID &&
  128. vips_image_get_typeof(in, "page-height") == G_TYPE_INT &&
  129. vips_image_get_typeof(in, "n-pages") == G_TYPE_INT &&
  130. vips_image_get_int(in, "n-pages", &n_pages) == 0 &&
  131. n_pages > 1 );
  132. }
  133. int
  134. vips_image_get_array_int_go(VipsImage *image, const char *name, int **out, int *n) {
  135. return vips_image_get_array_int(image, name, out, n);
  136. }
  137. void
  138. vips_image_set_array_int_go(VipsImage *image, const char *name, const int *array, int n) {
  139. vips_image_set_array_int(image, name, array, n);
  140. }
  141. int
  142. vips_addalpha_go(VipsImage *in, VipsImage **out) {
  143. return vips_addalpha(in, out, NULL);
  144. }
  145. int
  146. vips_premultiply_go(VipsImage *in, VipsImage **out) {
  147. if (!vips_image_hasalpha(in))
  148. return vips_copy(in, out, NULL);
  149. return vips_premultiply(in, out, NULL);
  150. }
  151. int
  152. vips_unpremultiply_go(VipsImage *in, VipsImage **out) {
  153. if (!vips_image_hasalpha(in))
  154. return vips_copy(in, out, NULL);
  155. return vips_unpremultiply(in, out, NULL);
  156. }
  157. int
  158. vips_copy_go(VipsImage *in, VipsImage **out) {
  159. return vips_copy(in, out, NULL);
  160. }
  161. int
  162. vips_cast_go(VipsImage *in, VipsImage **out, VipsBandFormat format) {
  163. return vips_cast(in, out, format, NULL);
  164. }
  165. int
  166. vips_rad2float_go(VipsImage *in, VipsImage **out) {
  167. return vips_rad2float(in, out, NULL);
  168. }
  169. int
  170. vips_resize_go(VipsImage *in, VipsImage **out, double wscale, double hscale) {
  171. if (!vips_image_hasalpha(in))
  172. return vips_resize(in, out, wscale, "vscale", hscale, NULL);
  173. VipsBandFormat format = vips_band_format(in);
  174. VipsImage *base = vips_image_new();
  175. VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 3);
  176. int res =
  177. vips_premultiply(in, &t[0], NULL) ||
  178. vips_resize(t[0], &t[1], wscale, "vscale", hscale, NULL) ||
  179. vips_unpremultiply(t[1], &t[2], NULL) ||
  180. vips_cast(t[2], out, format, NULL);
  181. clear_image(&base);
  182. return 0;
  183. }
  184. int
  185. vips_pixelate(VipsImage *in, VipsImage **out, int pixels) {
  186. VipsImage *base = vips_image_new();
  187. VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 3);
  188. int w, h, tw, th;
  189. w = in->Xsize;
  190. h = in->Ysize;
  191. tw = (int)((double)(w + pixels - 1) / pixels) * pixels;
  192. th = (int)((double)(h + pixels - 1) / pixels) * pixels;
  193. if (tw > w || th > h) {
  194. if (vips_embed(in, &t[0], 0, 0, tw, th, "extend", VIPS_EXTEND_COPY, NULL)) {
  195. clear_image(&base);
  196. return 1;
  197. }
  198. } else {
  199. if (vips_copy(in, &t[0], NULL)) {
  200. clear_image(&base);
  201. return 1;
  202. }
  203. }
  204. if (
  205. vips_shrink(t[0], &t[1], pixels, pixels, NULL) ||
  206. vips_zoom(t[1], &t[2], pixels, pixels, NULL)
  207. ) {
  208. clear_image(&base);
  209. return 1;
  210. }
  211. if (tw > w || th > h) {
  212. if (vips_extract_area(t[2], out, 0, 0, w, h, NULL)) {
  213. clear_image(&base);
  214. return 1;
  215. }
  216. } else {
  217. if (vips_copy(t[2], out, NULL)) {
  218. clear_image(&base);
  219. return 1;
  220. }
  221. }
  222. clear_image(&base);
  223. return 0;
  224. }
  225. int
  226. vips_icc_is_srgb_iec61966(VipsImage *in) {
  227. const void *data;
  228. size_t data_len;
  229. // 1998-12-01
  230. static char date[] = { 7, 206, 0, 2, 0, 9 };
  231. // 2.1
  232. static char version[] = { 2, 16, 0, 0 };
  233. // The image had no profile and built-in CMYK was imported.
  234. // Vips gives us an invalid data pointer when the built-in profile was imported,
  235. // so we check this mark before receiving an actual profile.
  236. // if (vips_image_get_typeof(in, "icc-cmyk-no-profile"))
  237. // return FALSE;
  238. if (vips_image_get_blob(in, VIPS_META_ICC_NAME, &data, &data_len))
  239. return FALSE;
  240. // Less than header size
  241. if (data_len < 128)
  242. return FALSE;
  243. // Predict it is sRGB IEC61966 2.1 by checking some header fields
  244. return ((memcmp(data + 48, "IEC ", 4) == 0) && // Device manufacturer
  245. (memcmp(data + 52, "sRGB", 4) == 0) && // Device model
  246. (memcmp(data + 80, "HP ", 4) == 0) && // Profile creator
  247. (memcmp(data + 24, date, 6) == 0) && // Date of creation
  248. (memcmp(data + 8, version, 4) == 0)); // Version
  249. }
  250. int
  251. vips_has_embedded_icc(VipsImage *in) {
  252. return vips_image_get_typeof(in, VIPS_META_ICC_NAME) != 0;
  253. }
  254. int
  255. vips_icc_import_go(VipsImage *in, VipsImage **out) {
  256. return vips_icc_import(in, out, "embedded", TRUE, "pcs", VIPS_PCS_LAB, NULL);
  257. }
  258. int
  259. vips_icc_export_go(VipsImage *in, VipsImage **out) {
  260. return vips_icc_export(in, out, "pcs", VIPS_PCS_LAB, NULL);
  261. }
  262. int
  263. vips_icc_export_srgb(VipsImage *in, VipsImage **out) {
  264. return vips_icc_export(in, out, "output_profile", "sRGB", "pcs", VIPS_PCS_LAB, NULL);
  265. }
  266. int
  267. vips_icc_transform_go(VipsImage *in, VipsImage **out) {
  268. return vips_icc_transform(in, out, "sRGB", "embedded", TRUE, "pcs", VIPS_PCS_LAB, NULL);
  269. }
  270. int
  271. vips_icc_remove(VipsImage *in, VipsImage **out) {
  272. if (vips_copy(in, out, NULL)) return 1;
  273. vips_image_remove(*out, VIPS_META_ICC_NAME);
  274. return 0;
  275. }
  276. int
  277. vips_colourspace_go(VipsImage *in, VipsImage **out, VipsInterpretation cs) {
  278. return vips_colourspace(in, out, cs, NULL);
  279. }
  280. int
  281. vips_rot_go(VipsImage *in, VipsImage **out, VipsAngle angle) {
  282. return vips_rot(in, out, angle, NULL);
  283. }
  284. int
  285. vips_flip_horizontal_go(VipsImage *in, VipsImage **out) {
  286. return vips_flip(in, out, VIPS_DIRECTION_HORIZONTAL, NULL);
  287. }
  288. int
  289. vips_smartcrop_go(VipsImage *in, VipsImage **out, int width, int height) {
  290. return vips_smartcrop(in, out, width, height, NULL);
  291. }
  292. int
  293. vips_gaussblur_go(VipsImage *in, VipsImage **out, double sigma) {
  294. return vips_gaussblur(in, out, sigma, NULL);
  295. }
  296. int
  297. vips_sharpen_go(VipsImage *in, VipsImage **out, double sigma) {
  298. return vips_sharpen(in, out, "sigma", sigma, NULL);
  299. }
  300. int
  301. vips_flatten_go(VipsImage *in, VipsImage **out, double r, double g, double b) {
  302. if (!vips_image_hasalpha(in))
  303. return vips_copy(in, out, NULL);
  304. VipsArrayDouble *bg = vips_array_double_newv(3, r, g, b);
  305. int res = vips_flatten(in, out, "background", bg, NULL);
  306. vips_area_unref((VipsArea *)bg);
  307. return res;
  308. }
  309. int
  310. vips_extract_area_go(VipsImage *in, VipsImage **out, int left, int top, int width, int height) {
  311. return vips_extract_area(in, out, left, top, width, height, NULL);
  312. }
  313. int
  314. vips_trim(VipsImage *in, VipsImage **out, double threshold,
  315. gboolean smart, double r, double g, double b,
  316. gboolean equal_hor, gboolean equal_ver) {
  317. VipsImage *base = vips_image_new();
  318. VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 2);
  319. VipsImage *tmp = in;
  320. if (vips_image_guess_interpretation(in) != VIPS_INTERPRETATION_sRGB) {
  321. if (vips_colourspace(in, &t[0], VIPS_INTERPRETATION_sRGB, NULL)) {
  322. clear_image(&base);
  323. return 1;
  324. }
  325. tmp = t[0];
  326. }
  327. if (vips_image_hasalpha(tmp)) {
  328. if (vips_flatten_go(tmp, &t[1], 255.0, 0, 255.0)) {
  329. clear_image(&base);
  330. return 1;
  331. }
  332. tmp = t[1];
  333. }
  334. double *bg = NULL;
  335. int bgn;
  336. VipsArrayDouble *bga;
  337. if (smart) {
  338. if (vips_getpoint(tmp, &bg, &bgn, 0, 0, NULL)) {
  339. clear_image(&base);
  340. return 1;
  341. }
  342. bga = vips_array_double_new(bg, bgn);
  343. } else {
  344. bga = vips_array_double_newv(3, r, g, b);
  345. }
  346. int left, right, top, bot, width, height, diff;
  347. int res = vips_find_trim(tmp, &left, &top, &width, &height, "background", bga, "threshold", threshold, NULL);
  348. clear_image(&base);
  349. vips_area_unref((VipsArea *)bga);
  350. g_free(bg);
  351. if (res) {
  352. return 1;
  353. }
  354. if (equal_hor) {
  355. right = in->Xsize - left - width;
  356. diff = right - left;
  357. if (diff > 0) {
  358. width += diff;
  359. } else if (diff < 0) {
  360. left = right;
  361. width -= diff;
  362. }
  363. }
  364. if (equal_ver) {
  365. bot = in->Ysize - top - height;
  366. diff = bot - top;
  367. if (diff > 0) {
  368. height += diff;
  369. } else if (diff < 0) {
  370. top = bot;
  371. height -= diff;
  372. }
  373. }
  374. if (width == 0 || height == 0) {
  375. return vips_copy(in, out, NULL);
  376. }
  377. return vips_extract_area(in, out, left, top, width, height, NULL);
  378. }
  379. int
  380. vips_replicate_go(VipsImage *in, VipsImage **out, int width, int height) {
  381. VipsImage *tmp;
  382. if (vips_replicate(in, &tmp, 1 + width / in->Xsize, 1 + height / in->Ysize, NULL))
  383. return 1;
  384. if (vips_extract_area(tmp, out, 0, 0, width, height, NULL)) {
  385. clear_image(&tmp);
  386. return 1;
  387. }
  388. clear_image(&tmp);
  389. return 0;
  390. }
  391. int
  392. vips_embed_go(VipsImage *in, VipsImage **out, int x, int y, int width, int height) {
  393. VipsImage *tmp;
  394. int ret =
  395. vips_ensure_alpha(in, &tmp) ||
  396. vips_embed(tmp, out, x, y, width, height, "extend", VIPS_EXTEND_BLACK, NULL);
  397. clear_image(&tmp);
  398. return ret;
  399. }
  400. int
  401. vips_ensure_alpha(VipsImage *in, VipsImage **out) {
  402. if (vips_image_hasalpha(in))
  403. return vips_copy(in, out, NULL);
  404. return vips_bandjoin_const1(in, out, 255, NULL);
  405. }
  406. int
  407. vips_apply_watermark(VipsImage *in, VipsImage *watermark, VipsImage **out, double opacity) {
  408. VipsImage *base = vips_image_new();
  409. VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 6);
  410. if (vips_ensure_alpha(watermark, &t[0])) {
  411. clear_image(&base);
  412. return 1;
  413. }
  414. if (opacity < 1) {
  415. if (
  416. vips_extract_band(t[0], &t[1], 0, "n", t[0]->Bands - 1, NULL) ||
  417. vips_extract_band(t[0], &t[2], t[0]->Bands - 1, "n", 1, NULL) ||
  418. vips_linear1(t[2], &t[3], opacity, 0, NULL) ||
  419. vips_bandjoin2(t[1], t[3], &t[4], NULL)
  420. ) {
  421. clear_image(&base);
  422. return 1;
  423. }
  424. } else {
  425. if (vips_copy(t[0], &t[4], NULL)) {
  426. clear_image(&base);
  427. return 1;
  428. }
  429. }
  430. int res =
  431. vips_composite2(in, t[4], &t[5], VIPS_BLEND_MODE_OVER, "compositing_space", in->Type, NULL) ||
  432. vips_cast(t[5], out, vips_image_get_format(in), NULL);
  433. clear_image(&base);
  434. return res;
  435. }
  436. int
  437. vips_arrayjoin_go(VipsImage **in, VipsImage **out, int n) {
  438. return vips_arrayjoin(in, out, n, "across", 1, NULL);
  439. }
  440. int
  441. vips_strip(VipsImage *in, VipsImage **out, int keep_exif_copyright) {
  442. static double default_resolution = 72.0 / 25.4;
  443. if (vips_copy(
  444. in, out,
  445. "xres", default_resolution,
  446. "yres", default_resolution,
  447. NULL
  448. )) return 1;
  449. gchar **fields = vips_image_get_fields(in);
  450. for (int i = 0; fields[i] != NULL; i++) {
  451. gchar *name = fields[i];
  452. if (strcmp(name, VIPS_META_ICC_NAME) == 0) continue;
  453. if (strcmp(name, "palette-bit-depth") == 0) continue;
  454. if (keep_exif_copyright) {
  455. if (strcmp(name, VIPS_META_EXIF_NAME) == 0) continue;
  456. if (strcmp(name, "exif-ifd0-Copyright") == 0) continue;
  457. if (strcmp(name, "exif-ifd0-Artist") == 0) continue;
  458. }
  459. vips_image_remove(*out, name);
  460. }
  461. g_strfreev(fields);
  462. return 0;
  463. }
  464. int
  465. vips_jpegsave_go(VipsImage *in, void **buf, size_t *len, int quality, int interlace) {
  466. return vips_jpegsave_buffer(
  467. in, buf, len,
  468. "Q", quality,
  469. "optimize_coding", TRUE,
  470. "interlace", interlace,
  471. NULL
  472. );
  473. }
  474. int
  475. vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace, int quantize, int colors) {
  476. int bitdepth;
  477. if (quantize) {
  478. bitdepth = 1;
  479. if (colors > 16) bitdepth = 8;
  480. else if (colors > 4) bitdepth = 4;
  481. else if (colors > 2) bitdepth = 2;
  482. } else {
  483. bitdepth = vips_get_palette_bit_depth(in);
  484. if (bitdepth) {
  485. if (bitdepth > 4) bitdepth = 8;
  486. else if (bitdepth > 2) bitdepth = 4;
  487. quantize = 1;
  488. colors = 1 << bitdepth;
  489. }
  490. }
  491. if (!quantize)
  492. return vips_pngsave_buffer(
  493. in, buf, len,
  494. "filter", VIPS_FOREIGN_PNG_FILTER_NONE,
  495. "interlace", interlace,
  496. NULL
  497. );
  498. return vips_pngsave_buffer(
  499. in, buf, len,
  500. "filter", VIPS_FOREIGN_PNG_FILTER_NONE,
  501. "interlace", interlace,
  502. "palette", quantize,
  503. "bitdepth", bitdepth,
  504. NULL
  505. );
  506. }
  507. int
  508. vips_webpsave_go(VipsImage *in, void **buf, size_t *len, int quality) {
  509. return vips_webpsave_buffer(
  510. in, buf, len,
  511. "Q", quality,
  512. NULL
  513. );
  514. }
  515. int
  516. vips_gifsave_go(VipsImage *in, void **buf, size_t *len) {
  517. #if VIPS_SUPPORT_GIFSAVE
  518. return vips_gifsave_buffer(in, buf, len, NULL);
  519. #else
  520. vips_error("vips_gifsave_go", "Saving GIF is not supported (libvips 8.12+ reuired)");
  521. return 1;
  522. #endif
  523. }
  524. int
  525. vips_tiffsave_go(VipsImage *in, void **buf, size_t *len, int quality) {
  526. return vips_tiffsave_buffer(in, buf, len, "Q", quality, NULL);
  527. }
  528. int
  529. vips_avifsave_go(VipsImage *in, void **buf, size_t *len, int quality, int speed) {
  530. return vips_heifsave_buffer(
  531. in, buf, len,
  532. "Q", quality,
  533. "compression", VIPS_FOREIGN_HEIF_COMPRESSION_AV1,
  534. #if VIPS_SUPPORT_AVIF_EFFORT
  535. "effort", 9-speed,
  536. #elif VIPS_SUPPORT_AVIF_SPEED
  537. "speed", speed,
  538. #endif
  539. NULL);
  540. }
  541. void
  542. vips_cleanup() {
  543. vips_error_clear();
  544. vips_thread_shutdown();
  545. }