vips.c 16 KB

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