<commit_before>#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>

#define VIPS_SUPPORT_SMARTCROP \
  (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 5))

enum types {
	JPEG = 0,
  PNG,
	WEBP,
	GIF
};

int
vips_initialize()
{
  return vips_init("imgproxy");
}

void
swap_and_clear(VipsImage **in, VipsImage *out) {
  g_object_unref((gpointer) *in);
  *in = out;
}

int
vips_type_find_load_go(int imgtype) {
  if (imgtype == JPEG) {
    return vips_type_find("VipsOperation", "jpegload");
  }
  if (imgtype == PNG) {
    return vips_type_find("VipsOperation", "pngload");
  }
  if (imgtype == WEBP) {
    return vips_type_find("VipsOperation", "webpload");
  }
	if (imgtype == GIF) {
		return vips_type_find("VipsOperation", "gifload");
	}
	return 0;
}

int
vips_type_find_save_go(int imgtype) {
  if (imgtype == JPEG) {
    return vips_type_find("VipsOperation", "jpegsave_buffer");
  }
  if (imgtype == PNG) {
    return vips_type_find("VipsOperation", "pngsave_buffer");
  }
	if (imgtype == WEBP) {
		return vips_type_find("VipsOperation", "webpsave_buffer");
	}
	return 0;
}

int
vips_jpegload_buffer_go(void *buf, size_t len, VipsImage **out)
{
  return vips_jpegload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
}

int
vips_pngload_buffer_go(void *buf, size_t len, VipsImage **out)
{
  return vips_pngload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
}

int
vips_gifload_buffer_go(void *buf, size_t len, VipsImage **out)
{
  return vips_gifload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
}

int
vips_webpload_buffer_go(void *buf, size_t len, VipsImage **out)
{
  return vips_webpload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
}

int
vips_resize_go(VipsImage *in, VipsImage **out, double scale)
{
  return vips_resize(in, out, scale, NULL);
}

int
vips_support_smartcrop() {
#if VIPS_SUPPORT_SMARTCROP
	return 1;
#else
	return 0;
#endif
}

int
vips_smartcrop_go(VipsImage *in, VipsImage **out, int width, int height) {
#if VIPS_SUPPORT_SMARTCROP<commit_msg>Disable gif loading for libvips < 8.3<commit_after>#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>

#define VIPS_SUPPORT_SMARTCROP \
  (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 5))

#define VIPS_SUPPORT_GIF \
  VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 3)

enum types {
	JPEG = 0,
  PNG,
	WEBP,
	GIF
};

int
vips_initialize()
{
  return vips_init("imgproxy");
}

void
swap_and_clear(VipsImage **in, VipsImage *out) {
  g_object_unref((gpointer) *in);
  *in = out;
}

int
vips_type_find_load_go(int imgtype) {
  if (imgtype == JPEG) {
    return vips_type_find("VipsOperation", "jpegload");
  }
  if (imgtype == PNG) {
    return vips_type_find("VipsOperation", "pngload");
  }
  if (imgtype == WEBP) {
    return vips_type_find("VipsOperation", "webpload");
  }
	if (imgtype == GIF) {
		return vips_type_find("VipsOperation", "gifload");
	}
	return 0;
}

int
vips_type_find_save_go(int imgtype) {
  if (imgtype == JPEG) {
    return vips_type_find("VipsOperation", "jpegsave_buffer");
  }
  if (imgtype == PNG) {
    return vips_type_find("VipsOperation", "pngsave_buffer");
  }
	if (imgtype == WEBP) {
		return vips_type_find("VipsOperation", "webpsave_buffer");
	}
	return 0;
}

int
vips_jpegload_buffer_go(void *buf, size_t len, VipsImage **out)
{
  return vips_jpegload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
}

int
vips_pngload_buffer_go(void *buf, size_t len, VipsImage **out)
{
  return vips_pngload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
}

int
vips_gifload_buffer_go(void *buf, size_t len, VipsImage **out)
{
#if VIPS_SUPPORT_GIF
  return vips_gifload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
#else
  return 0;
#endif
}

int
vips_webpload_buffer_go(void *buf, size_t len, VipsImage **out)
{
  return vips_webpload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
}

int
vips_resize_go(VipsImage *in, VipsImage **out, double scale)
{
  return vips_resize(in, out, scale, NULL);
}

int
vips_support_smartcrop() {
#if VIPS_SUPPORT_SMARTCROP
	return 1;
#else
	return 0;
#endif
}

int
vips_smartcrop_go(VipsImage *in, VipsImage **out, int width, int height) {
#if VIPS_SUPPORT_SMARTCROP
{'fraction_non_alphanumeric': 0.13501038541426263, 'fraction_numerical': 0.0055388876067389795, 'mean_word_length': 5.43026706231454, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3530424', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1805, 'n_words': 368}