|
@@ -30,10 +30,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
|
|
@@ -42,13 +41,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()
|
|
|
{
|
|
@@ -65,7 +57,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;
|
|
|
}
|
|
@@ -154,12 +146,12 @@ vips_tiffload_source_go(VipsImgproxySource *source, VipsImage **out)
|
|
|
int
|
|
|
vips_black_go(VipsImage **out, int width, int height, int bands)
|
|
|
{
|
|
|
- VipsImage *tmp;
|
|
|
+ VipsImage *tmp = NULL;
|
|
|
|
|
|
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;
|
|
|
}
|
|
@@ -184,7 +176,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
|
|
@@ -213,7 +205,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;
|
|
|
}
|
|
|
|
|
@@ -229,7 +221,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;
|
|
|
}
|
|
|
|
|
@@ -242,7 +234,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;
|
|
|
}
|
|
@@ -396,7 +388,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;
|
|
|
}
|
|
@@ -529,7 +521,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;
|
|
|
}
|
|
|
|
|
@@ -538,7 +530,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;
|
|
|
}
|
|
|
|
|
@@ -551,14 +543,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;
|
|
|
}
|
|
@@ -636,7 +628,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;
|
|
|
}
|
|
|
|
|
@@ -646,7 +638,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;
|
|
|
}
|
|
|
|
|
@@ -655,7 +647,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;
|
|
|
}
|
|
|
|
|
@@ -675,7 +667,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;
|
|
|
}
|
|
|
|
|
@@ -685,7 +677,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;
|
|
|
}
|
|
|
|
|
@@ -693,7 +685,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;
|
|
|
}
|
|
|
|
|
@@ -703,7 +695,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;
|
|
|
}
|
|
|
|
|
@@ -714,7 +706,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;
|
|
|
}
|
|
@@ -749,7 +741,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];
|
|
@@ -758,7 +750,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];
|
|
@@ -770,7 +762,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);
|
|
@@ -782,7 +774,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);
|
|
|
|
|
@@ -824,7 +816,7 @@ vips_trim(VipsImage *in, VipsImage **out, double threshold,
|
|
|
int
|
|
|
vips_replicate_go(VipsImage *in, VipsImage **out, int width, int height, int centered)
|
|
|
{
|
|
|
- VipsImage *tmp;
|
|
|
+ VipsImage *tmp = NULL;
|
|
|
|
|
|
int across = ceil((double) width / in->Xsize);
|
|
|
int down = ceil((double) height / in->Ysize);
|
|
@@ -843,11 +835,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;
|
|
|
}
|
|
@@ -867,8 +859,7 @@ vips_embed_go(VipsImage *in, VipsImage **out, int x, int y, int width, int heigh
|
|
|
int ret =
|
|
|
vips_embed(in, out, x, y, width, height, "extend", VIPS_EXTEND_BLACK, NULL);
|
|
|
|
|
|
- if (tmp)
|
|
|
- clear_image(&tmp);
|
|
|
+ VIPS_UNREF(tmp);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -892,7 +883,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;
|
|
|
}
|
|
|
|
|
@@ -907,7 +898,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;
|
|
|
}
|
|
|
|
|
@@ -920,7 +911,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;
|
|
|
}
|