diff --git a/libsrc/conversion/Makefile.am b/libsrc/conversion/Makefile.am index d2910aac..ec6fe1cd 100644 --- a/libsrc/conversion/Makefile.am +++ b/libsrc/conversion/Makefile.am @@ -37,7 +37,6 @@ libconversion_la_SOURCES = \ im_system.c \ im_print.c \ im_tbjoin.c \ - im_tile_cache.c \ im_text.c \ im_thresh.c \ im_vips2mask.c \ diff --git a/libsrc/conversion/conver_dispatch.c b/libsrc/conversion/conver_dispatch.c index 8cb0f0a4..2847425c 100644 --- a/libsrc/conversion/conver_dispatch.c +++ b/libsrc/conversion/conver_dispatch.c @@ -1444,355 +1444,6 @@ static im_function zoom_desc = { zoom_args /* Arg list */ }; -static int -jpeg2vips_vec( im_object *argv ) -{ - char *in = argv[0]; - IMAGE *out = argv[1]; - - if( im_jpeg2vips( in, out ) ) - return( -1 ); - - return( 0 ); -} - -static im_arg_desc jpeg2vips_args[] = { - IM_INPUT_STRING( "in" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -static im_function jpeg2vips_desc = { - "im_jpeg2vips", /* Name */ - "convert from jpeg", /* Description */ - 0, /* Flags */ - jpeg2vips_vec, /* Dispatch function */ - IM_NUMBER( jpeg2vips_args ), /* Size of arg list */ - jpeg2vips_args /* Arg list */ -}; - -static int -vips2jpeg_vec( im_object *argv ) -{ - IMAGE *in = argv[0]; - char *out = argv[1]; - - if( im_vips2jpeg( in, out ) ) - return( -1 ); - - return( 0 ); -} - -static im_arg_desc vips2jpeg_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_INPUT_STRING( "out" ) -}; - -static im_function vips2jpeg_desc = { - "im_vips2jpeg", /* Name */ - "convert to jpeg", /* Description */ - 0, /* Flags */ - vips2jpeg_vec, /* Dispatch function */ - IM_NUMBER( vips2jpeg_args ), /* Size of arg list */ - vips2jpeg_args /* Arg list */ -}; - -static int -vips2mimejpeg_vec( im_object *argv ) -{ - IMAGE *in = argv[0]; - int qfac = *((int *) argv[1]); - - if( im_vips2mimejpeg( in, qfac ) ) - return( -1 ); - - return( 0 ); -} - -static im_arg_desc vips2mimejpeg_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_INPUT_INT( "qfac" ) -}; - -static im_function vips2mimejpeg_desc = { - "im_vips2mimejpeg", /* Name */ - "convert to jpeg as mime type on stdout", /* Description */ - 0, /* Flags */ - vips2mimejpeg_vec, /* Dispatch function */ - IM_NUMBER( vips2mimejpeg_args ), /* Size of arg list */ - vips2mimejpeg_args /* Arg list */ -}; - -/* Args for vips2png. - */ -static im_arg_desc vips2png_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_INPUT_STRING( "out" ) -}; - -/* Call im_vips2png via arg vector. - */ -static int -vips2png_vec( im_object *argv ) -{ - return( im_vips2png( argv[0], argv[1] ) ); -} - -/* Description of im_vips2png. - */ -static im_function vips2png_desc = { - "im_vips2png", /* Name */ - "convert VIPS image to PNG file", /* Description */ - 0, - vips2png_vec, /* Dispatch function */ - IM_NUMBER( vips2png_args ), /* Size of arg list */ - vips2png_args /* Arg list */ -}; - -/* Args for png2vips. - */ -static im_arg_desc png2vips_args[] = { - IM_INPUT_STRING( "in" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -/* Call im_png2vips via arg vector. - */ -static int -png2vips_vec( im_object *argv ) -{ - return( im_png2vips( argv[0], argv[1] ) ); -} - -/* Description of im_png2vips. - */ -static im_function png2vips_desc = { - "im_png2vips", /* Name */ - "convert PNG file to VIPS image", /* Description */ - 0, - png2vips_vec, /* Dispatch function */ - IM_NUMBER( png2vips_args ), /* Size of arg list */ - png2vips_args /* Arg list */ -}; - -/* Args for exr2vips. - */ -static im_arg_desc exr2vips_args[] = { - IM_INPUT_STRING( "in" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -/* Call im_exr2vips via arg vector. - */ -static int -exr2vips_vec( im_object *argv ) -{ - return( im_exr2vips( argv[0], argv[1] ) ); -} - -/* Description of im_exr2vips. - */ -static im_function exr2vips_desc = { - "im_exr2vips", /* Name */ - "convert an OpenEXR file to VIPS", /* Description */ - 0, - exr2vips_vec, /* Dispatch function */ - IM_NUMBER( exr2vips_args ), /* Size of arg list */ - exr2vips_args /* Arg list */ -}; - -/* Args for vips2tiff. - */ -static im_arg_desc vips2tiff_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_INPUT_STRING( "out" ) -}; - -/* Call im_vips2tiff via arg vector. - */ -static int -vips2tiff_vec( im_object *argv ) -{ - return( im_vips2tiff( argv[0], argv[1] ) ); -} - -/* Description of im_vips2tiff. - */ -static im_function vips2tiff_desc = { - "im_vips2tiff", /* Name */ - "convert VIPS image to TIFF file", /* Description */ - 0, - vips2tiff_vec, /* Dispatch function */ - IM_NUMBER( vips2tiff_args ), /* Size of arg list */ - vips2tiff_args /* Arg list */ -}; - -/* Args for magick2vips. - */ -static im_arg_desc magick2vips_args[] = { - IM_INPUT_STRING( "in" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -/* Call im_magick2vips via arg vector. - */ -static int -magick2vips_vec( im_object *argv ) -{ - return( im_magick2vips( argv[0], argv[1] ) ); -} - -/* Description of im_magick2vips. - */ -static im_function magick2vips_desc = { - "im_magick2vips", /* Name */ - "load file with libMagick", /* Description */ - 0, - magick2vips_vec, /* Dispatch function */ - IM_NUMBER( magick2vips_args ), /* Size of arg list */ - magick2vips_args /* Arg list */ -}; - -/* Args for tiff2vips. - */ -static im_arg_desc tiff2vips_args[] = { - IM_INPUT_STRING( "in" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -/* Call im_tiff2vips via arg vector. - */ -static int -tiff2vips_vec( im_object *argv ) -{ - return( im_tiff2vips( argv[0], argv[1] ) ); -} - -/* Description of im_tiff2vips. - */ -static im_function tiff2vips_desc = { - "im_tiff2vips", /* Name */ - "convert TIFF file to VIPS image", /* Description */ - 0, - tiff2vips_vec, /* Dispatch function */ - IM_NUMBER( tiff2vips_args ), /* Size of arg list */ - tiff2vips_args /* Arg list */ -}; - -static int -analyze2vips_vec( im_object *argv ) -{ - const char *in = argv[0]; - IMAGE *out = argv[1]; - - return( im_analyze2vips( in, out ) ); -} - -static im_arg_desc analyze2vips_arg_types[] = { - IM_INPUT_STRING( "filename" ), - IM_OUTPUT_IMAGE( "im" ) -}; - -static im_function analyze2vips_desc = { - "im_analyze2vips", /* Name */ - "read a file in analyze format",/* Description */ - 0, /* Flags */ - analyze2vips_vec, /* Dispatch function */ - IM_NUMBER( analyze2vips_arg_types ),/* Size of arg list */ - analyze2vips_arg_types /* Arg list */ -}; - -static int -csv2vips_vec( im_object *argv ) -{ - const char *in = argv[0]; - IMAGE *out = argv[1]; - - return( im_csv2vips( in, out ) ); -} - -static im_arg_desc csv2vips_arg_types[] = { - IM_INPUT_STRING( "filename" ), - IM_OUTPUT_IMAGE( "im" ) -}; - -static im_function csv2vips_desc = { - "im_csv2vips", /* Name */ - "read a file in csv format",/* Description */ - 0, /* Flags */ - csv2vips_vec, /* Dispatch function */ - IM_NUMBER( csv2vips_arg_types ),/* Size of arg list */ - csv2vips_arg_types /* Arg list */ -}; - -static int -vips2csv_vec( im_object *argv ) -{ - IMAGE *in = argv[0]; - const char *filename = argv[1]; - - return( im_vips2csv( in, filename ) ); -} - -static im_arg_desc vips2csv_arg_types[] = { - IM_INPUT_IMAGE( "in" ), - IM_INPUT_STRING( "filename" ) -}; - -static im_function vips2csv_desc = { - "im_vips2csv", /* Name */ - "write an image in csv format", /* Description */ - 0, /* Flags */ - vips2csv_vec, /* Dispatch function */ - IM_NUMBER( vips2csv_arg_types ),/* Size of arg list */ - vips2csv_arg_types /* Arg list */ -}; - -static int -ppm2vips_vec( im_object *argv ) -{ - const char *in = argv[0]; - IMAGE *out = argv[1]; - - return( im_ppm2vips( in, out ) ); -} - -static im_arg_desc ppm2vips_arg_types[] = { - IM_INPUT_STRING( "filename" ), - IM_OUTPUT_IMAGE( "im" ) -}; - -static im_function ppm2vips_desc = { - "im_ppm2vips", /* Name */ - "read a file in pbm/pgm/ppm format", /* Description */ - 0, /* Flags */ - ppm2vips_vec, /* Dispatch function */ - IM_NUMBER( ppm2vips_arg_types ),/* Size of arg list */ - ppm2vips_arg_types /* Arg list */ -}; - -static int -vips2ppm_vec( im_object *argv ) -{ - IMAGE *im = argv[0]; - const char *filename = argv[1]; - - return( im_vips2ppm( im, filename ) ); -} - -static im_arg_desc vips2ppm_arg_types[] = { - IM_INPUT_IMAGE( "im" ), - IM_INPUT_STRING( "filename" ) -}; - -static im_function vips2ppm_desc = { - "im_vips2ppm", /* Name */ - "write a file in pbm/pgm/ppm format", /* Description */ - 0, /* Flags */ - vips2ppm_vec, /* Dispatch function */ - IM_NUMBER( vips2ppm_arg_types ),/* Size of arg list */ - vips2ppm_arg_types /* Arg list */ -}; - /* Call im_msb via arg vector. */ static int @@ -1934,7 +1585,6 @@ static im_function *conv_list[] = { ©_swap_desc, ©_set_desc, ©_set_meta_desc, - &csv2vips_desc, &extract_area_desc, &extract_areabands_desc, &extract_band_desc, @@ -1947,16 +1597,10 @@ static im_function *conv_list[] = { &grid_desc, &insert_desc, &insert_noexpand_desc, - &jpeg2vips_desc, &lrjoin_desc, - &magick2vips_desc, &mask2vips_desc, &msb_desc, &msb_band_desc, - &png2vips_desc, - &exr2vips_desc, - &ppm2vips_desc, - &analyze2vips_desc, &print_desc, &recomb_desc, &replicate_desc, @@ -1973,14 +1617,7 @@ static im_function *conv_list[] = { &tbjoin_desc, &text_desc, &thresh_desc, - &tiff2vips_desc, - &vips2csv_desc, - &vips2jpeg_desc, &vips2mask_desc, - &vips2mimejpeg_desc, - &vips2png_desc, - &vips2ppm_desc, - &vips2tiff_desc, &wrap_desc, &zoom_desc }; diff --git a/libsrc/format/im_mask2vips.c b/libsrc/conversion/im_mask2vips.c similarity index 100% rename from libsrc/format/im_mask2vips.c rename to libsrc/conversion/im_mask2vips.c diff --git a/libsrc/format/im_vips2mask.c b/libsrc/conversion/im_vips2mask.c similarity index 100% rename from libsrc/format/im_vips2mask.c rename to libsrc/conversion/im_vips2mask.c diff --git a/libsrc/format/Makefile.am b/libsrc/format/Makefile.am index 6c03baaf..2e2968a6 100644 --- a/libsrc/format/Makefile.am +++ b/libsrc/format/Makefile.am @@ -1,61 +1,22 @@ -noinst_LTLIBRARIES = libconversion.la +noinst_LTLIBRARIES = libformat.la -libconversion_la_SOURCES = \ - im_bernd.c \ - im_vips2tiff.c \ - im_tiff2vips.c \ - conver_dispatch.c \ +libformat_la_SOURCES = \ dbh.h \ - im_bandjoin.c \ + format_dispatch.c \ im_analyze2vips.c \ - im_black.c \ - im_c2amph.c \ - im_c2rect.c \ - im_c2imag.c \ - im_c2ps.c \ - im_c2real.c \ - im_clip.c \ - im_copy.c \ im_csv2vips.c \ - im_vips2csv.c \ - im_extract.c \ im_exr2vips.c \ - im_falsecolour.c \ - im_fliphor.c \ - im_flipver.c \ - im_gbandjoin.c \ - im_insert.c \ im_jpeg2vips.c \ - im_lrjoin.c \ im_magick2vips.c \ - im_mask2vips.c \ - im_msb.c \ im_png2vips.c \ im_ppm2vips.c \ - im_recomb.c \ - im_replicate.c \ - im_grid.c \ im_raw2vips.c \ - im_ri2c.c \ - im_rightshift_size.c \ - im_rot180.c \ - im_rot270.c \ - im_rot90.c \ - im_scale.c \ - im_scaleps.c \ - im_slice.c \ - im_subsample.c \ - im_system.c \ - im_print.c \ - im_tbjoin.c \ + im_tiff2vips.c \ im_tile_cache.c \ - im_text.c \ - im_thresh.c \ - im_vips2mask.c \ + im_vips2csv.c \ im_vips2jpeg.c \ - im_vips2ppm.c \ im_vips2png.c \ - im_wrap.c \ - im_zoom.c + im_vips2ppm.c \ + im_vips2tiff.c INCLUDES = -I${top_srcdir}/include @VIPS_CFLAGS@ @VIPS_INCLUDES@ diff --git a/libsrc/format/format_dispatch.c b/libsrc/format/format_dispatch.c index 8cb0f0a4..36938d8c 100644 --- a/libsrc/format/format_dispatch.c +++ b/libsrc/format/format_dispatch.c @@ -42,1408 +42,6 @@ #include #endif /*WITH_DMALLOC*/ -static int -print_vec( im_object *argv ) -{ - const char *message = argv[0]; - char **out = (char **) &argv[1]; - - if( im_print( message ) ) - return( -1 ); - *out = im_strdup( NULL, "printed" ); - - return( 0 ); -} - -static im_arg_desc print_arg_types[] = { - IM_INPUT_STRING( "message" ), - IM_OUTPUT_STRING( "result" ) -}; - -static im_function print_desc = { - "im_print", /* Name */ - "print string to stdout", /* Description */ - 0, /* Flags */ - print_vec, /* Dispatch function */ - IM_NUMBER( print_arg_types ), /* Size of arg list */ - print_arg_types /* Arg list */ -}; - -static int -system_vec( im_object *argv ) -{ - IMAGE *in = argv[0]; - char *cmd = argv[1]; - char **out = (char **) &argv[2]; - - if( im_system( in, cmd, out ) ) - return( -1 ); - - return( 0 ); -} - -static im_arg_desc system_arg_types[] = { - IM_INPUT_IMAGE( "im" ), - IM_INPUT_STRING( "command" ), - IM_OUTPUT_STRING( "output" ) -}; - -static im_function system_desc = { - "im_system", /* Name */ - "run command on image", /* Description */ - 0, /* Flags */ - system_vec, /* Dispatch function */ - IM_NUMBER( system_arg_types ), /* Size of arg list */ - system_arg_types /* Arg list */ -}; - -static int -subsample_vec( im_object *argv ) -{ - IMAGE *in = argv[0]; - IMAGE *out = argv[1]; - int xsh = *((int *) argv[2]); - int ysh = *((int *) argv[3]); - - if( im_subsample( in, out, xsh, ysh ) ) - return( -1 ); - - return( 0 ); -} - -static im_arg_desc subsample_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "xshrink" ), - IM_INPUT_INT( "yshrink" ) -}; - -static im_function subsample_desc = { - "im_subsample", /* Name */ - "subsample image by integer factors", /* Description */ - IM_FN_PIO, /* Flags */ - subsample_vec, /* Dispatch function */ - IM_NUMBER( subsample_args ), /* Size of arg list */ - subsample_args /* Arg list */ -}; - -/* Args to im_bernd. - */ -static im_arg_desc bernd_args[] = { - IM_INPUT_STRING( "tiffname" ), - IM_INPUT_INT( "left" ), - IM_INPUT_INT( "top" ), - IM_INPUT_INT( "width" ), - IM_INPUT_INT( "height" ) -}; - -/* Call im_bernd via arg vector. - */ -static int -bernd_vec( im_object *argv ) -{ - char *name = argv[0]; - int left = *((int *) argv[1]); - int top = *((int *) argv[2]); - int width = *((int *) argv[3]); - int height = *((int *) argv[4]); - - return( im_bernd( name, left, top, width, height ) ); -} - -/* Description of im_bernd. - */ -static im_function bernd_desc = { - "im_bernd", /* Name */ - "extract from pyramid as jpeg", /* Description */ - 0, /* Flags */ - bernd_vec, /* Dispatch function */ - IM_NUMBER( bernd_args ), /* Size of arg list */ - bernd_args /* Arg list */ -}; - -/* Args to im_extract. - */ -static im_arg_desc extract_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "left" ), - IM_INPUT_INT( "top" ), - IM_INPUT_INT( "width" ), - IM_INPUT_INT( "height" ), - IM_INPUT_INT( "band" ) -}; - -/* Call im_extract via arg vector. - */ -static int -extract_vec( im_object *argv ) -{ - IMAGE_BOX box; - - box.xstart = *((int *) argv[2]); - box.ystart = *((int *) argv[3]); - box.xsize = *((int *) argv[4]); - box.ysize = *((int *) argv[5]); - box.chsel = *((int *) argv[6]); - - return( im_extract( argv[0], argv[1], &box ) ); -} - -/* Description of im_extract. - */ -static im_function extract_desc = { - "im_extract", /* Name */ - "extract area/band", /* Description */ - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - extract_vec, /* Dispatch function */ - IM_NUMBER( extract_args ), /* Size of arg list */ - extract_args /* Arg list */ -}; - -/* Args to im_extract_area. - */ -static im_arg_desc extract_area_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "left" ), - IM_INPUT_INT( "top" ), - IM_INPUT_INT( "width" ), - IM_INPUT_INT( "height" ) -}; - -/* Call im_extract_area via arg vector. - */ -static int -extract_area_vec( im_object *argv ) -{ - int x = *((int *) argv[2]); - int y = *((int *) argv[3]); - int w = *((int *) argv[4]); - int h = *((int *) argv[5]); - - return( im_extract_area( argv[0], argv[1], x, y, w, h ) ); -} - -/* Description of im_extract_area. - */ -static im_function extract_area_desc = { - "im_extract_area", /* Name */ - "extract area", /* Description */ - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - extract_area_vec, /* Dispatch function */ - IM_NUMBER( extract_area_args ), /* Size of arg list */ - extract_area_args /* Arg list */ -}; - -/* Args to im_extract_bands. - */ -static im_arg_desc extract_bands_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "band" ), - IM_INPUT_INT( "nbands" ), -}; - -/* Call im_extract_bands via arg vector. - */ -static int -extract_bands_vec( im_object *argv ) -{ - int chsel = *((int *) argv[2]); - int nbands = *((int *) argv[3]); - - return( im_extract_bands( argv[0], argv[1], chsel, nbands ) ); -} - -/* Description of im_extract_bands. - */ -static im_function extract_bands_desc = { - "im_extract_bands", /* Name */ - "extract several bands", /* Description */ - IM_FN_PIO, /* Flags */ - extract_bands_vec, /* Dispatch function */ - IM_NUMBER( extract_bands_args ),/* Size of arg list */ - extract_bands_args /* Arg list */ -}; - -/* Args to im_extract_band. - */ -static im_arg_desc extract_band_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "band" ) -}; - -/* Call im_extract_band via arg vector. - */ -static int -extract_band_vec( im_object *argv ) -{ - int chsel = *((int *) argv[2]); - - return( im_extract_band( argv[0], argv[1], chsel ) ); -} - -/* Description of im_extract_band. - */ -static im_function extract_band_desc = { - "im_extract_band", /* Name */ - "extract band", /* Description */ - IM_FN_PIO, /* Flags */ - extract_band_vec, /* Dispatch function */ - IM_NUMBER( extract_band_args ), /* Size of arg list */ - extract_band_args /* Arg list */ -}; - -/* Args to im_extract_areabands. - */ -static im_arg_desc extract_areabands_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "left" ), - IM_INPUT_INT( "top" ), - IM_INPUT_INT( "width" ), - IM_INPUT_INT( "height" ), - IM_INPUT_INT( "band" ), - IM_INPUT_INT( "nbands" ) -}; - -/* Call im_extract_areabands via arg vector. - */ -static int -extract_areabands_vec( im_object *argv ) -{ - int left = *((int *) argv[2]); - int top = *((int *) argv[3]); - int width = *((int *) argv[4]); - int height = *((int *) argv[5]); - int band = *((int *) argv[6]); - int nbands = *((int *) argv[7]); - - return( im_extract_areabands( argv[0], argv[1], - left, top, width, height, band, nbands ) ); -} - -/* Description of im_extract_areabands. - */ -static im_function extract_areabands_desc = { - "im_extract_areabands", /* Name */ - "extract area and bands", /* Description */ - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - extract_areabands_vec, /* Dispatch function */ - IM_NUMBER( extract_areabands_args ),/* Size of arg list */ - extract_areabands_args /* Arg list */ -}; - -/* One image in, one out. - */ -static im_arg_desc one_in_one_out[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -/* Two images in, one out. - */ -static im_arg_desc two_in_one_out[] = { - IM_INPUT_IMAGE( "in1" ), - IM_INPUT_IMAGE( "in2" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -/* Call im_bandjoin via arg vector. - */ -static int -bandjoin_vec( im_object *argv ) -{ - return( im_bandjoin( argv[0], argv[1], argv[2] ) ); -} - -/* Description of im_bandjoin. - */ -static im_function bandjoin_desc = { - "im_bandjoin", /* Name */ - "bandwise join of two images", /* Description */ - IM_FN_PIO, /* Flags */ - bandjoin_vec, /* Dispatch function */ - IM_NUMBER( two_in_one_out ), /* Size of arg list */ - two_in_one_out /* Arg list */ -}; - -static im_arg_desc gbandjoin_args[] = { - IM_INPUT_IMAGEVEC( "in" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -static int -gbandjoin_vec( im_object *argv ) -{ - im_imagevec_object *iv = (im_imagevec_object *) argv[0]; - - return( im_gbandjoin( iv->vec, argv[1], iv->n ) ); -} - -static im_function gbandjoin_desc = { - "im_gbandjoin", /* Name */ - "bandwise join of many images", /* Description */ - IM_FN_PIO, /* Flags */ - gbandjoin_vec, /* Dispatch function */ - IM_NUMBER( gbandjoin_args ), /* Size of arg list */ - gbandjoin_args /* Arg list */ -}; - -/* Args to im_text. - */ -static im_arg_desc text_args[] = { - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_STRING( "text" ), - IM_INPUT_STRING( "font" ), - IM_INPUT_INT( "width" ), - IM_INPUT_INT( "alignment" ), - IM_INPUT_INT( "dpi" ) -}; - -/* Call im_text via arg vector. - */ -static int -text_vec( im_object *argv ) -{ - int width = *((int *) argv[3]); - int alignment = *((int *) argv[4]); - int dpi = *((int *) argv[5]); - - return( im_text( argv[0], argv[1], argv[2], width, alignment, dpi ) ); -} - -/* Description of im_text. - */ -static im_function text_desc = { - "im_text", /* Name */ - "generate text image", /* Description */ - IM_FN_PIO, /* Flags */ - text_vec, /* Dispatch function */ - IM_NUMBER( text_args ), /* Size of arg list */ - text_args /* Arg list */ -}; - -/* Args to im_black. - */ -static im_arg_desc black_args[] = { - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "x_size" ), - IM_INPUT_INT( "y_size" ), - IM_INPUT_INT( "bands" ) -}; - -/* Call im_black via arg vector. - */ -static int -black_vec( im_object *argv ) -{ - int xs = *((int *) argv[1]); - int ys = *((int *) argv[2]); - int bands = *((int *) argv[3]); - - return( im_black( argv[0], xs, ys, bands ) ); -} - -/* Description of im_black. - */ -static im_function black_desc = { - "im_black", /* Name */ - "generate black image", /* Description */ - IM_FN_PIO, /* Flags */ - black_vec, /* Dispatch function */ - IM_NUMBER( black_args ), /* Size of arg list */ - black_args /* Arg list */ -}; - -/* Args to im_clip2fmt. - */ -static im_arg_desc clip2fmt_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "ofmt" ) -}; - -/* Call im_clip2fmt via arg vector. - */ -static int -clip2fmt_vec( im_object *argv ) -{ - int ofmt = *((int *) argv[2]); - - return( im_clip2fmt( argv[0], argv[1], ofmt ) ); -} - -/* Description of im_clip2fmt. - */ -static im_function clip2fmt_desc = { - "im_clip2fmt", /* Name */ - "convert image format to ofmt", /* Description */ - IM_FN_PIO, /* Flags */ - clip2fmt_vec, /* Dispatch function */ - IM_NUMBER( clip2fmt_args ), /* Size of arg list */ - clip2fmt_args /* Arg list */ -}; - -/* Call im_c2rect via arg vector. - */ -static int -c2rect_vec( im_object *argv ) -{ - return( im_c2rect( argv[0], argv[1] ) ); -} - -/* Description of im_c2rect. - */ -static im_function c2rect_desc = { - "im_c2rect", /* Name */ - "convert phase and amplitude to real and imaginary", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - c2rect_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_c2amph via arg vector. - */ -static int -c2amph_vec( im_object *argv ) -{ - return( im_c2amph( argv[0], argv[1] ) ); -} - -/* Description of im_c2amph. - */ -static im_function c2amph_desc = { - "im_c2amph", /* Name */ - "convert real and imaginary to phase and amplitude", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - c2amph_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2dcm via arg vector. - */ -static int -clip2dcm_vec( im_object *argv ) -{ - return( im_clip2dcm( argv[0], argv[1] ) ); -} - -/* Description of im_clip2dcm. - */ -static im_function clip2dcm_desc = { - "im_clip2dcm", /* Name */ - "convert to double complex", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2dcm_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2cm via arg vector. - */ -static int -clip2cm_vec( im_object *argv ) -{ - return( im_clip2cm( argv[0], argv[1] ) ); -} - -/* Description of im_clip2cm. - */ -static im_function clip2cm_desc = { - "im_clip2cm", /* Name */ - "convert to complex", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2cm_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2us via arg vector. - */ -static int -clip2us_vec( im_object *argv ) -{ - return( im_clip2us( argv[0], argv[1] ) ); -} - -/* Description of im_clip2us. - */ -static im_function clip2us_desc = { - "im_clip2us", /* Name */ - "convert to unsigned 16-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2us_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2ui via arg vector. - */ -static int -clip2ui_vec( im_object *argv ) -{ - return( im_clip2ui( argv[0], argv[1] ) ); -} - -/* Description of im_clip2ui. - */ -static im_function clip2ui_desc = { - "im_clip2ui", /* Name */ - "convert to unsigned 32-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2ui_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2s via arg vector. - */ -static int -clip2s_vec( im_object *argv ) -{ - return( im_clip2s( argv[0], argv[1] ) ); -} - -/* Description of im_clip2s. - */ -static im_function clip2s_desc = { - "im_clip2s", /* Name */ - "convert to signed 16-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2s_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2i via arg vector. - */ -static int -clip2i_vec( im_object *argv ) -{ - return( im_clip2i( argv[0], argv[1] ) ); -} - -/* Description of im_clip2i. - */ -static im_function clip2i_desc = { - "im_clip2i", /* Name */ - "convert to signed 32-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2i_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2d via arg vector. - */ -static int -clip2d_vec( im_object *argv ) -{ - return( im_clip2d( argv[0], argv[1] ) ); -} - -/* Description of im_clip2d. - */ -static im_function clip2d_desc = { - "im_clip2d", /* Name */ - "convert to double-precision float", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2d_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2f via arg vector. - */ -static int -clip2f_vec( im_object *argv ) -{ - return( im_clip2f( argv[0], argv[1] ) ); -} - -/* Description of im_clip2f. - */ -static im_function clip2f_desc = { - "im_clip2f", /* Name */ - "convert to single-precision float", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2f_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2c via arg vector. - */ -static int -clip2c_vec( im_object *argv ) -{ - return( im_clip2c( argv[0], argv[1] ) ); -} - -/* Description of im_clip2c. - */ -static im_function clip2c_desc = { - "im_clip2c", /* Name */ - "convert to signed 8-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2c_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip via arg vector. - */ -static int -clip_vec( im_object *argv ) -{ - return( im_clip( argv[0], argv[1] ) ); -} - -/* Description of im_clip. - */ -static im_function clip_desc = { - "im_clip", /* Name */ - "convert to unsigned 8-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_ri2c via arg vector. - */ -static int -ri2c_vec( im_object *argv ) -{ - return( im_ri2c( argv[0], argv[1], argv[2] ) ); -} - -/* Description of im_ri2c. - */ -static im_function ri2c_desc = { - "im_ri2c", /* Name */ - "join two non-complex images to form complex", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - ri2c_vec, /* Dispatch function */ - IM_NUMBER( two_in_one_out ), /* Size of arg list */ - two_in_one_out /* Arg list */ -}; - -/* Call im_c2imag via arg vector. - */ -static int -c2imag_vec( im_object *argv ) -{ - return( im_c2imag( argv[0], argv[1] ) ); -} - -/* Description of im_c2imag. - */ -static im_function c2imag_desc = { - "im_c2imag", /* Name */ - "extract imaginary part of complex image", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - c2imag_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_c2real via arg vector. - */ -static int -c2real_vec( im_object *argv ) -{ - return( im_c2real( argv[0], argv[1] ) ); -} - -/* Description of im_c2real. - */ -static im_function c2real_desc = { - "im_c2real", /* Name */ - "extract real part of complex image", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - c2real_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_c2ps via arg vector. - */ -static int -c2ps_vec( im_object *argv ) -{ - return( im_c2ps( argv[0], argv[1] ) ); -} - -/* Description of im_c2ps. - */ -static im_function c2ps_desc = { - "im_c2ps", /* Name */ - "find power spectrum of complex image", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - c2ps_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Args to im_copy_set. - */ -static im_arg_desc copy_set_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "Type" ), - IM_INPUT_DOUBLE( "Xres" ), - IM_INPUT_DOUBLE( "Yres" ), - IM_INPUT_INT( "Xoffset" ), - IM_INPUT_INT( "Yoffset" ) -}; - -/* Call im_copy_set via arg vector. - */ -static int -copy_set_vec( im_object *argv ) -{ - int Type = *((int *) argv[2]); - float Xres = *((double *) argv[3]); - float Yres = *((double *) argv[4]); - int Xoffset = *((int *) argv[5]); - int Yoffset = *((int *) argv[6]); - - return( im_copy_set( argv[0], argv[1], - Type, Xres, Yres, Xoffset, Yoffset ) ); -} - -/* Description of im_copy_set. - */ -static im_function copy_set_desc = { - "im_copy_set", /* Name */ - "copy image, setting informational fields", - - /* Can't set PTOP ... we don't want to zap the LUT, we want the real - * image. - */ - IM_FN_PIO, /* Flags */ - - copy_set_vec, /* Dispatch function */ - IM_NUMBER( copy_set_args ), /* Size of arg list */ - copy_set_args /* Arg list */ -}; - -/* Args to im_copy_set_meta. - */ -static im_arg_desc copy_set_meta_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_STRING( "field" ), - IM_INPUT_GVALUE( "value" ) -}; - -/* Call im_copy_set_meta via arg vector. - */ -static int -copy_set_meta_vec( im_object *argv ) -{ - const char *field = argv[2]; - GValue *value = argv[3]; - - return( im_copy_set_meta( argv[0], argv[1], field, value ) ); -} - -/* Description of im_copy_set_meta. - */ -static im_function copy_set_meta_desc = { - "im_copy_set_meta", /* Name */ - "copy image, setting a meta field", - - /* Can't set PTOP ... we don't want to zap the LUT, we want the real - * image. - */ - IM_FN_PIO, /* Flags */ - - copy_set_meta_vec, /* Dispatch function */ - IM_NUMBER( copy_set_meta_args ),/* Size of arg list */ - copy_set_meta_args /* Arg list */ -}; - -/* Args to im_copy_morph. - */ -static im_arg_desc copy_morph_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "Bands" ), - IM_INPUT_INT( "BandFmt" ), - IM_INPUT_INT( "Coding" ) -}; - -/* Call im_copy_morph via arg vector. - */ -static int -copy_morph_vec( im_object *argv ) -{ - int Bands = *((int *) argv[2]); - int BandFmt = *((int *) argv[3]); - int Coding = *((int *) argv[4]); - - return( im_copy_morph( argv[0], argv[1], - Bands, BandFmt, Coding ) ); -} - -/* Description of im_copy_morph. - */ -static im_function copy_morph_desc = { - "im_copy_morph", /* Name */ - "copy image, setting pixel layout", - - /* Can't set PTOP ... we don't want to zap the LUT, we want the real - * image. - */ - IM_FN_PIO, /* Flags */ - - copy_morph_vec, /* Dispatch function */ - IM_NUMBER( copy_morph_args ), /* Size of arg list */ - copy_morph_args /* Arg list */ -}; - -/* Call im_copy via arg vector. - */ -static int -copy_vec( im_object *argv ) -{ - return( im_copy( argv[0], argv[1] ) ); -} - -/* Description of im_copy. - */ -static im_function copy_desc = { - "im_copy", /* Name */ - "copy image", - - /* Can't set PTOP ... we don't want to zap the LUT, we want the real - * image. - */ - IM_FN_PIO, /* Flags */ - - copy_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_copy_swap via arg vector. - */ -static int -copy_swap_vec( im_object *argv ) -{ - return( im_copy_swap( argv[0], argv[1] ) ); -} - -/* Description of im_copy_swap. - */ -static im_function copy_swap_desc = { - "im_copy_swap", /* Name */ - "copy image, swapping byte order", - - /* Can't set PTOP ... we don't want to zap the LUT, we want the real - * image. - */ - IM_FN_PIO, /* Flags */ - - copy_swap_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_fliphor via arg vector. - */ -static int -fliphor_vec( im_object *argv ) -{ - return( im_fliphor( argv[0], argv[1] ) ); -} - -/* Description of im_fliphor. - */ -static im_function fliphor_desc = { - "im_fliphor", /* Name */ - "flip image left-right", - IM_FN_PIO, /* Flags */ - fliphor_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_flipver via arg vector. - */ -static int -flipver_vec( im_object *argv ) -{ - return( im_flipver( argv[0], argv[1] ) ); -} - -/* Description of im_flipver. - */ -static im_function flipver_desc = { - "im_flipver", /* Name */ - "flip image top-bottom", - IM_FN_PIO, /* Flags */ - flipver_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_falsecolour via arg vector. - */ -static int -falsecolour_vec( im_object *argv ) -{ - return( im_falsecolour( argv[0], argv[1] ) ); -} - -/* Description of im_falsecolour. - */ -static im_function falsecolour_desc = { - "im_falsecolour", /* Name */ - "turn luminance changes into chrominance changes", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - falsecolour_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Args for im_recomb. - */ -static im_arg_desc recomb_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_DMASK( "matrix" ) -}; - -/* Call im_recomb via arg vector. - */ -static int -recomb_vec( im_object *argv ) -{ - im_mask_object *mo = argv[2]; - - return( im_recomb( argv[0], argv[1], mo->mask ) ); -} - -/* Description of im_recomb. - */ -static im_function recomb_desc = { - "im_recomb", /* Name */ - "linear recombination with mask", - IM_FN_PIO, /* Flags */ - recomb_vec, /* Dispatch function */ - IM_NUMBER( recomb_args ), /* Size of arg list */ - recomb_args /* Arg list */ -}; - -/* Args for im_insert. - */ -static im_arg_desc insert_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_INPUT_IMAGE( "sub" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "x" ), - IM_INPUT_INT( "y" ) -}; - -/* Call im_insert via arg vector. - */ -static int -insert_vec( im_object *argv ) -{ - int x = *((int *) argv[3]); - int y = *((int *) argv[4]); - - return( im_insert( argv[0], argv[1], argv[2], x, y ) ); -} - -/* Description of im_insert. - */ -static im_function insert_desc = { - "im_insert", /* Name */ - "insert sub-image into main image at position", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - insert_vec, /* Dispatch function */ - IM_NUMBER( insert_args ), /* Size of arg list */ - insert_args /* Arg list */ -}; - -/* Call im_insert_noexpand via arg vector. - */ -static int -insert_noexpand_vec( im_object *argv ) -{ - int x = *((int *) argv[3]); - int y = *((int *) argv[4]); - - return( im_insert_noexpand( argv[0], argv[1], argv[2], x, y ) ); -} - -/* Description of im_insert_noexpand. - */ -static im_function insert_noexpand_desc = { - "im_insert_noexpand", /* Name */ - "insert sub-image into main image at position, no expansion", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - insert_noexpand_vec, /* Dispatch function */ - IM_NUMBER( insert_args ), /* Size of arg list */ - insert_args /* Arg list */ -}; - -/* Call im_rot180 via arg vector. - */ -static int -rot180_vec( im_object *argv ) -{ - return( im_rot180( argv[0], argv[1] ) ); -} - -/* Description of im_rot180. - */ -static im_function rot180_desc = { - "im_rot180", /* Name */ - "rotate image 180 degrees", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - rot180_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_rot90 via arg vector. - */ -static int -rot90_vec( im_object *argv ) -{ - return( im_rot90( argv[0], argv[1] ) ); -} - -/* Description of im_rot90. - */ -static im_function rot90_desc = { - "im_rot90", /* Name */ - "rotate image 90 degrees clockwise", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - rot90_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_rot270 via arg vector. - */ -static int -rot270_vec( im_object *argv ) -{ - return( im_rot270( argv[0], argv[1] ) ); -} - -/* Description of im_rot270. - */ -static im_function rot270_desc = { - "im_rot270", /* Name */ - "rotate image 270 degrees clockwise", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - rot270_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_lrjoin via arg vector. - */ -static int -lrjoin_vec( im_object *argv ) -{ - return( im_lrjoin( argv[0], argv[1], argv[2] ) ); -} - -/* Description of im_lrjoin. - */ -static im_function lrjoin_desc = { - "im_lrjoin", /* Name */ - "join two images left-right", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - lrjoin_vec, /* Dispatch function */ - IM_NUMBER( two_in_one_out ), /* Size of arg list */ - two_in_one_out /* Arg list */ -}; - -/* Call im_tbjoin via arg vector. - */ -static int -tbjoin_vec( im_object *argv ) -{ - return( im_tbjoin( argv[0], argv[1], argv[2] ) ); -} - -/* Description of im_tbjoin. - */ -static im_function tbjoin_desc = { - "im_tbjoin", /* Name */ - "join two images top-bottom", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - tbjoin_vec, /* Dispatch function */ - IM_NUMBER( two_in_one_out ), /* Size of arg list */ - two_in_one_out /* Arg list */ -}; - -/* Args to im_mask2vips. - */ -static im_arg_desc mask2vips_args[] = { - IM_INPUT_DMASK( "input" ), - IM_OUTPUT_IMAGE( "output" ), -}; - -/* Call im_mask2vips via arg vector. - */ -static int -mask2vips_vec( im_object *argv ) -{ - im_mask_object *mo = argv[0]; - - return( im_mask2vips( mo->mask, argv[1] ) ); -} - -/* Description of im_mask2vips. - */ -static im_function mask2vips_desc = { - "im_mask2vips", /* Name */ - "convert DOUBLEMASK to VIPS image", - 0, /* Flags */ - mask2vips_vec, /* Dispatch function */ - IM_NUMBER( mask2vips_args ), /* Size of arg list */ - mask2vips_args /* Arg list */ -}; - -/* Args to im_vips2mask. - */ -static im_arg_desc vips2mask_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_DMASK( "output" ), -}; - -/* Call im_vips2mask via arg vector. - */ -static int -vips2mask_vec( im_object *argv ) -{ - im_mask_object *mo = argv[1]; - - if( !(mo->mask = im_vips2mask( argv[0], mo->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_vips2mask. - */ -static im_function vips2mask_desc = { - "im_vips2mask", /* Name */ - "convert VIPS image to DOUBLEMASK", - 0, /* Flags */ - vips2mask_vec, /* Dispatch function */ - IM_NUMBER( vips2mask_args ), /* Size of arg list */ - vips2mask_args /* Arg list */ -}; - -/* Call im_scale via arg vector. - */ -static int -scale_vec( im_object *argv ) -{ - return( im_scale( argv[0], argv[1] ) ); -} - -/* Description of im_scale. - */ -static im_function scale_desc = { - "im_scale", /* Name */ - "scale image linearly to fit range 0-255", - IM_FN_PIO, /* Flags */ - scale_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_scaleps via arg vector. - */ -static int -scaleps_vec( im_object *argv ) -{ - return( im_scaleps( argv[0], argv[1] ) ); -} - -/* Description of im_scaleps. - */ -static im_function scaleps_desc = { - "im_scaleps", /* Name */ - "logarithmic scale of image to fit range 0-255", - 0, /* Flags */ - scaleps_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Args to im_slice. - */ -static im_arg_desc slice_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_DOUBLE( "thresh1" ), - IM_INPUT_DOUBLE( "thresh2" ) -}; - -/* Call im_slice via arg vector. - */ -static int -slice_vec( im_object *argv ) -{ - double t1 = *((double *) argv[2]); - double t2 = *((double *) argv[3]); - - return( im_slice( argv[0], argv[1], t1, t2 ) ); -} - -/* Description of im_slice. - */ -static im_function slice_desc = { - "im_slice", /* Name */ - "slice an image using two thresholds", - 0, /* Flags */ - slice_vec, /* Dispatch function */ - IM_NUMBER( slice_args ), /* Size of arg list */ - slice_args /* Arg list */ -}; - -/* Args to im_thresh. - */ -static im_arg_desc thresh_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_DOUBLE( "threshold" ) -}; - -/* Call im_thresh via arg vector. - */ -static int -thresh_vec( im_object *argv ) -{ - double t1 = *((double *) argv[2]); - - return( im_thresh( argv[0], argv[1], t1 ) ); -} - -/* Description of im_thresh. - */ -static im_function thresh_desc = { - "im_thresh", /* Name */ - "slice an image at a threshold", - 0, /* Flags */ - thresh_vec, /* Dispatch function */ - IM_NUMBER( thresh_args ), /* Size of arg list */ - thresh_args /* Arg list */ -}; - -/* Args to im_grid. - */ -static im_arg_desc grid_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "tile_height" ), - IM_INPUT_INT( "across" ), - IM_INPUT_INT( "down" ) -}; - -/* Call im_grid via arg vector. - */ -static int -grid_vec( im_object *argv ) -{ - int tile_height = *((int *) argv[2]); - int across = *((int *) argv[3]); - int down = *((int *) argv[4]); - - return( im_grid( argv[0], argv[1], tile_height, across, down ) ); -} - -/* Description of im_grid. - */ -static im_function grid_desc = { - "im_grid", /* Name */ - "chop a tall thin image into a grid of images", - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - grid_vec, /* Dispatch function */ - IM_NUMBER( grid_args ), /* Size of arg list */ - grid_args /* Arg list */ -}; - -/* Args to im_replicate. - */ -static im_arg_desc replicate_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "across" ), - IM_INPUT_INT( "down" ) -}; - -/* Call im_replicate via arg vector. - */ -static int -replicate_vec( im_object *argv ) -{ - int across = *((int *) argv[2]); - int down = *((int *) argv[3]); - - return( im_replicate( argv[0], argv[1], across, down ) ); -} - -/* Description of im_replicate. - */ -static im_function replicate_desc = { - "im_replicate", /* Name */ - "replicate an image horizontally and vertically", - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - replicate_vec, /* Dispatch function */ - IM_NUMBER( replicate_args ), /* Size of arg list */ - replicate_args /* Arg list */ -}; - -/* Args to im_zoom. - */ -static im_arg_desc zoom_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_INT( "xfac" ), - IM_INPUT_INT( "yfac" ) -}; - -/* Call im_zoom via arg vector. - */ -static int -zoom_vec( im_object *argv ) -{ - int xfac = *((int *) argv[2]); - int yfac = *((int *) argv[3]); - - return( im_zoom( argv[0], argv[1], xfac, yfac ) ); -} - -/* Description of im_zoom. - */ -static im_function zoom_desc = { - "im_zoom", /* Name */ - "simple zoom of an image by integer factors", - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - zoom_vec, /* Dispatch function */ - IM_NUMBER( zoom_args ), /* Size of arg list */ - zoom_args /* Arg list */ -}; - static int jpeg2vips_vec( im_object *argv ) { @@ -1793,202 +391,32 @@ static im_function vips2ppm_desc = { vips2ppm_arg_types /* Arg list */ }; -/* Call im_msb via arg vector. - */ -static int -msb_vec (im_object * argv) -{ - return im_msb (argv[0], argv[1]); -} - -/* Description of im_msb. - */ -static im_function msb_desc = { - "im_msb", /* Name */ - "convert to uchar by discarding bits", - IM_FN_PIO | IM_FN_PTOP, /* Flags */ - msb_vec, /* Dispatch function */ - IM_NUMBER (one_in_one_out), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Args to im_msb_band. - */ -static im_arg_desc msb_band_args[] = { - IM_INPUT_IMAGE ("in"), - IM_OUTPUT_IMAGE ("out"), - IM_INPUT_INT ("band") -}; - -/* Call im_msb_band via arg vector. - */ -static int -msb_band_vec (im_object * argv) -{ - IMAGE *in = (IMAGE *) argv[0]; - IMAGE *out = (IMAGE *) argv[1]; - int *band = (int *) argv[2]; - - return im_msb_band (in, out, *band); -} - -/* Description of im_msb_band. - */ -static im_function msb_band_desc = { - "im_msb_band", /* Name */ - "convert to single band uchar by discarding bits", - IM_FN_PIO | IM_FN_PTOP, /* Flags */ - msb_band_vec, /* Dispatch function */ - IM_NUMBER (msb_band_args), /* Size of arg list */ - msb_band_args /* Arg list */ -}; - -/* Args to im_rightshift_size. - */ -static im_arg_desc rightshift_size_args[] = { - IM_INPUT_IMAGE ("in"), - IM_OUTPUT_IMAGE ("out"), - IM_INPUT_INT ("xshift"), - IM_INPUT_INT ("yshift"), - IM_INPUT_INT ("band_fmt") -}; - -/* Call im_rightshift_size via arg vector. - */ -static int -rightshift_size_vec (im_object * argv) -{ - IMAGE *in = (IMAGE *) argv[0]; - IMAGE *out = (IMAGE *) argv[1]; - int *xshift = (int *) argv[2]; - int *yshift = (int *) argv[3]; - int *band_fmt = (int *) argv[4]; - - return im_rightshift_size (in, out, *xshift, *yshift, *band_fmt ); -} - -/* Description of im_rightshift_size. - */ -static im_function rightshift_size_desc = { - "im_rightshift_size", /* Name */ - "decrease size by a power-of-two factor", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - rightshift_size_vec, /* Dispatch function */ - IM_NUMBER (rightshift_size_args), /* Size of arg list */ - rightshift_size_args /* Arg list */ -}; - -/* Args to im_wrap. - */ -static im_arg_desc wrap_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "x" ), - IM_INPUT_INT( "y" ) -}; - -/* Call im_wrap via arg vector. - */ -static int -wrap_vec (im_object * argv) -{ - return im_wrap( (IMAGE*)argv[0], (IMAGE*)argv[1], *(int*)argv[2], *(int*)argv[3] ); -} - -/* Description of im_wrap. - */ -static im_function wrap_desc = { - "im_wrap", /* Name */ - "shift image origin, wrapping at sides", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - wrap_vec, /* Dispatch function */ - IM_NUMBER (wrap_args), /* Size of arg list */ - wrap_args /* Arg list */ -}; - - /* Package up all these functions. */ -static im_function *conv_list[] = { - &bandjoin_desc, - &bernd_desc, - &black_desc, - &c2amph_desc, - &c2imag_desc, - &c2ps_desc, - &c2real_desc, - &c2rect_desc, - &clip2c_desc, - &clip2cm_desc, - &clip2d_desc, - &clip2dcm_desc, - &clip2f_desc, - &clip2fmt_desc, - &clip2i_desc, - &clip2s_desc, - &clip2ui_desc, - &clip2us_desc, - &clip_desc, - ©_desc, - ©_morph_desc, - ©_swap_desc, - ©_set_desc, - ©_set_meta_desc, +static im_function *list[] = { &csv2vips_desc, - &extract_area_desc, - &extract_areabands_desc, - &extract_band_desc, - &extract_bands_desc, - &extract_desc, - &falsecolour_desc, - &fliphor_desc, - &flipver_desc, - &gbandjoin_desc, - &grid_desc, - &insert_desc, - &insert_noexpand_desc, &jpeg2vips_desc, - &lrjoin_desc, &magick2vips_desc, - &mask2vips_desc, - &msb_desc, - &msb_band_desc, &png2vips_desc, &exr2vips_desc, &ppm2vips_desc, &analyze2vips_desc, - &print_desc, - &recomb_desc, - &replicate_desc, - &ri2c_desc, - &rot180_desc, - &rot270_desc, - &rot90_desc, - &scale_desc, - &scaleps_desc, - &rightshift_size_desc, - &slice_desc, - &subsample_desc, - &system_desc, - &tbjoin_desc, - &text_desc, - &thresh_desc, &tiff2vips_desc, &vips2csv_desc, &vips2jpeg_desc, - &vips2mask_desc, &vips2mimejpeg_desc, &vips2png_desc, &vips2ppm_desc, - &vips2tiff_desc, - &wrap_desc, - &zoom_desc + &vips2tiff_desc }; /* Package of functions. */ -im_package im__conversion = { - "conversion", - IM_NUMBER( conv_list ), - conv_list +im_package im__format = { + "format", + IM_NUMBER( list ), + list }; + + + diff --git a/libsrc/format/predicate.c b/libsrc/format/predicate.c new file mode 100644 index 00000000..ee7b53ba --- /dev/null +++ b/libsrc/format/predicate.c @@ -0,0 +1,530 @@ +/* Test various predicates. + * + * J.Cupitt, 8/4/93. + * 13/10/95 JC + * - ANSIfied + * - im_ispoweroftwo() added + * 14/11/96 Jc + * - im_isjpeg() added + * 25/3/97 JC + * - im_isvips() added + * 14/4/97 JC + * - im_istifftiled() added + * 29/10/98 JC + * - im_isMSBfirst() and im_amiMSBfirst() added + * 16/6/99 JC + * - added im_existsf() + * 22/11/00 JC + * - added im_isppm() + * 23/4/01 JC + * - HAVE_TIFF turns on TIFFness + * 19/10/02 HB + * - PNG added + * 1/5/06 + * - added exr + * 3/8/07 + * - cleanups + * 22/5/08 + * - now just formats + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif /*HAVE_UNISTD_H*/ +#ifdef HAVE_IO_H +#include +#endif /*HAVE_IO_H*/ +#include +#include + +#include + +#ifdef HAVE_TIFF +#include +#endif /*HAVE_TIFF*/ + +#ifdef HAVE_PNG +#include +#endif /*HAVE_PNG*/ + +#ifdef WITH_DMALLOC +#include +#endif /*WITH_DMALLOC*/ + +/* Test BandFmt. + */ +int +im_isint( IMAGE *im ) +{ + switch( im->BandFmt ) { + case IM_BANDFMT_UCHAR: + case IM_BANDFMT_CHAR: + case IM_BANDFMT_USHORT: + case IM_BANDFMT_SHORT: + case IM_BANDFMT_UINT: + case IM_BANDFMT_INT: + return( 1 ); + + case IM_BANDFMT_FLOAT: + case IM_BANDFMT_DOUBLE: + case IM_BANDFMT_COMPLEX: + case IM_BANDFMT_DPCOMPLEX: + return( 0 ); + + default: + error_exit( "im_isint: unknown image BandFmt" ); + /*NOTREACHED*/ + return( -1 ); + } +} + +/* Test endianness of an image. SPARC is MSB first + */ +int +im_isMSBfirst( IMAGE *im ) +{ + if( im->magic == IM_MAGIC_SPARC ) + return( 1 ); + else + return( 0 ); +} + +/* Test this processor for endianness. True for SPARC order. + */ +int +im_amiMSBfirst( void ) +{ + int test; + unsigned char *p = (unsigned char *) &test; + + test = 0; + p[0] = 255; + + if( test == 255 ) + return( 0 ); + else + return( 1 ); +} + +int +im_isuint( IMAGE *im ) +{ + switch( im->BandFmt ) { + case IM_BANDFMT_UCHAR: + case IM_BANDFMT_USHORT: + case IM_BANDFMT_UINT: + return( 1 ); + + case IM_BANDFMT_INT: + case IM_BANDFMT_SHORT: + case IM_BANDFMT_CHAR: + case IM_BANDFMT_FLOAT: + case IM_BANDFMT_DOUBLE: + case IM_BANDFMT_COMPLEX: + case IM_BANDFMT_DPCOMPLEX: + return( 0 ); + + default: + error_exit( "im_isuint: unknown image BandFmt" ); + /*NOTREACHED*/ + return( -1 ); + } +} + +int +im_isfloat( IMAGE *im ) +{ + switch( im->BandFmt ) { + case IM_BANDFMT_FLOAT: + case IM_BANDFMT_DOUBLE: + return( 1 ); + + case IM_BANDFMT_UCHAR: + case IM_BANDFMT_CHAR: + case IM_BANDFMT_USHORT: + case IM_BANDFMT_SHORT: + case IM_BANDFMT_UINT: + case IM_BANDFMT_INT: + case IM_BANDFMT_COMPLEX: + case IM_BANDFMT_DPCOMPLEX: + return( 0 ); + + default: + error_exit( "im_isfloat: unknown image BandFmt" ); + /*NOTREACHED*/ + return( -1 ); + } +} + +int +im_isscalar( IMAGE *im ) +{ + switch( im->BandFmt ) { + case IM_BANDFMT_UCHAR: + case IM_BANDFMT_CHAR: + case IM_BANDFMT_USHORT: + case IM_BANDFMT_SHORT: + case IM_BANDFMT_UINT: + case IM_BANDFMT_INT: + case IM_BANDFMT_FLOAT: + case IM_BANDFMT_DOUBLE: + return( 1 ); + + case IM_BANDFMT_COMPLEX: + case IM_BANDFMT_DPCOMPLEX: + return( 0 ); + + default: + error_exit( "im_isscalar: unknown image BandFmt" ); + /*NOTREACHED*/ + return( -1 ); + } +} + +int +im_iscomplex( IMAGE *im ) +{ + switch( im->BandFmt ) { + case IM_BANDFMT_COMPLEX: + case IM_BANDFMT_DPCOMPLEX: + return( 1 ); + + case IM_BANDFMT_UCHAR: + case IM_BANDFMT_CHAR: + case IM_BANDFMT_USHORT: + case IM_BANDFMT_SHORT: + case IM_BANDFMT_UINT: + case IM_BANDFMT_INT: + case IM_BANDFMT_FLOAT: + case IM_BANDFMT_DOUBLE: + return( 0 ); + + default: + error_exit( "im_iscomplex: unknown image BandFmt" ); + /*NOTREACHED*/ + return( -1 ); + } +} + +/* Read a few bytes from the start of a file. For sniffing file types. + */ +static int +get_bytes( const char *filename, unsigned char buf[], int len ) +{ + int fd; + + /* File may not even exist (for tmp images for example!) + * so no hasty messages. And the file might be truncated, so no error + * on read either. + */ +#ifdef BINARY_OPEN + if( (fd = open( filename, O_RDONLY | O_BINARY )) == -1 ) +#else /*BINARY_OPEN*/ + if( (fd = open( filename, O_RDONLY )) == -1 ) +#endif /*BINARY_OPEN*/ + return( 0 ); + if( read( fd, buf, len ) != len ) { + close( fd ); + return( 0 ); + } + close( fd ); + + return( 1 ); +} + +int +im_istiff( const char *filename ) +{ + unsigned char buf[2]; + + if( get_bytes( filename, buf, 2 ) ) + if( (buf[0] == 'M' && buf[1] == 'M') || + (buf[0] == 'I' && buf[1] == 'I') ) + return( 1 ); + + return( 0 ); +} + +#ifdef HAVE_PNG +int +im_ispng( const char *filename ) +{ + unsigned char buf[8]; + + return( get_bytes( filename, buf, 8 ) && + !png_sig_cmp( buf, 0, 8 ) ); +} +#else /*HAVE_PNG*/ +int +im_ispng( const char *filename ) +{ + return( 0 ); +} +#endif /*HAVE_PNG*/ + +#ifdef HAVE_MAGICK +int +im_ismagick( const char *filename ) +{ + IMAGE *im; + int result; + + if( !(im = im_open( "dummy", "p" )) ) + return( -1 ); + result = im_magick2vips_header( filename, im ); + im_clear_error_string(); + im_close( im ); + + return( result == 0 ); +} +#else /*HAVE_MAGICK*/ +int +im_ismagick( const char *filename ) +{ + return( 0 ); +} +#endif /*HAVE_MAGICK*/ + +int +im_isppm( const char *filename ) +{ + unsigned char buf[2]; + + if( get_bytes( filename, buf, 2 ) ) + if( buf[0] == 'P' && (buf[1] >= '1' || buf[1] <= '6') ) + return( 1 ); + + return( 0 ); +} + +#ifdef HAVE_TIFF + +/* Handle TIFF errors here. + */ +static void +vhandle( char *module, char *fmt, ... ) +{ + va_list ap; + + im_errormsg( "TIFF error in \"%s\": ", module ); + + va_start( ap, fmt ); + im_verrormsg( fmt, ap ); + va_end( ap ); +} + +int +im_istifftiled( const char *filename ) +{ + TIFF *tif; + int tiled; + + /* Override the default TIFF error handler. + */ + TIFFSetErrorHandler( (TIFFErrorHandler) vhandle ); + +#ifdef BINARY_OPEN + if( !(tif = TIFFOpen( filename, "rb" )) ) { +#else /*BINARY_OPEN*/ + if( !(tif = TIFFOpen( filename, "r" )) ) { +#endif /*BINARY_OPEN*/ + /* Not a TIFF file ... return False. + */ + im_clear_error_string(); + return( 0 ); + } + tiled = TIFFIsTiled( tif ); + TIFFClose( tif ); + + return( tiled ); +} + +#else /*HAVE_TIFF*/ + +int +im_istifftiled( const char *filename ) +{ + return( 0 ); +} + +#endif /*HAVE_TIFF*/ + +int +im_isjpeg( const char *filename ) +{ + unsigned char buf[2]; + + if( get_bytes( filename, buf, 2 ) ) + if( (int) buf[0] == 0xff && (int) buf[1] == 0xd8 ) + return( 1 ); + + return( 0 ); +} + +int +im_isvips( const char *filename ) +{ + unsigned char buf[4]; + + if( get_bytes( filename, buf, 4 ) ) { + if( buf[0] == 0x08 && buf[1] == 0xf2 && + buf[2] == 0xa6 && buf[3] == 0xb6 ) + /* SPARC-order VIPS image. + */ + return( 1 ); + else if( buf[3] == 0x08 && buf[2] == 0xf2 && + buf[1] == 0xa6 && buf[0] == 0xb6 ) + /* INTEL-order VIPS image. + */ + return( 1 ); + } + + return( 0 ); +} + +int +im_isexr( const char *filename ) +{ + unsigned char buf[4]; + + if( get_bytes( filename, buf, 4 ) ) + if( buf[0] == 0x76 && buf[1] == 0x2f && + buf[2] == 0x31 && buf[3] == 0x01 ) + return( 1 ); + + return( 0 ); +} + +/* Test for file exists. + */ +int +im_existsf( const char *name, ... ) +{ + va_list ap; + char buf1[PATH_MAX]; + + va_start( ap, name ); + (void) im_vsnprintf( buf1, PATH_MAX - 1, name, ap ); + va_end( ap ); + + /* Try that. + */ + if( !access( buf1, R_OK ) ) + return( 1 ); + + return( 0 ); +} + +/* True if this IMAGE is a disc file of some sort. + */ +int +im_isfile( IMAGE *im ) +{ + switch( im->dtype ) { + case IM_MMAPIN: + case IM_MMAPINRW: + case IM_OPENOUT: + case IM_OPENIN: + return( 1 ); + + case IM_PARTIAL: + case IM_SETBUF: + case IM_SETBUF_FOREIGN: + case IM_NONE: + return( 0 ); + + default: + error_exit( "im_isfile: corrupt IMAGE descriptor" ); + /*NOTREACHED*/ + return( -1 ); + } +} + +/* True if this IMAGE is a partial of some sort. + */ +int +im_ispartial( IMAGE *im ) +{ + switch( im->dtype ) { + case IM_PARTIAL: + return( 1 ); + + case IM_SETBUF: + case IM_SETBUF_FOREIGN: + case IM_MMAPIN: + case IM_MMAPINRW: + case IM_OPENIN: + case IM_OPENOUT: + case IM_NONE: + return( 0 ); + + default: + error_exit( "im_ispartial: corrupt IMAGE descriptor" ); + /*NOTREACHED*/ + return( -1 ); + } +} + +/* True if an int is a power of two ... 1, 2, 4, 8, 16, 32, etc. Do with just + * integer arithmetic for portability. A previous Nicos version using doubles + * and log/log failed on x86 with rounding problems. Return 0 for not + * power of two, otherwise return the position of the set bit (numbering with + * bit 1 as the lsb). + */ +int +im_ispoweroftwo( int p ) +{ + int i, n; + + /* Count set bits. Could use a LUT, I guess. + */ + for( i = 0, n = 0; p; i++, p >>= 1 ) + if( (p & 1) == 1 ) + n++; + + /* Should be just one set bit. + */ + if( n == 1 ) + /* Return position of bit. + */ + return( i ); + else + return( 0 ); +} diff --git a/libsrc/iofuncs/package.c b/libsrc/iofuncs/package.c index 9e86645c..1d92dec3 100644 --- a/libsrc/iofuncs/package.c +++ b/libsrc/iofuncs/package.c @@ -61,6 +61,7 @@ extern im_package im__boolean; extern im_package im__colour; extern im_package im__conversion; extern im_package im__convolution; +extern im_package im__format; extern im_package im__freq_filt; extern im_package im__histograms_lut; extern im_package im__inplace; @@ -405,6 +406,7 @@ static im_package *built_in[] = { &im__colour, &im__conversion, &im__convolution, + &im__format, &im__freq_filt, &im__histograms_lut, &im__inplace,