|
@@ -15,10 +15,9 @@ vips_initialize()
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-clear_image(VipsImage **in)
|
|
|
+unref_image(VipsImage *in)
|
|
|
{
|
|
|
- if (G_IS_OBJECT(*in))
|
|
|
- g_clear_object(in);
|
|
|
+ VIPS_UNREF(in);
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -27,13 +26,6 @@ g_free_go(void **buf)
|
|
|
g_free(*buf);
|
|
|
}
|
|
|
|
|
|
-void
|
|
|
-swap_and_clear(VipsImage **in, VipsImage *out)
|
|
|
-{
|
|
|
- clear_image(in);
|
|
|
- *in = out;
|
|
|
-}
|
|
|
-
|
|
|
int
|
|
|
gif_resolution_limit()
|
|
|
{
|
|
@@ -50,7 +42,7 @@ vips_health()
|
|
|
int res = vips_black(&t[0], 4, 4, "bands", 4, NULL) ||
|
|
|
!(t[1] = vips_image_copy_memory(t[0]));
|
|
|
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
@@ -142,7 +134,7 @@ vips_black_go(VipsImage **out, int width, int height, int bands)
|
|
|
int res = vips_black(&tmp, width, height, "bands", bands, NULL) ||
|
|
|
vips_copy(tmp, out, "interpretation", VIPS_INTERPRETATION_sRGB, NULL);
|
|
|
|
|
|
- clear_image(&tmp);
|
|
|
+ VIPS_UNREF(tmp);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
@@ -167,7 +159,7 @@ vips_fix_scRGB_alpha_tiff(VipsImage *in, VipsImage **out)
|
|
|
vips_cast(t[2], &t[3], in->BandFmt, NULL) ||
|
|
|
vips_bandjoin2(t[0], t[3], out, NULL);
|
|
|
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
|
|
|
return res;
|
|
|
#endif
|
|
@@ -196,7 +188,7 @@ vips_fix_BW_float_tiff(VipsImage *in, VipsImage **out)
|
|
|
vips_linear1(t[1], &t[2], 65535.0, 0, NULL) ||
|
|
|
vips_cast_ushort(t[2], &t[3], NULL) ||
|
|
|
vips_copy(t[3], &t[4], "interpretation", VIPS_INTERPRETATION_GREY16, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -212,7 +204,7 @@ vips_fix_BW_float_tiff(VipsImage *in, VipsImage **out)
|
|
|
vips_bandjoin(rgb, &t[5], 3, NULL) ||
|
|
|
vips_colourspace(t[5], &t[6], VIPS_INTERPRETATION_GREY16,
|
|
|
"source_space", VIPS_INTERPRETATION_scRGB, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -225,7 +217,7 @@ vips_fix_BW_float_tiff(VipsImage *in, VipsImage **out)
|
|
|
else
|
|
|
res = vips_icc_remove(t[6], out);
|
|
|
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
@@ -366,7 +358,7 @@ vips_resize_go(VipsImage *in, VipsImage **out, double wscale, double hscale)
|
|
|
vips_unpremultiply(t[2], &t[3], NULL) ||
|
|
|
vips_cast(t[3], out, format, NULL);
|
|
|
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
@@ -499,7 +491,7 @@ vips_icc_import_go(VipsImage *in, VipsImage **out)
|
|
|
|
|
|
if (vips_extract_band(in, &t[0], 0, "n", bands, NULL) ||
|
|
|
vips_extract_band(in, &t[1], bands, "n", 1, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -508,7 +500,7 @@ vips_icc_import_go(VipsImage *in, VipsImage **out)
|
|
|
}
|
|
|
|
|
|
if (vips_icc_import(in, out, "embedded", TRUE, "pcs", vips_icc_get_pcs(in), NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -521,14 +513,14 @@ vips_icc_import_go(VipsImage *in, VipsImage **out)
|
|
|
if (vips_cast(t[1], &t[3], t[2]->BandFmt, NULL) ||
|
|
|
vips_linear1(t[3], &t[4], 1.0 / 255.0, 0, NULL) ||
|
|
|
vips_bandjoin2(t[2], t[4], out, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
vips_image_set_int(*out, "imgproxy-icc-imported", 1);
|
|
|
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -606,7 +598,7 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
if (
|
|
|
vips_premultiply(in, &t[0], NULL) ||
|
|
|
vips_cast(t[0], &t[1], format, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -616,7 +608,7 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
|
|
|
if (blur_sigma > 0.0) {
|
|
|
if (vips_gaussblur(in, &t[2], blur_sigma, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -625,7 +617,7 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
|
|
|
if (sharp_sigma > 0.0) {
|
|
|
if (vips_sharpen(in, &t[3], "sigma", sharp_sigma, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -645,7 +637,7 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
|
|
|
if (tw > w || th > h) {
|
|
|
if (vips_embed(in, &t[4], 0, 0, tw, th, "extend", VIPS_EXTEND_MIRROR, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -655,7 +647,7 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
if (
|
|
|
vips_shrink(in, &t[5], pixelate_pixels, pixelate_pixels, NULL) ||
|
|
|
vips_zoom(t[5], &t[6], pixelate_pixels, pixelate_pixels, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -663,7 +655,7 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
|
|
|
if (tw > w || th > h) {
|
|
|
if (vips_extract_area(in, &t[7], 0, 0, w, h, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -673,7 +665,7 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
|
|
|
if (premultiplied) {
|
|
|
if (vips_unpremultiply(in, &t[8], NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -684,7 +676,7 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
vips_colourspace(in, &t[9], interpretation, NULL) ||
|
|
|
vips_cast(t[9], out, format, NULL);
|
|
|
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
@@ -719,7 +711,7 @@ vips_trim(VipsImage *in, VipsImage **out, double threshold,
|
|
|
|
|
|
if (vips_image_guess_interpretation(in) != VIPS_INTERPRETATION_sRGB) {
|
|
|
if (vips_colourspace(in, &t[0], VIPS_INTERPRETATION_sRGB, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
tmp = t[0];
|
|
@@ -728,7 +720,7 @@ vips_trim(VipsImage *in, VipsImage **out, double threshold,
|
|
|
if (vips_image_hasalpha(tmp)) {
|
|
|
RGB f_bg = { 255.0, 0, 255.0 };
|
|
|
if (vips_flatten_go(tmp, &t[1], f_bg)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
tmp = t[1];
|
|
@@ -740,7 +732,7 @@ vips_trim(VipsImage *in, VipsImage **out, double threshold,
|
|
|
|
|
|
if (smart) {
|
|
|
if (vips_getpoint(tmp, &img_bg, &img_bgn, 0, 0, NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
bga = vips_array_double_new(img_bg, img_bgn);
|
|
@@ -752,7 +744,7 @@ vips_trim(VipsImage *in, VipsImage **out, double threshold,
|
|
|
int left, right, top, bot, width, height, diff;
|
|
|
int res = vips_find_trim(tmp, &left, &top, &width, &height, "background", bga, "threshold", threshold, NULL);
|
|
|
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
vips_area_unref((VipsArea *) bga);
|
|
|
g_free(img_bg);
|
|
|
|
|
@@ -813,11 +805,11 @@ vips_replicate_go(VipsImage *in, VipsImage **out, int width, int height, int cen
|
|
|
const int top = centered ? (tmp->Ysize - height) / 2 : 0;
|
|
|
|
|
|
if (vips_extract_area(tmp, out, left, top, width, height, NULL)) {
|
|
|
- clear_image(&tmp);
|
|
|
+ VIPS_UNREF(tmp);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- clear_image(&tmp);
|
|
|
+ VIPS_UNREF(tmp);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -838,7 +830,7 @@ vips_embed_go(VipsImage *in, VipsImage **out, int x, int y, int width, int heigh
|
|
|
vips_embed(in, out, x, y, width, height, "extend", VIPS_EXTEND_BLACK, NULL);
|
|
|
|
|
|
if (tmp)
|
|
|
- clear_image(&tmp);
|
|
|
+ VIPS_UNREF(tmp);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -862,7 +854,7 @@ vips_apply_watermark(VipsImage *in, VipsImage *watermark, VipsImage **out, int l
|
|
|
vips_extract_band(watermark, &t[2], watermark->Bands - 1, "n", 1, NULL) ||
|
|
|
vips_linear1(t[2], &t[3], opacity, 0, NULL) ||
|
|
|
vips_bandjoin2(t[1], t[3], &t[4], NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -877,7 +869,7 @@ vips_apply_watermark(VipsImage *in, VipsImage *watermark, VipsImage **out, int l
|
|
|
"x", left, "y", top, "compositing_space", in->Type,
|
|
|
NULL) ||
|
|
|
vips_cast(t[5], &t[6], vips_image_get_format(in), NULL)) {
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -890,7 +882,7 @@ vips_apply_watermark(VipsImage *in, VipsImage *watermark, VipsImage **out, int l
|
|
|
res = vips_copy(t[6], out, NULL);
|
|
|
}
|
|
|
|
|
|
- clear_image(&base);
|
|
|
+ VIPS_UNREF(base);
|
|
|
|
|
|
return res;
|
|
|
}
|