remove cimg and gmic

move this to a plugin, it's too big for the core library
This commit is contained in:
John Cupitt 2014-10-08 17:51:07 +01:00
parent ca2ae681cd
commit 927b2d7954
14 changed files with 10 additions and 262948 deletions

View File

@ -15,7 +15,7 @@
- better extra band handling by colour, again
- move zoomify ImageProperties file, now a better match to the offical tool
- rename VIPS_ANGLE_180 as VIPS_ANGLE_D180 etc. to help python
- update cimg, add gmic, plus a configure option to turn it on
- remove cimg support, we have a gmic plugin now instead
8/9/14 started 7.40.10
- icc_import and icc_transform checks the input profile for compatibility

View File

@ -665,19 +665,6 @@ if test x"$with_pangoft2" != "xno"; then
])
fi
# g'mic ... embedding the gmic interpreter needs a C++ compiler and a lot of
# patience. And tolerance for huge object files.
AC_ARG_WITH([gmic],
AS_HELP_STRING([--with-gmic], [build with gmic (default: no)]))
if test x"$with_gmic" == "xyes"; then
AC_DEFINE(HAVE_GMIC,1,[define to enable the gmic interpreter.])
AM_CONDITIONAL(ENABLE_GMIC, true)
else
AM_CONDITIONAL(ENABLE_GMIC, false)
with_gmic=no
fi
# hmm, these don't have .pc files on ubuntu 5.10, how odd
FIND_ZIP(
[with_zip=yes],
@ -815,7 +802,6 @@ AC_OUTPUT([
libvips/include/vips/Makefile
libvips/Makefile
libvips/arithmetic/Makefile
libvips/cimg/Makefile
libvips/colour/Makefile
libvips/conversion/Makefile
libvips/convolution/Makefile
@ -882,5 +868,4 @@ file import/export with libjpeg: $with_jpeg
image pyramid export: $with_gsf
(requires libgsf-1 1.14.27 or later)
use libexif to load/save JPEG metadata: $with_libexif
build Python binding: $with_python
embed gmic interpreter: $with_gmic])
build Python binding: $with_python])

View File

@ -2,15 +2,6 @@ OPTIONAL_COMPILE_DIR =
OPTIONAL_DIST_DIR =
OPTIONAL_LIB =
# only build in the cimg dir if C++ is enabled
if ENABLE_CXX
OPTIONAL_COMPILE_DIR += cimg
OPTIONAL_LIB += cimg/libcimg.la
else
OPTIONAL_DIST_DIR += cimg
endif
# same for deprecated
if ENABLE_DEPRECATED
OPTIONAL_COMPILE_DIR += deprecated
OPTIONAL_LIB += deprecated/libdeprecated.la
@ -47,7 +38,7 @@ libvips_la_SOURCES =
# sadly the if/endif isn't enough to stop automake detecting a c++ link even
# when c++ is disabled ... comment out this line if you have linking problems
if ENABLE_CXX
nodist_EXTRA_libvips_la_SOURCES = cimg/dummy2.cc
nodist_EXTRA_libvips_la_SOURCES = resample/dummy2.cc
endif
# DLLs need dependant libs there too ... put @VIPS_LIBS@ at the end

File diff suppressed because it is too large Load Diff

View File

@ -1,47 +0,0 @@
noinst_LTLIBRARIES = libcimg.la
OPTIONAL_SRC =
OPTIONAL_DIST =
if ENABLE_GMIC
OPTIONAL_SRC += vips_gmic.cpp gmic.cpp
else
OPTIONAL_DIST += vips_gmic.cpp gmic.cpp
endif
libcimg_la_SOURCES = \
CImg.h \
gmic_def.h \
gmic.h \
cimg.c \
$(OPTIONAL_SRC)
# various cimg settings as well
# display=0 means don't build the cimg display stuff
# don't turn on the parallel stuff, we rely on vips for that
# don't use cimg_use_rng, we want the system generator
# don't turn on jpg/png/tiff/exr read write, we use vips for that
# don't use -Dcimg_use_fftw3, CImg wants fftw_init_threads() etc. which
# are not widely available
if OS_WIN32
AM_CPPFLAGS = \
-Dcimg_OS=2 \
-Dgmic_build \
-Dcimg_strict_warnings \
-Dcimg_display=0 \
-DLOCALEDIR=\""$(LOCALEDIR)"\"
else
AM_CPPFLAGS = \
-Dcimg_OS=1 \
-Dgmic_build \
-Dcimg_strict_warnings \
-Dcimg_display=0 \
-DLOCALEDIR=\""$(LOCALEDIR)"\"
endif
# used by the final libvips link rather than us
EXTRA_DIST = \
dummy2.cc \
$(OPTIONAL_DIST)
AM_CPPFLAGS += -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@

View File

@ -1,95 +0,0 @@
/* pass images through gmic
*/
/*
Copyright (C) 1991-2005 The National Gallery
This library 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.1 of the License, or (at your option) any later version.
This library 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 library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
/*
#define DEBUG
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <vips/vips.h>
/**
* SECTION: cimg
* @short_description: pass images through the gmic interpreter
* @see_also: <link linkend="libvips-boolean">boolean</link>
* @stability: Stable
* @include: vips/vips.h
*
* Pass images through the gmic interpreter.
*/
/**
* vips_gmic:
* @in: (array length=n) (transfer none): array of input images
* @out: output image
* @n: number of input images
* @padding: overlap tiles by this much
* @x_scale:
* @y_scale:
* @command: command to execute
*
* Returns: 0 on success, -1 on failure.
*/
int
vips_gmic( VipsImage **in, VipsImage **out, int n,
int padding, double x_scale, double y_scale, const char *command, ... )
{
VipsArrayImage *array;
va_list ap;
int result;
array = vips_array_image_new( in, n );
va_start( ap, command );
result = vips_call_split( "gmic", ap, array, out,
padding, x_scale, y_scale, command );
va_end( ap );
vips_area_unref( VIPS_AREA( array ) );
return( result );
}
/* Called from iofuncs to init all operations in this dir. Use a plugin system
* instead?
*/
void
vips_cimg_operation_init( void )
{
#ifdef HAVE_GMIC
extern GType vips_gmic_get_type( void );
#endif /*HAVE_GMIC*/
#ifdef HAVE_GMIC
vips_gmic_get_type();
#endif /*HAVE_GMIC*/
}

File diff suppressed because it is too large Load Diff

View File

@ -1,327 +0,0 @@
/*
#
# File : gmic.h
# ( C++ header file )
#
# Description : GREYC's Magic for Image Computing
# ( http://gmic.sourceforge.net )
# This file is also a part of the CImg Library project.
# ( http://cimg.sourceforge.net )
#
# Note : Include this file in your C++ source code, if you
# want to use the G'MIC interpreter in your own program.
#
# Copyright : David Tschumperle
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include <locale>
#ifndef gmic_version
#define gmic_version 1600
// Define environment variables.
#ifndef gmic_is_beta
#define gmic_is_beta 0
#endif // #ifndef gmic_is_beta
#ifndef cimg_verbosity
#define cimg_verbosity 1
#endif // #ifndef cimg_verbosity
#ifdef gmic_build
#define cimg_plugin "gmic.cpp"
#include "./CImg.h"
#if cimg_OS==2
#include <process.h>
#ifdef _MSC_VER
#pragma comment(linker,"/STACK:16777216")
#endif // #ifdef _MSC_VER
#elif cimg_OS==1
#include <cerrno>
#include <sys/resource.h>
static struct gmic_increase_stack {
gmic_increase_stack() {
const rlim_t requested_stack_size = 16777216;
struct rlimit rl;
const int result = getrlimit(RLIMIT_STACK,&rl);
if (!result && rl.rlim_cur<requested_stack_size) {
rl.rlim_cur = requested_stack_size;
setrlimit(RLIMIT_STACK,&rl);
}
}
} _gmic_increase_stack;
#endif // #if cimg_OS==2
#else // #ifdef gmic_build
#include <cstdio>
#include <cstring>
#ifndef cimg_version
namespace cimg_library {
// Define the G'MIC image structure.
//----------------------------------
template<typename T> struct CImg {
unsigned int _width; // Number of image columns (dimension along the X-axis).
unsigned int _height; // Number of image lines (dimension along the Y-axis)
unsigned int _depth; // Number of image slices (dimension along the Z-axis).
unsigned int _spectrum; // Number of image channels (dimension along the C-axis).
bool _is_shared; // Tells if the data buffer is shared by another structure.
T *_data; // Pointer to the first pixel value.
// Destructor.
~CImg();
// Empty constructor.
CImg():_width(0),_height(0),_depth(0),_spectrum(0),_is_shared(false),_data(0) {}
// Use to allocate a new image with specified dimension.
CImg<T>& assign(const unsigned int w, const unsigned int h=1,
const unsigned int d=1, const unsigned int s=1);
};
// Define the G'MIC image list structure.
//---------------------------------------
template<typename T> struct CImgList {
unsigned int _width; // Number of images in the list.
unsigned int _allocated_width; // Allocated items in the list (must be 2^N and >size).
CImg<T> *_data; // Pointer to the first image of the list.
// Destructor.
~CImgList();
// Empty constructor.
CImgList():_width(0),_allocated_width(0),_data(0) {}
// Use to allocate a new image list with specified dimension.
CImgList<T>& assign(const unsigned int n);
};
}
#endif // #ifndef cimg_version
#endif // #ifdef gmic_build
#define gmic_image cimg_library::CImg
#define gmic_list cimg_library::CImgList
#define gmic_display cimg_library::CImgDisplay
// Define some special character codes used for replacement in double quoted strings.
const char _dollar = 23, _lbrace = 24, _rbrace = 25, _comma = 26, _dquote = 28, _arobace = 29,
_newline = 30;
// Define the G'MIC exception class.
//----------------------------------
struct gmic_exception {
gmic_image<char> _command_help, _message;
gmic_exception() {}
gmic_exception(const char *const command, const char *const message) {
if (command) {
_command_help.assign(std::strlen(command)+1,1,1,1);
std::strcpy(_command_help._data,command);
}
if (message) {
_message.assign(std::strlen(message)+1,1,1,1);
std::strcpy(_message._data,message);
}
}
const char *what() const { // Give the error message returned by the G'MIC interpreter.
return _message._data?_message._data:"";
}
const char *command_help() const {
return _command_help._data?_command_help._data:"";
}
};
// Define the G'MIC interpreter class.
//------------------------------------
struct gmic {
// Constructors - Destructors.
// Use the methods below to create and run the G'MIC interpreter from your C++ source.
gmic();
gmic(const char *const commands_line,
const char *const custom_commands=0,
const bool include_default_commands=true,
float *const p_progress=0, int *const p_cancel=0);
template<typename T>
gmic(const char *const commands_line,
gmic_list<T>& images, gmic_list<char>& images_names,
const char *const custom_commands=0,
const bool include_default_commands=true,
float *const p_progress=0, int *const p_cancel=0);
~gmic();
// Methods to call interpreter on an already constructed gmic instance.
gmic& run(const char *const commands_line,
float *const p_progress=0, int *const p_cancel=0) {
gmic_list<float> images;
gmic_list<char> images_names;
return run(commands_line,images,images_names,
p_progress,p_cancel);
}
template<typename T>
gmic& run(const char *const commands_line,
gmic_list<T> &images, gmic_list<char> &images_names,
float *const p_progress=0, int *const p_cancel=0) {
starting_commands_line = commands_line;
is_debug = false;
return _run(commands_line_to_CImgList(commands_line),
images,images_names,p_progress,p_cancel);
}
//--------------------------------------------------------------------------------------
// All functions below should be considered as 'private' and thus, should not be used
// in your own C++ source code. Use them at your own risk.
//--------------------------------------------------------------------------------------
template<typename T>
void _gmic(const char *const commands_line,
gmic_list<T>& images, gmic_list<char>& images_names,
const char *const custom_commands, const bool include_default_commands,
float *const p_progress, int *const p_cancel);
gmic& add_variable(const char *const variable_name, const char *const variable_content);
gmic& add_commands(const char *const data_commands, const char *const commands_file=0);
gmic& add_commands(std::FILE *const file, const char *const filename=0);
gmic_image<char> scope2string() const;
gmic_image<char> scope2string(const gmic_image<unsigned int>& scope_selection) const;
gmic_image<char> scope2string(const gmic_image<unsigned int>* scope_selection) const;
gmic_image<unsigned int> selection2cimg(const char *const string, const unsigned int indice_max,
const gmic_list<char>& names,
const char *const command, const bool is_selection,
const bool allow_new_name, gmic_image<char>& new_name);
gmic_image<char> selection2string(const gmic_image<unsigned int>& selection,
const gmic_list<char>& images_names,
const bool display_selection) const;
gmic_list<char> commands_line_to_CImgList(const char *const commands_line);
template<typename T>
gmic_image<char> substitute_item(const char *const source,
gmic_list<T>& images, gmic_list<char>& images_names,
gmic_list<T>& parent_images, gmic_list<char>& parent_images_names,
unsigned int variables_sizes[256]);
gmic& print(const char *format, ...);
gmic& error(const char *format, ...);
gmic& debug(const char *format, ...);
template<typename T>
gmic& print(const gmic_list<T>& list, const gmic_image<unsigned int> *const scope_selection,
const char *format, ...);
template<typename T>
gmic& warn(const gmic_list<T>& list, const gmic_image<unsigned int> *const scope_selection,
const char *format, ...);
template<typename T>
gmic& error(const gmic_list<T>& list, const gmic_image<unsigned int> *const scope_selection,
const char *const command, const char *format, ...);
template<typename T>
gmic& debug(const gmic_list<T>& list, const char *format, ...);
template<typename T>
gmic& print_images(const gmic_list<T>& images,
const gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
const bool is_header=true);
template<typename T>
gmic& display_images(const gmic_list<T>& images,
const gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
unsigned int *const XYZ);
template<typename T>
gmic& display_plots(const gmic_list<T>& images,
const gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
const unsigned int plot_type, const unsigned int vertex_type,
const double xmin, const double xmax,
const double ymin, const double ymax);
template<typename T>
gmic& display_objects3d(const gmic_list<T>& images,
const gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
const gmic_image<unsigned char>& background3d);
template<typename T>
gmic_image<T>& check_image(const gmic_list<T>& list, gmic_image<T>& img);
template<typename T>
const gmic_image<T>& check_image(const gmic_list<T>& list, const gmic_image<T>& img);
template<typename T>
gmic& remove_images(gmic_list<T>& images, gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
const unsigned int start, const unsigned int end);
template<typename T>
gmic& _run(const gmic_list<char>& commands_line,
gmic_list<T> &images, gmic_list<char> &images_names,
float *const p_progress=0, int *const p_cancel=0);
template<typename T>
gmic& _run(const gmic_list<char>& commands_line, unsigned int& position,
gmic_list<T>& images, gmic_list<char>&images_names,
gmic_list<T>& parent_images, gmic_list<char>& parent_images_names,
unsigned int variables_sizes[256],
bool *const is_noargs=0);
// Internal environment variables of the interpreter.
#if cimg_display!=0
gmic_display instant_window[10];
#endif // #if cimg_display!=0
gmic_list<char> *const commands, *const commands_names, *const commands_has_arguments,
*const _variables, *const _variables_names, **const variables, **const variables_names,
commands_files, scope;
gmic_list<unsigned int> dowhiles, repeatdones;
gmic_image<unsigned char> light3d;
gmic_image<char> status;
float focale3d, light3d_x, light3d_y, light3d_z, specular_lightness3d, specular_shininess3d,
_progress, *progress;
bool is_released, is_debug, is_start, is_quit, is_return, is_double3d, is_default_type,
is_debug_infos, check_elif;
int verbosity, render3d, renderd3d;
volatile int _cancel, *cancel;
unsigned int nb_carriages, debug_filename, debug_line, cimg_exception_mode;
unsigned long reference_time;
const char *starting_commands_line;
}; // End of the 'gmic' class.
#endif // #ifndef gmic_version
// Local Variables:
// mode: c++
// End:

File diff suppressed because it is too large Load Diff

View File

@ -1,351 +0,0 @@
/* Pass VIPS images through gmic
*
* AF, 6/10/14
*/
/*
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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/dispatch.h>
#include <limits.h>
#include <iostream>
#include "CImg.h"
#include "gmic.h"
using namespace cimg_library;
typedef struct _VipsGMic {
VipsOperation parent_instance;
VipsArrayImage *in;
VipsImage *out;
char *command;
int padding;
double x_scale;
double y_scale;
} VipsGMic;
typedef VipsOperationClass VipsGMicClass;
#define VIPS_TYPE_GMIC (vips_gmic_get_type())
#define VIPS_GMIC( obj ) \
(G_TYPE_CHECK_INSTANCE_CAST( (obj), VIPS_TYPE_GMIC, VipsGMic ))
#define VIPS_GMIC_CLASS( klass ) \
(G_TYPE_CHECK_CLASS_CAST( (klass), VIPS_TYPE_GMIC, VipsGMicClass))
#define VIPS_IS_GMIC( obj ) \
(G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_GMIC ))
#define VIPS_IS_GMIC_CLASS( klass ) \
(G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_GMIC ))
#define VIPS_GMIC_GET_CLASS( obj ) \
(G_TYPE_INSTANCE_GET_CLASS( (obj), VIPS_TYPE_GMIC, VipsGMicClass ))
extern "C" {
G_DEFINE_TYPE( VipsGMic, vips_gmic, VIPS_TYPE_OPERATION );
}
static int
vips_gmic_get_tile_border( VipsGMic *vipsgmic )
{
return( vipsgmic->padding );
}
#define INDEX( IMG, X, Y, Z ) \
((*(IMG))( (guint) (X), (guint) (Y), (guint) (Z), 0 ))
// copy part of a vips region into a cimg
template<typename T> static void
vips_to_gmic( VipsRegion *in, VipsRect *area, CImg<T> *img )
{
VipsImage *im = in->im;
for( int y = 0; y < area->height; y++ ) {
T *p = (T *) VIPS_REGION_ADDR( in, area->left, area->top + y );
for( int x = 0; x < area->width; x++ ) {
for( int z = 0; z < im->Bands; z++ )
INDEX( img, x, y, z ) = p[z];
p += im->Bands;
}
}
}
// write a CImg to a vips region
// fill out->valid, img has pixels in img_rect
template<typename T> static void
vips_from_gmic( gmic_image<T> *img, VipsRect *img_rect, VipsRegion *out )
{
VipsImage *im = out->im;
VipsRect *valid = &out->valid;
g_assert( vips_rect_includesrect( img_rect, valid ) );
int x_off = valid->left - img_rect->left;
int y_off = valid->top - img_rect->top;
for( int y = 0; y < valid->height; y++ ) {
T *p = (T *) \
VIPS_REGION_ADDR( out, valid->left, valid->top + y );
for( int x = 0; x < valid->width; x++ ) {
for( int z = 0; z < im->Bands; z++ )
p[z] = INDEX( img, x + x_off, y + y_off, z );
p += im->Bands;
}
}
}
template<typename T> static int
vips_gmic_gen_template( VipsRegion *oreg,
void *seq, void *a, void *b, gboolean *stop )
{
VipsRegion **ir = (VipsRegion **) seq;
VipsGMic *vipsgmic = (VipsGMic *) b;
int ninput = VIPS_AREA( vipsgmic->in )->n;
const int tile_border = vips_gmic_get_tile_border( vipsgmic );
const VipsRect *r = &oreg->valid;
VipsRect need;
VipsRect image;
need = *r;
vips_rect_marginadjust( &need, tile_border );
image.left = 0;
image.top = 0;
image.width = ir[0]->im->Xsize;
image.height = ir[0]->im->Ysize;
vips_rect_intersectrect( &need, &image, &need );
for( int i = 0; ir[i]; i++ )
if( vips_region_prepare( ir[i], &need ) )
return( -1 );
gmic gmic_instance;
gmic_list<T> images;
gmic_list<char> images_names;
try {
images.assign( (guint) ninput );
for( int i = 0; ir[i]; i++ ) {
gmic_image<T> &img = images._data[i];
img.assign( need.width, need.height,
1, ir[i]->im->Bands );
vips_to_gmic<T>( ir[0], &need, &img );
}
gmic_instance.run( vipsgmic->command, images, images_names );
vips_from_gmic<T>( &images._data[0], &need, oreg );
}
catch( gmic_exception e ) {
images.assign( (guint) 0 );
vips_error( "VipsGMic", "%s", e.what() );
return( -1 );
}
images.assign( (guint) 0 );
return( 0 );
}
static int
vips_gmic_gen( VipsRegion *oreg, void *seq, void *a, void *b, gboolean *stop )
{
VipsRegion **ir = (VipsRegion **) seq;
switch( ir[0]->im->BandFmt ) {
case VIPS_FORMAT_UCHAR:
return( vips_gmic_gen_template<unsigned char>( oreg,
seq, a, b, stop ) );
break;
case VIPS_FORMAT_USHORT:
return( vips_gmic_gen_template<unsigned short int>( oreg,
seq, a, b, stop ) );
break;
case VIPS_FORMAT_FLOAT:
return( vips_gmic_gen_template<float>( oreg,
seq, a, b, stop ) );
break;
default:
g_assert( 0 );
break;
}
return( 0 );
}
/* Save a bit of typing.
*/
#define UC VIPS_FORMAT_UCHAR
#define C VIPS_FORMAT_CHAR
#define US VIPS_FORMAT_USHORT
#define S VIPS_FORMAT_SHORT
#define UI VIPS_FORMAT_UINT
#define I VIPS_FORMAT_INT
#define F VIPS_FORMAT_FLOAT
#define X VIPS_FORMAT_COMPLEX
#define D VIPS_FORMAT_DOUBLE
#define DX VIPS_FORMAT_DPCOMPLEX
/* Type promotion.
*/
static const VipsBandFormat vips_gmic_format_table[10] = {
/* UC C US S UI I F X D DX */
UC, F, US, F, F, F, F, F, F, F
};
static int
vips_gmic_build( VipsObject *object )
{
VipsObjectClass *klass = VIPS_OBJECT_GET_CLASS( object );
VipsGMic *vipsgmic = (VipsGMic *) object;
VipsImage **in;
VipsImage **t;
int ninput;
VipsBandFormat format;
if( VIPS_OBJECT_CLASS( vips_gmic_parent_class )->build( object ) )
return( -1 );
in = vips_array_image_get( vipsgmic->in, &ninput );
for( int i = 0; i < ninput; i++ )
if( vips_image_pio_input( in[i] ) ||
vips_check_coding_known( klass->nickname, in[i] ) )
return( -1 );
/* Cast all inputs up to the largest common supported format.
*/
format = VIPS_FORMAT_UCHAR;
for( int i = 0; i < ninput; i++ )
format = VIPS_MAX( format, in[i]->BandFmt );
format = vips_gmic_format_table[format];
t = (VipsImage **) vips_object_local_array( object, ninput );
for( int i = 0; i < ninput; i++ )
if( vips_cast( in[i], &t[i], format, NULL ) )
return( -1 );
in = t;
g_object_set( vipsgmic, "out", vips_image_new(), NULL );
if( vips_image_pipeline_array( vipsgmic->out,
VIPS_DEMAND_STYLE_ANY, in ) )
return( -1 );
if( ninput > 0 ) {
if( vips_image_generate( vipsgmic->out,
vips_start_many, vips_gmic_gen, vips_stop_many,
in, vipsgmic ) )
return( -1 );
}
else {
if( vips_image_generate( vipsgmic->out,
NULL, vips_gmic_gen, NULL,
NULL, vipsgmic ) )
return( -1 );
}
return( 0 );
}
static void
vips_gmic_class_init( VipsGMicClass *klass )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( klass );
VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( klass );
VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( klass );
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
vobject_class->nickname = "gmic";
vobject_class->description = _( "Vips G'MIC" );
vobject_class->build = vips_gmic_build;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
VIPS_ARG_BOXED( klass, "in", 0,
_( "Input" ),
_( "Array of input images" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsGMic, in ),
VIPS_TYPE_ARRAY_IMAGE );
VIPS_ARG_IMAGE( klass, "out", 1,
_( "Output" ),
_( "Output image" ),
VIPS_ARGUMENT_REQUIRED_OUTPUT,
G_STRUCT_OFFSET( VipsGMic, out ) );
VIPS_ARG_INT( klass, "padding", 3,
_( "padding" ),
_( "Tile overlap" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsGMic, padding ),
0, INT_MAX, 0);
VIPS_ARG_DOUBLE( klass, "x_scale", 4,
_( "x_scale" ),
_( "X Scale" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsGMic, x_scale ),
0, 100000000, 1);
VIPS_ARG_DOUBLE( klass, "y_scale", 5,
_( "y_scale" ),
_( "Y Scale" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsGMic, y_scale ),
0, 100000000, 1);
VIPS_ARG_STRING( klass, "command", 10,
_( "command" ),
_( "G'MIC command string" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsGMic, command ),
NULL );
}
static void
vips_gmic_init( VipsGMic *vipsgmic )
{
}

View File

@ -5352,20 +5352,8 @@ im_greyc_mask( IMAGE *in, IMAGE *out, IMAGE *mask,
float dl, float da, float gauss_prec,
int interpolation, int fast_approx )
{
VipsImage *input_images[2];
VipsImage *output_image;
char *command;
int result;
vips_error( "im_greyc_mask",
"This function is no longer in the core library" );
input_images[0] = in;
input_images[1] = mask;
command = g_strdup_printf( "-smooth %g,%g,%g,%g,%g,%g,%g,%g,%d,%d",
amplitude, sharpness, anisotropy,
alpha, sigma, dl, da, gauss_prec,
interpolation, fast_approx );
result = vips_gmic( input_images, &output_image, 2,
4, 1, 1, command, NULL );
g_free( command );
return( result );
return( -1 );
}

View File

@ -285,7 +285,6 @@ vips_init( const char *argv0 )
vips_morphology_operation_init();
vips_draw_operation_init();
vips_mosaicing_operation_init();
vips_cimg_operation_init();
/* Load up any plugins in the vips libdir. We don't error on failure,
* it's too annoying to have VIPS refuse to start because of a broken

View File

@ -20,6 +20,9 @@ libresample_la_SOURCES = \
vsqbs.cpp \
templates.h
EXTRA_DIST = \
dummy2.cc
else
libresample_la_SOURCES = \
@ -34,6 +37,7 @@ libresample_la_SOURCES = \
transform.c
EXTRA_DIST = \
dummy2.cc \
bicubic.cpp \
lbb.cpp \
nohalo.cpp \