add tiffsave_buffer

add tests

also some cleanups to foreign include files

see https://github.com/jcupitt/libvips/issues/417
This commit is contained in:
John Cupitt 2016-10-15 12:29:14 +01:00
parent 6d1d6fd16c
commit c90b8be0b8
66 changed files with 1104 additions and 1015 deletions

View File

@ -1,5 +1,6 @@
13/10/16 started 8.5.0
- rewritten buffer system is safer and frees memory earlier
- added tiff save to buffer
27/9/16 started 8.4.2
- small doc improvements

View File

@ -44,7 +44,7 @@
#include <vips/vips.h>
#include "../foreign/csv.h"
#include "../foreign/pforeign.h"
int
im_csv2vips( const char *filename, IMAGE *out )

View File

@ -49,7 +49,7 @@
#include <vips/thread.h>
#include <vips/internal.h>
#include "../foreign/openexr2vips.h"
#include "../foreign/pforeign.h"
int
im_exr2vips( const char *filename, IMAGE *out )

View File

@ -48,9 +48,7 @@
#include <vips/vips.h>
#ifdef HAVE_JPEG
#include "../foreign/vipsjpeg.h"
#endif /*HAVE_JPEG*/
#include "../foreign/pforeign.h"
static int
jpeg2vips( const char *name, IMAGE *out, gboolean header_only )

View File

@ -42,7 +42,7 @@
#include <vips/vips.h>
#include "../foreign/magick.h"
#include "../foreign/pforeign.h"
int
im_magick2vips( const char *filename, IMAGE *out )

View File

@ -45,7 +45,7 @@
#include <vips/vips.h>
#include <vips/internal.h>
#include "../foreign/vipspng.h"
#include "../foreign/pforeign.h"
static int
png2vips( const char *name, IMAGE *out, gboolean header_only )

View File

@ -49,7 +49,7 @@
#include <vips/internal.h>
#include <vips/thread.h>
#include "../foreign/tiff.h"
#include "../foreign/pforeign.h"
static int
tiff2vips( const char *name, IMAGE *out, gboolean header_only )

View File

@ -39,7 +39,7 @@
#include <vips/vips.h>
#include <vips/internal.h>
#include "../foreign/webp.h"
#include "../foreign/pforeign.h"
static int
webp2vips( const char *name, IMAGE *out, gboolean header_only )

View File

@ -1,19 +1,17 @@
noinst_LTLIBRARIES = libforeign.la
libforeign_la_SOURCES = \
pforeign.h \
gifload.c \
cairo.c \
pdfload.c \
svgload.c \
radiance.h \
radiance.c \
radload.c \
radsave.c \
ppm.h \
ppm.c \
ppmload.c \
ppmsave.c \
csv.h \
csv.c \
csvload.c \
csvsave.c \
@ -27,35 +25,28 @@ libforeign_la_SOURCES = \
dbh.h \
analyzeload.c \
analyze2vips.c \
analyze2vips.h \
foreign.c \
matlab.h \
matlab.c \
matload.c \
magick.h \
magick2vips.c \
magickload.c \
magick7load.c \
pngload.c \
pngsave.c \
vipspng.h \
vipspng.c \
openexr2vips.h \
openexr2vips.c \
openexrload.c \
fits.h \
fits.c \
fitsload.c \
fitssave.c \
tiff.h \
tiff.c \
vips2tiff.c \
tiff2vips.c \
tiffload.c \
tiffsave.c \
openslide2vips.h \
openslide2vips.c \
openslideload.c \
webp.h \
webpload.c \
webpsave.c \
webp2vips.c \
@ -63,7 +54,6 @@ libforeign_la_SOURCES = \
vips2jpeg.c \
jpeg2vips.c \
jpeg.h \
vipsjpeg.h \
jpegload.c \
jpegsave.c

View File

@ -61,7 +61,7 @@
#include <vips/internal.h>
#include "dbh.h"
#include "analyze2vips.h"
#include "pforeign.h"
/* The things we can have in header fields. Can't use GType, since we want a
* static value we can use in a declaration.

View File

@ -1,46 +0,0 @@
/* common defs for tiff read/write
*/
/*
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
*/
#ifndef VIPS_ANALYZE_H
#define VIPS_ANALYZE_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
int vips__isanalyze( const char *filename );
int vips__analyze_read_header( const char *filename, VipsImage *out );
int vips__analyze_read( const char *filename, VipsImage *out );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_ANALYZE_H*/

View File

@ -50,7 +50,7 @@
#ifdef HAVE_ANALYZE
#include "analyze2vips.h"
#include "pforeign.h"
typedef struct _VipsForeignLoadAnalyze {
VipsForeignLoad parent_object;

View File

@ -75,7 +75,7 @@
#include <vips/vips.h>
#include "csv.h"
#include "pforeign.h"
/* Skip to the start of the next line (ie. read until we see a '\n'), return
* zero if we are at EOF.

View File

@ -1,62 +0,0 @@
/* common defs for csv read/write
*/
/*
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
*/
#ifndef VIPS_CSV_H
#define VIPS_CSV_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
extern const char *vips__foreign_csv_suffs[];
int vips__csv_read( const char *filename, VipsImage *out,
int skip, int lines, const char *whitespace, const char *separator );
int vips__csv_read_header( const char *filename, VipsImage *out,
int skip, int lines, const char *whitespace, const char *separator );
int vips__csv_write( VipsImage *in, const char *filename,
const char *separator );
int vips__matrix_read_header( const char *filename,
int *width, int *height, double *scale, double *offset );
int vips__matrix_ismatrix( const char *filename );
VipsImage *vips__matrix_read_file( FILE *fp );
VipsImage *vips__matrix_read( const char *filename );
int vips__matrix_write( VipsImage *in, const char *filename );
int vips__matrix_write_file( VipsImage *in, FILE *fp );
extern const char *vips__foreign_matrix_suffs[];
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_CSV_H*/

View File

@ -48,7 +48,7 @@
#include <vips/buf.h>
#include <vips/internal.h>
#include "csv.h"
#include "pforeign.h"
typedef struct _VipsForeignLoadCsv {
VipsForeignLoad parent_object;

View File

@ -47,7 +47,7 @@
#include <vips/vips.h>
#include "csv.h"
#include "pforeign.h"
typedef struct _VipsForeignSaveCsv {
VipsForeignSave parent_object;

View File

@ -1,3 +0,0 @@
void shrink_region_uncoded( VipsRegion *from, VipsRegion *to,
VipsRect *target );

View File

@ -73,7 +73,7 @@
#include <fitsio.h>
#include "fits.h"
#include "pforeign.h"
/*

View File

@ -1,50 +0,0 @@
/* defs for fits read/write
*/
/*
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
*/
#ifndef VIPS_FITS_H
#define VIPS_FITS_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
extern const char *vips__fits_suffs[];
int vips__fits_isfits( const char *filename );
int vips__fits_read_header( const char *filename, VipsImage *out );
int vips__fits_read( const char *filename, VipsImage *out );
int vips__fits_write( VipsImage *in, const char *filename );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_FITS_H*/

View File

@ -50,7 +50,7 @@
#ifdef HAVE_CFITSIO
#include "fits.h"
#include "pforeign.h"
typedef struct _VipsForeignLoadFits {
VipsForeignLoad parent_object;

View File

@ -51,7 +51,7 @@
#ifdef HAVE_CFITSIO
#include "fits.h"
#include "pforeign.h"
typedef struct _VipsForeignSaveFits {
VipsForeignSave parent_object;

View File

@ -59,6 +59,8 @@
#include <vips/internal.h>
#include <vips/debug.h>
#include "pforeign.h"
/**
* SECTION: foreign
* @short_description: load and save images in a variety of formats
@ -1636,7 +1638,8 @@ vips_foreign_operation_init( void )
extern GType vips_foreign_save_jpeg_mime_get_type( void );
extern GType vips_foreign_load_tiff_file_get_type( void );
extern GType vips_foreign_load_tiff_buffer_get_type( void );
extern GType vips_foreign_save_tiff_get_type( void );
extern GType vips_foreign_save_tiff_file_get_type( void );
extern GType vips_foreign_save_tiff_buffer_get_type( void );
extern GType vips_foreign_load_vips_get_type( void );
extern GType vips_foreign_save_vips_get_type( void );
extern GType vips_foreign_load_raw_get_type( void );
@ -1738,7 +1741,8 @@ vips_foreign_operation_init( void )
#ifdef HAVE_TIFF
vips_foreign_load_tiff_file_get_type();
vips_foreign_load_tiff_buffer_get_type();
vips_foreign_save_tiff_get_type();
vips_foreign_save_tiff_file_get_type();
vips_foreign_save_tiff_buffer_get_type();
#endif /*HAVE_TIFF*/
#ifdef HAVE_OPENSLIDE

View File

@ -143,8 +143,9 @@
#include <vips/buf.h>
#include <vips/internal.h>
#include "pforeign.h"
#include "jpeg.h"
#include "vipsjpeg.h"
/* Stuff we track during a read.
*/

View File

@ -52,6 +52,8 @@
#include <vips/buf.h>
#include <vips/internal.h>
#include "pforeign.h"
#ifdef HAVE_JPEG
#ifdef HAVE_EXIF
@ -68,8 +70,6 @@
#endif /*UNTAGGED_EXIF*/
#endif /*HAVE_EXIF*/
#include "vipsjpeg.h"
typedef struct _VipsForeignLoadJpeg {
VipsForeignLoad parent_object;

View File

@ -50,6 +50,8 @@
#include <vips/buf.h>
#include <vips/internal.h>
#include "pforeign.h"
#ifdef HAVE_JPEG
#ifdef HAVE_EXIF
@ -66,8 +68,6 @@
#endif /*UNTAGGED_EXIF*/
#endif /*HAVE_EXIF*/
#include "vipsjpeg.h"
typedef struct _VipsForeignSaveJpeg {
VipsForeignSave parent_object;

View File

@ -1,52 +0,0 @@
/* common defs for libMagick read/write
*/
/*
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
*/
#ifndef VIPS_MAGICK_H
#define VIPS_MAGICK_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
int vips__magick_read( const char *filename,
VipsImage *out, gboolean all_frames, const char *density, int page );
int vips__magick_read_header( const char *filename,
VipsImage *out, gboolean all_frames, const char *density, int page );
int vips__magick_read_buffer( const void *buf, const size_t len,
VipsImage *out, gboolean all_frames, const char *density, int page );
int vips__magick_read_buffer_header( const void *buf, const size_t len,
VipsImage *out, gboolean all_frames, const char *density, int page );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_MAGICK_H*/

View File

@ -100,7 +100,7 @@
#include <magick/api.h>
#include "magick.h"
#include "pforeign.h"
/* pre-float Magick used to call this MaxRGB.
*/

View File

@ -56,7 +56,7 @@
#ifdef HAVE_MAGICK
#include "magick.h"
#include "pforeign.h"
typedef struct _VipsForeignLoadMagick {
VipsForeignLoad parent_object;

View File

@ -73,7 +73,7 @@
#include <matio.h>
#include "matlab.h"
#include "pforeign.h"
/* What we track during a Mat-file read.
*/

View File

@ -1,48 +0,0 @@
/* common defs for matio read/write
*/
/*
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
*/
#ifndef VIPS_MAT_H
#define VIPS_MAT_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
extern const char *vips__mat_suffs[];
int vips__mat_load( const char *filename, VipsImage *out );
int vips__mat_header( const char *filename, VipsImage *out );
int vips__mat_ismat( const char *filename );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_MAT_H*/

View File

@ -52,7 +52,7 @@
#ifdef HAVE_MATIO
#include "matlab.h"
#include "pforeign.h"
typedef struct _VipsForeignLoadMat {
VipsForeignLoad parent_object;

View File

@ -48,7 +48,7 @@
#include <vips/buf.h>
#include <vips/internal.h>
#include "csv.h"
#include "pforeign.h"
typedef struct _VipsForeignLoadMatrix {
VipsForeignLoad parent_object;

View File

@ -47,7 +47,7 @@
#include <vips/vips.h>
#include "csv.h"
#include "pforeign.h"
typedef struct _VipsForeignSaveMatrix {
VipsForeignSave parent_object;

View File

@ -86,7 +86,7 @@
#include <ImfCRgbaFile.h>
#include "openexr2vips.h"
#include "pforeign.h"
/* What we track during a OpenEXR read.
*/

View File

@ -1,47 +0,0 @@
/* common defs for jpeg read/write
*/
/*
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
*/
#ifndef VIPS_OPENEXR2VIPS_H
#define VIPS_OPENEXR2VIPS_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
int vips__openexr_isexr( const char *filename );
gboolean vips__openexr_istiled( const char *filename );
int vips__openexr_read_header( const char *filename, VipsImage *out );
int vips__openexr_read( const char *filename, VipsImage *out );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_OPENEXR2VIPS_H*/

View File

@ -50,7 +50,7 @@
#ifdef HAVE_OPENEXR
#include "openexr2vips.h"
#include "pforeign.h"
typedef struct _VipsForeignLoadOpenexr {
VipsForeignLoad parent_object;

View File

@ -91,9 +91,9 @@
#include <vips/vips.h>
#include <vips/debug.h>
#include <openslide.h>
#include "pforeign.h"
#include "openslide2vips.h"
#include <openslide.h>
typedef struct {
openslide_t *osr;

View File

@ -1,50 +0,0 @@
/* common defs for jpeg read/write
*/
/*
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
*/
#ifndef VIPS_OPENSLIDE2VIPS_H
#define VIPS_OPENSLIDE2VIPS_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
int vips__openslide_isslide( const char *filename );
int vips__openslide_read_header( const char *filename, VipsImage *out,
int level, gboolean autocrop, char *associated );
int vips__openslide_read( const char *filename, VipsImage *out,
int level, gboolean autocrop );
int vips__openslide_read_associated( const char *filename, VipsImage *out,
const char *associated );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_OPENSLIDE2VIPS_H*/

View File

@ -55,9 +55,9 @@
#include <vips/buf.h>
#include <vips/internal.h>
#ifdef HAVE_OPENSLIDE
#include "pforeign.h"
#include "openslide2vips.h"
#ifdef HAVE_OPENSLIDE
typedef struct _VipsForeignLoadOpenslide {
VipsForeignLoad parent_object;

230
libvips/foreign/pforeign.h Normal file
View File

@ -0,0 +1,230 @@
/* Private decls shared by all foreign.
*/
/*
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
*/
#ifndef VIPS_PARITHMETIC_H
#define VIPS_PARITHMETIC_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
void vips__tiff_init( void );
int vips__tiff_write( VipsImage *in, const char *filename,
VipsForeignTiffCompression compression, int Q,
VipsForeignTiffPredictor predictor,
char *profile,
gboolean tile, int tile_width, int tile_height,
gboolean pyramid,
gboolean squash,
gboolean miniswhite,
VipsForeignTiffResunit resunit, double xres, double yres,
gboolean bigtiff,
gboolean rgbjpeg,
gboolean properties,
gboolean strip );
int vips__tiff_write_buf( VipsImage *in,
void **obuf, size_t *olen,
VipsForeignTiffCompression compression, int Q,
VipsForeignTiffPredictor predictor,
char *profile,
gboolean tile, int tile_width, int tile_height,
gboolean pyramid,
gboolean squash,
gboolean miniswhite,
VipsForeignTiffResunit resunit, double xres, double yres,
gboolean bigtiff,
gboolean rgbjpeg,
gboolean properties, gboolean strip );
int vips__tiff_read_header( const char *filename, VipsImage *out,
int page, gboolean autorotate );
int vips__tiff_read( const char *filename, VipsImage *out,
int page, gboolean autorotate, gboolean readbehind );
gboolean vips__istifftiled( const char *filename );
gboolean vips__istiff_buffer( const void *buf, size_t len );
gboolean vips__istiff( const char *filename );
int vips__tiff_read_header_buffer( const void *buf, size_t len, VipsImage *out,
int page, gboolean autorotate );
int vips__tiff_read_buffer( const void *buf, size_t len, VipsImage *out,
int page, gboolean autorotate, gboolean readbehind );
extern const char *vips__foreign_tiff_suffs[];
int vips__isanalyze( const char *filename );
int vips__analyze_read_header( const char *filename, VipsImage *out );
int vips__analyze_read( const char *filename, VipsImage *out );
extern const char *vips__foreign_csv_suffs[];
int vips__csv_read( const char *filename, VipsImage *out,
int skip, int lines, const char *whitespace, const char *separator );
int vips__csv_read_header( const char *filename, VipsImage *out,
int skip, int lines, const char *whitespace, const char *separator );
int vips__csv_write( VipsImage *in, const char *filename,
const char *separator );
int vips__matrix_read_header( const char *filename,
int *width, int *height, double *scale, double *offset );
int vips__matrix_ismatrix( const char *filename );
VipsImage *vips__matrix_read_file( FILE *fp );
VipsImage *vips__matrix_read( const char *filename );
int vips__matrix_write( VipsImage *in, const char *filename );
int vips__matrix_write_file( VipsImage *in, FILE *fp );
extern const char *vips__foreign_matrix_suffs[];
int vips__openexr_isexr( const char *filename );
gboolean vips__openexr_istiled( const char *filename );
int vips__openexr_read_header( const char *filename, VipsImage *out );
int vips__openexr_read( const char *filename, VipsImage *out );
extern const char *vips__fits_suffs[];
int vips__fits_isfits( const char *filename );
int vips__fits_read_header( const char *filename, VipsImage *out );
int vips__fits_read( const char *filename, VipsImage *out );
int vips__fits_write( VipsImage *in, const char *filename );
int vips__magick_read( const char *filename,
VipsImage *out, gboolean all_frames, const char *density, int page );
int vips__magick_read_header( const char *filename,
VipsImage *out, gboolean all_frames, const char *density, int page );
int vips__magick_read_buffer( const void *buf, const size_t len,
VipsImage *out, gboolean all_frames, const char *density, int page );
int vips__magick_read_buffer_header( const void *buf, const size_t len,
VipsImage *out, gboolean all_frames, const char *density, int page );
extern const char *vips__mat_suffs[];
int vips__mat_load( const char *filename, VipsImage *out );
int vips__mat_header( const char *filename, VipsImage *out );
int vips__mat_ismat( const char *filename );
int vips__ppm_header( const char *name, VipsImage *out );
int vips__ppm_load( const char *name, VipsImage *out );
int vips__ppm_isppm( const char *filename );
VipsForeignFlags vips__ppm_flags( const char *filename );
extern const char *vips__ppm_suffs[];
int vips__ppm_save( VipsImage *in, const char *filename,
gboolean ascii, gboolean squash );
int vips__rad_israd( const char *filename );
int vips__rad_header( const char *filename, VipsImage *out );
int vips__rad_load( const char *filename, VipsImage *out, gboolean readbehind );
int vips__rad_save( VipsImage *in, const char *filename );
int vips__rad_save_buf( VipsImage *in, void **obuf, size_t *olen );
extern const char *vips__rad_suffs[];
extern const char *vips__jpeg_suffs[];
int vips__jpeg_write_file( VipsImage *in,
const char *filename, int Q, const char *profile,
gboolean optimize_coding, gboolean progressive, gboolean strip,
gboolean no_subsample, gboolean trellis_quant,
gboolean overshoot_deringing, gboolean optimize_scans, int quant_table );
int vips__jpeg_write_buffer( VipsImage *in,
void **obuf, size_t *olen, int Q, const char *profile,
gboolean optimize_coding, gboolean progressive, gboolean strip,
gboolean no_subsample, gboolean trellis_quant,
gboolean overshoot_deringing, gboolean optimize_scans, int quant_table );
int vips__isjpeg_buffer( const void *buf, size_t len );
int vips__isjpeg( const char *filename );
int vips__jpeg_read_file( const char *name, VipsImage *out,
gboolean header_only, int shrink, gboolean fail, gboolean readbehind,
gboolean autorotate );
int vips__jpeg_read_buffer( const void *buf, size_t len, VipsImage *out,
gboolean header_only, int shrink, int fail, gboolean readbehind,
gboolean autorotate );
int vips__png_header( const char *name, VipsImage *out );
int vips__png_read( const char *name, VipsImage *out, gboolean readbehind );
gboolean vips__png_ispng_buffer( const void *buf, size_t len );
int vips__png_ispng( const char *filename );
gboolean vips__png_isinterlaced( const char *filename );
extern const char *vips__png_suffs[];
int vips__png_read_buffer( const void *buffer, size_t length,
VipsImage *out, gboolean readbehind );
int vips__png_header_buffer( const void *buffer, size_t length,
VipsImage *out );
int vips__png_write( VipsImage *in, const char *filename,
int compress, int interlace, const char *profile,
VipsForeignPngFilter filter, gboolean strip );
int vips__png_write_buf( VipsImage *in,
void **obuf, size_t *olen, int compression, int interlace,
const char *profile, VipsForeignPngFilter filter, gboolean strip );
extern const char *vips__webp_suffs[];
int vips__iswebp_buffer( const void *buf, size_t len );
int vips__iswebp( const char *filename );
int vips__webp_read_file_header( const char *name, VipsImage *out, int shrink );
int vips__webp_read_file( const char *name, VipsImage *out, int shrink );
int vips__webp_read_buffer_header( const void *buf, size_t len,
VipsImage *out, int shrink );
int vips__webp_read_buffer( const void *buf, size_t len,
VipsImage *out, int shrink );
int vips__webp_write_file( VipsImage *out, const char *filename,
int Q, gboolean lossless, VipsForeignWebpPreset preset,
gboolean smart_subsample, gboolean near_lossless,
int alpha_q );
int vips__webp_write_buffer( VipsImage *out, void **buf, size_t *len,
int Q, gboolean lossless, VipsForeignWebpPreset preset,
gboolean smart_subsample, gboolean near_lossless,
int alpha_q );
int vips__openslide_isslide( const char *filename );
int vips__openslide_read_header( const char *filename, VipsImage *out,
int level, gboolean autocrop, char *associated );
int vips__openslide_read( const char *filename, VipsImage *out,
int level, gboolean autocrop );
int vips__openslide_read_associated( const char *filename, VipsImage *out,
const char *associated );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_PARITHMETIC_H*/

View File

@ -48,9 +48,9 @@
#include <vips/buf.h>
#include <vips/internal.h>
#ifdef HAVE_PNG
#include "pforeign.h"
#include "vipspng.h"
#ifdef HAVE_PNG
typedef struct _VipsForeignLoadPng {
VipsForeignLoad parent_object;

View File

@ -49,9 +49,9 @@
#include <vips/vips.h>
#ifdef HAVE_PNG
#include "pforeign.h"
#include "vipspng.h"
#ifdef HAVE_PNG
typedef struct _VipsForeignSavePng {
VipsForeignSave parent_object;

View File

@ -80,7 +80,7 @@
#include <vips/vips.h>
#include <vips/internal.h>
#include "ppm.h"
#include "pforeign.h"
/* The largest number/field/whatever we can read.
*/

View File

@ -1,51 +0,0 @@
/* common defs for ppm read/write
*/
/*
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
*/
#ifndef VIPS_PPM_H
#define VIPS_PPM_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
int vips__ppm_header( const char *name, VipsImage *out );
int vips__ppm_load( const char *name, VipsImage *out );
int vips__ppm_isppm( const char *filename );
VipsForeignFlags vips__ppm_flags( const char *filename );
extern const char *vips__ppm_suffs[];
int vips__ppm_save( VipsImage *in, const char *filename,
gboolean ascii, gboolean squash );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_PPM_H*/

View File

@ -48,9 +48,9 @@
#include <vips/buf.h>
#include <vips/internal.h>
#ifdef HAVE_PPM
#include "pforeign.h"
#include "ppm.h"
#ifdef HAVE_PPM
typedef struct _VipsForeignLoadPpm {
VipsForeignLoad parent_object;

View File

@ -47,9 +47,9 @@
#include <vips/vips.h>
#ifdef HAVE_PPM
#include "pforeign.h"
#include "ppm.h"
#ifdef HAVE_PPM
typedef struct _VipsForeignSavePpm {
VipsForeignSave parent_object;

View File

@ -143,7 +143,7 @@
#include <vips/internal.h>
#include <vips/debug.h>
#include "radiance.h"
#include "pforeign.h"
/* Begin copy-paste from Radiance sources.
*/

View File

@ -1,51 +0,0 @@
/* common defs for ppm read/write
*/
/*
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
*/
#ifndef VIPS_RADIANCE_H
#define VIPS_RADIANCE_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
int vips__rad_israd( const char *filename );
int vips__rad_header( const char *filename, VipsImage *out );
int vips__rad_load( const char *filename, VipsImage *out, gboolean readbehind );
int vips__rad_save( VipsImage *in, const char *filename );
int vips__rad_save_buf( VipsImage *in, void **obuf, size_t *olen );
extern const char *vips__rad_suffs[];
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_RADIANCE_H*/

View File

@ -48,9 +48,9 @@
#include <vips/buf.h>
#include <vips/internal.h>
#ifdef HAVE_RADIANCE
#include "pforeign.h"
#include "radiance.h"
#ifdef HAVE_RADIANCE
typedef struct _VipsForeignLoadRad {
VipsForeignLoad parent_object;

View File

@ -49,9 +49,9 @@
#include <vips/vips.h>
#ifdef HAVE_RADIANCE
#include "pforeign.h"
#include "radiance.h"
#ifdef HAVE_RADIANCE
typedef struct _VipsForeignSaveRad {
VipsForeignSave parent_object;

459
libvips/foreign/tiff.c Normal file
View File

@ -0,0 +1,459 @@
/* Some shared TIFF utilities.
*
* 14/10/16
* - from vips2tiff.c
*/
/*
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
*/
/*
#define DEBUG
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#ifdef HAVE_TIFF
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /*HAVE_UNISTD_H*/
#include <string.h>
#include <libxml/parser.h>
#include <vips/vips.h>
#include <vips/internal.h>
#include <tiffio.h>
#include "tiff.h"
/* Handle TIFF errors here. Shared with vips2tiff.c. These can be called from
* more than one thread, but vips_error and vips_warn have mutexes in, so that's
* OK.
*/
static void
vips__thandler_error( const char *module, const char *fmt, va_list ap )
{
vips_verror( module, fmt, ap );
}
static void
vips__thandler_warning( const char *module, const char *fmt, va_list ap )
{
char buf[256];
vips_vsnprintf( buf, 256, fmt, ap );
vips_warn( module, "%s", buf );
}
/* Call this during startup. Other libraries may be using libtiff and we want
* to capture any messages they send as well.
*/
void
vips__tiff_init( void )
{
TIFFSetErrorHandler( vips__thandler_error );
TIFFSetWarningHandler( vips__thandler_warning );
}
/* Open TIFF for output.
*/
TIFF *
vips__tiff_openout( const char *path, gboolean bigtiff )
{
TIFF *tif;
const char *mode = bigtiff ? "w8" : "w";
#ifdef DEBUG
printf( "vips__tiff_openout( \"%s\", \"%s\" )\n", path, mode );
#endif /*DEBUG*/
/* Need the utf-16 version on Windows.
*/
#ifdef OS_WIN32
{
GError *error = NULL;
wchar_t *path16;
if( !(path16 = (wchar_t *)
g_utf8_to_utf16( path, -1, NULL, NULL, &error )) ) {
vips_g_error( &error );
return( NULL );
}
tif = TIFFOpenW( path16, mode );
g_free( path16 );
}
#else /*!OS_WIN32*/
tif = TIFFOpen( path, mode );
#endif /*OS_WIN32*/
if( !tif ) {
vips_error( "tiff",
_( "unable to open \"%s\" for output" ), path );
return( NULL );
}
return( tif );
}
/* Open TIFF for input from a file.
*/
TIFF *
vips__tiff_openin( const char *path )
{
/* No mmap --- no performance advantage with libtiff, and it burns up
* our VM if the tiff file is large.
*/
const char *mode = "rm";
TIFF *tif;
#ifdef DEBUG
printf( "vips__tiff_openin( \"%s\" )\n", path );
#endif /*DEBUG*/
/* Need the utf-16 version on Windows.
*/
#ifdef OS_WIN32
{
GError *error = NULL;
wchar_t *path16;
if( !(path16 = (wchar_t *)
g_utf8_to_utf16( path, -1, NULL, NULL, &error )) ) {
vips_g_error( &error );
return( NULL );
}
tif = TIFFOpenW( path16, mode );
g_free( path16 );
}
#else /*!OS_WIN32*/
tif = TIFFOpen( path, mode );
#endif /*OS_WIN32*/
if( !tif ) {
vips_error( "tiff",
_( "unable to open \"%s\" for input" ), path );
return( NULL );
}
return( tif );
}
/* TIFF input from a memory buffer.
*/
typedef struct _VipsTiffOpeninBuffer {
size_t position;
const void *data;
size_t length;
} VipsTiffOpeninBuffer;
static tsize_t
openin_buffer_read( thandle_t st, tdata_t data, tsize_t size )
{
VipsTiffOpeninBuffer *buffer = (VipsTiffOpeninBuffer *) st;
size_t available;
size_t copied;
if( buffer->position > buffer->length ) {
vips_error( "openin_buffer_read",
"%s", _( "read beyond end of buffer" ) );
return( 0 );
}
available = buffer->length - buffer->position;
copied = VIPS_MIN( size, available );
memcpy( data,
(unsigned char *) buffer->data + buffer->position, copied );
buffer->position += copied;
return( copied );
}
static tsize_t
openin_buffer_write( thandle_t st, tdata_t buffer, tsize_t size )
{
g_assert_not_reached();
return( 0 );
}
static int
openin_buffer_close( thandle_t st )
{
return( 0 );
}
/* After calling this, ->pos is not bound by the size of the buffer, it can
* have any positive value.
*/
static toff_t
openin_buffer_seek( thandle_t st, toff_t position, int whence )
{
VipsTiffOpeninBuffer *buffer = (VipsTiffOpeninBuffer *) st;
if( whence == SEEK_SET )
buffer->position = position;
else if( whence == SEEK_CUR )
buffer->position += position;
else if( whence == SEEK_END )
buffer->position = buffer->length + position;
else
g_assert_not_reached();
return( buffer->position );
}
static toff_t
openin_buffer_size( thandle_t st )
{
VipsTiffOpeninBuffer *buffer = (VipsTiffOpeninBuffer *) st;
return( buffer->length );
}
static int
openin_buffer_map( thandle_t st, tdata_t *start, toff_t *len )
{
g_assert_not_reached();
return( 0 );
}
static void
openin_buffer_unmap( thandle_t st, tdata_t start, toff_t len )
{
g_assert_not_reached();
return;
}
TIFF *
vips__tiff_openin_buffer( VipsImage *image, const void *data, size_t length )
{
VipsTiffOpeninBuffer *buffer;
TIFF *tiff;
#ifdef DEBUG
printf( "vips__tiff_openin_buffer:\n" );
#endif /*DEBUG*/
buffer = VIPS_NEW( image, VipsTiffOpeninBuffer );
buffer->position = 0;
buffer->data = data;
buffer->length = length;
if( !(tiff = TIFFClientOpen( "memory input", "rm",
(thandle_t) buffer,
openin_buffer_read,
openin_buffer_write,
openin_buffer_seek,
openin_buffer_close,
openin_buffer_size,
openin_buffer_map,
openin_buffer_unmap )) ) {
vips_error( "vips__tiff_openin_buffer", "%s",
_( "unable to open memory buffer for input" ) );
return( NULL );
}
return( tiff );
}
/* TIFF output to a memory buffer.
*/
typedef struct _VipsTiffOpenoutBuffer {
size_t position;
void *data;
size_t allocated;
size_t length;
/* On close, consolidate and write the output here.
*/
void **out_data;
size_t *out_length;
} VipsTiffOpenoutBuffer;
static tsize_t
openout_buffer_read( thandle_t st, tdata_t data, tsize_t size )
{
g_assert_not_reached();
return( 0 );
}
static tsize_t
openout_buffer_write( thandle_t st, tdata_t data, tsize_t size )
{
VipsTiffOpenoutBuffer *buffer = (VipsTiffOpenoutBuffer *) st;
size_t new_length = VIPS_MAX( buffer->position + size, buffer->length );
#ifdef DEBUG
printf( "openout_buffer_write: %zd bytes\n", size );
#endif /*DEBUG*/
/* We could make a chain of blocks, but libtiff does a lot of seeking
* during writes, so we'd have to handle writes being
* split over blocks, which would be annoying.
*
* Instead, go for exponential realloc: the number of reallocs grows as
* log(final size), and we never over allocate by more than 30%.
*
* realloc can be very, very slow on Windows, but maybe g_realloc() is
* smarter.
*/
if( new_length > buffer->allocated ) {
buffer->allocated = VIPS_MAX( (16 + buffer->allocated) * 3 / 2,
new_length );
buffer->data = g_try_realloc( buffer->data, buffer->allocated );
if( buffer->data == NULL ) {
vips_error( "tiff memory write",
"%s", _( "Out of memory." ) );
return( 0 );
}
}
memcpy( buffer->data + buffer->position, data, size );
buffer->position += size;
buffer->length = new_length;
return( size );
}
static int
openout_buffer_close( thandle_t st )
{
VipsTiffOpenoutBuffer *buffer = (VipsTiffOpenoutBuffer *) st;
*(buffer->out_data) = buffer->data;
*(buffer->out_length) = buffer->length;
return( 0 );
}
static toff_t
openout_buffer_seek( thandle_t st, toff_t position, int whence )
{
VipsTiffOpenoutBuffer *buffer = (VipsTiffOpenoutBuffer *) st;
#ifdef DEBUG
printf( "openout_buffer_seek: position %zd, whence %d\n",
position, whence );
#endif /*DEBUG*/
if( whence == SEEK_SET )
buffer->position = position;
else if( whence == SEEK_CUR )
buffer->position += position;
else if( whence == SEEK_END )
buffer->position = buffer->length + position;
else
g_assert_not_reached();
return( buffer->position );
}
static toff_t
openout_buffer_size( thandle_t st )
{
g_assert_not_reached();
return( 0 );
}
static int
openout_buffer_map( thandle_t st, tdata_t *start, toff_t *len )
{
g_assert_not_reached();
return( 0 );
}
static void
openout_buffer_unmap( thandle_t st, tdata_t start, toff_t len )
{
g_assert_not_reached();
return;
}
/* On TIFFClose(), @data and @length are set to point to the output buffer.
*/
TIFF *
vips__tiff_openout_buffer( VipsImage *image,
gboolean bigtiff, void **out_data, size_t *out_length )
{
const char *mode = bigtiff ? "w8" : "w";
VipsTiffOpenoutBuffer *buffer;
TIFF *tiff;
#ifdef DEBUG
printf( "vips__tiff_openout_buffer:\n" );
#endif /*DEBUG*/
buffer = VIPS_NEW( image, VipsTiffOpenoutBuffer );
buffer->position = 0;
buffer->data = NULL;
buffer->allocated = 0;
buffer->length = 0;
buffer->out_data = out_data;
buffer->out_length = out_length;
if( !(tiff = TIFFClientOpen( "memory output", mode,
(thandle_t) buffer,
openout_buffer_read,
openout_buffer_write,
openout_buffer_seek,
openout_buffer_close,
openout_buffer_size,
openout_buffer_map,
openout_buffer_unmap )) ) {
vips_error( "vips__tiff_openout_buffer", "%s",
_( "unable to open memory buffer for output" ) );
return( NULL );
}
return( tiff );
}
#endif /*HAVE_TIFF*/

View File

@ -31,40 +31,19 @@
#ifndef VIPS_TIFF_H
#define VIPS_TIFF_H
#include <tiffio.h>
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
extern const char *vips__foreign_tiff_suffs[];
TIFF *vips__tiff_openout( const char *path, gboolean bigtiff );
TIFF *vips__tiff_openin( const char *path );
void vips__tiff_init( void );
int vips__tiff_write( VipsImage *in, const char *filename,
VipsForeignTiffCompression compression, int Q,
VipsForeignTiffPredictor predictor,
char *profile,
gboolean tile, int tile_width, int tile_height,
gboolean pyramid,
gboolean squash,
gboolean miniswhite,
VipsForeignTiffResunit resunit, double xres, double yres,
gboolean bigtiff,
gboolean rgbjpeg,
gboolean properties,
gboolean strip );
int vips__tiff_read_header( const char *filename, VipsImage *out,
int page, gboolean autorotate );
int vips__tiff_read( const char *filename, VipsImage *out,
int page, gboolean autorotate, gboolean readbehind );
gboolean vips__istifftiled( const char *filename );
gboolean vips__istiff_buffer( const void *buf, size_t len );
gboolean vips__istiff( const char *filename );
int vips__tiff_read_header_buffer( const void *buf, size_t len, VipsImage *out,
int page, gboolean autorotate );
int vips__tiff_read_buffer( const void *buf, size_t len, VipsImage *out,
int page, gboolean autorotate, gboolean readbehind );
TIFF *vips__tiff_openin_buffer( VipsImage *image,
const void *data, size_t length );
TIFF *vips__tiff_openout_buffer( VipsImage *image,
gboolean bigtiff, void **out_data, size_t *out_length );
#ifdef __cplusplus
}

View File

@ -215,8 +215,7 @@
#include <vips/internal.h>
#include <vips/thread.h>
#include <tiffio.h>
#include "pforeign.h"
#include "tiff.h"
/* Scanline-type process function.
@ -231,8 +230,6 @@ typedef struct _ReadTiff {
/* Parameters.
*/
char *filename;
const void *buf;
size_t len;
VipsImage *out;
int page;
gboolean autorotate;
@ -282,35 +279,6 @@ typedef struct _ReadTiff {
tdata_t contig_buf;
} ReadTiff;
/* Handle TIFF errors here. Shared with vips2tiff.c. These can be called from
* more than one thread, but vips_error and vips_warn have mutexes in, so that's
* OK.
*/
static void
vips__thandler_error( const char *module, const char *fmt, va_list ap )
{
vips_verror( module, fmt, ap );
}
static void
vips__thandler_warning( const char *module, const char *fmt, va_list ap )
{
char buf[256];
vips_vsnprintf( buf, 256, fmt, ap );
vips_warn( module, "%s", buf );
}
/* Call this during startup. Other libraries may be using libtiff and we want
* to capture any messages they send as well.
*/
void
vips__tiff_init( void )
{
TIFFSetErrorHandler( vips__thandler_error );
TIFFSetWarningHandler( vips__thandler_warning );
}
/* Test for field exists.
*/
static int
@ -1829,8 +1797,6 @@ readtiff_new( VipsImage *out,
return( NULL );
rtiff->filename = NULL;
rtiff->buf = NULL;
rtiff->len = 0;
rtiff->out = out;
rtiff->page = page;
rtiff->autorotate = autorotate;
@ -1858,10 +1824,6 @@ readtiff_new( VipsImage *out,
return( rtiff );
}
/* Can't declare this in tiff.h, we need that to be TIFF-free.
*/
TIFF *vips__tiff_openin( const char *name );
static ReadTiff *
readtiff_new_filename( const char *filename, VipsImage *out,
int page, gboolean autorotate, gboolean readbehind )
@ -1894,86 +1856,6 @@ readtiff_new_filename( const char *filename, VipsImage *out,
return( rtiff );
}
static tsize_t
my_tiff_read( thandle_t st, tdata_t buffer, tsize_t size )
{
ReadTiff *rtiff = (ReadTiff *) st;
size_t available;
size_t copy;
if( rtiff->pos > rtiff->len ) {
vips_error( "tiff2vips",
"%s", _( "read beyond end of buffer" ) );
return( 0 );
}
available = rtiff->len - rtiff->pos;
copy = VIPS_MIN( size, available );
memcpy( buffer, (unsigned char *) rtiff->buf + rtiff->pos, copy );
rtiff->pos += copy;
return( copy );
}
static tsize_t
my_tiff_write( thandle_t st, tdata_t buffer, tsize_t size )
{
g_assert_not_reached();
return( 0 );
}
static int
my_tiff_close( thandle_t st )
{
return 0;
}
/* After calling this, ->pos is not bound by the size of the buffer, it can
* have any positive value.
*/
static toff_t
my_tiff_seek( thandle_t st, toff_t pos, int whence )
{
ReadTiff *rtiff = (ReadTiff *) st;
if( whence == SEEK_SET )
rtiff->pos = pos;
else if( whence == SEEK_CUR )
rtiff->pos += pos;
else if( whence == SEEK_END )
rtiff->pos = rtiff->len + pos;
else
g_assert_not_reached();
return( rtiff->pos );
}
static toff_t
my_tiff_size( thandle_t st )
{
ReadTiff *rtiff = (ReadTiff *) st;
return( rtiff->len );
}
static int
my_tiff_map( thandle_t st, tdata_t *start, toff_t *len )
{
g_assert_not_reached();
return 0;
}
static void
my_tiff_unmap( thandle_t st, tdata_t start, toff_t len )
{
g_assert_not_reached();
return;
}
static ReadTiff *
readtiff_new_buffer( const void *buf, size_t len, VipsImage *out,
int page, gboolean autorotate, gboolean readbehind )
@ -1984,17 +1866,8 @@ readtiff_new_buffer( const void *buf, size_t len, VipsImage *out,
if( !(rtiff = readtiff_new( out, page, autorotate, readbehind )) )
return( NULL );
rtiff->buf = buf;
rtiff->len = len;
if( !(rtiff->tiff = TIFFClientOpen( "memory buffer", "rm",
(thandle_t) rtiff,
my_tiff_read, my_tiff_write, my_tiff_seek, my_tiff_close,
my_tiff_size, my_tiff_map, my_tiff_unmap )) ) {
vips_error( "tiff2vips", "%s",
_( "unable to open memory buffer for input" ) );
if( !(rtiff->tiff = vips__tiff_openin_buffer( out, buf, len )) )
return( NULL );
}
for( i = 0; i < page; i++ )
if( !TIFFReadDirectory( rtiff->tiff ) ) {

View File

@ -48,9 +48,9 @@
#include <vips/buf.h>
#include <vips/internal.h>
#ifdef HAVE_TIFF
#include "pforeign.h"
#include "tiff.h"
#ifdef HAVE_TIFF
typedef struct _VipsForeignLoadTiff {
VipsForeignLoad parent_object;

View File

@ -56,6 +56,8 @@
#include <vips/vips.h>
#include <vips/internal.h>
#include "pforeign.h"
#ifdef HAVE_TIFF
#include "tiff.h"
@ -63,10 +65,6 @@
typedef struct _VipsForeignSaveTiff {
VipsForeignSave parent_object;
/* Filename for save.
*/
char *filename;
/* Many options argh.
*/
VipsForeignTiffCompression compression;
@ -89,7 +87,7 @@ typedef struct _VipsForeignSaveTiff {
typedef VipsForeignSaveClass VipsForeignSaveTiffClass;
G_DEFINE_TYPE( VipsForeignSaveTiff, vips_foreign_save_tiff,
G_DEFINE_ABSTRACT_TYPE( VipsForeignSaveTiff, vips_foreign_save_tiff,
VIPS_TYPE_FOREIGN_SAVE );
#define UC VIPS_FORMAT_UCHAR
@ -156,20 +154,6 @@ vips_foreign_save_tiff_build( VipsObject *object )
tiff->yres *= 2.54;
}
if( vips__tiff_write( save->ready, tiff->filename,
tiff->compression, tiff->Q, tiff->predictor,
tiff->profile,
tiff->tile, tiff->tile_width, tiff->tile_height,
tiff->pyramid,
tiff->squash,
tiff->miniswhite,
tiff->resunit, tiff->xres, tiff->yres,
tiff->bigtiff,
tiff->rgbjpeg,
tiff->properties,
save->strip ) )
return( -1 );
return( 0 );
}
@ -184,7 +168,7 @@ vips_foreign_save_tiff_class_init( VipsForeignSaveTiffClass *class )
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
object_class->nickname = "tiffsave";
object_class->nickname = "tiffsave_base";
object_class->description = _( "save image to tiff file" );
object_class->build = vips_foreign_save_tiff_build;
@ -193,13 +177,6 @@ vips_foreign_save_tiff_class_init( VipsForeignSaveTiffClass *class )
save_class->saveable = VIPS_SAVEABLE_ANY;
save_class->coding[VIPS_CODING_LABQ] = TRUE;
VIPS_ARG_STRING( class, "filename", 1,
_( "Filename" ),
_( "Filename to save to" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsForeignSaveTiff, filename ),
NULL );
VIPS_ARG_ENUM( class, "compression", 6,
_( "Compression" ),
_( "Compression for this file" ),
@ -329,6 +306,146 @@ vips_foreign_save_tiff_init( VipsForeignSaveTiff *tiff )
tiff->yres = 1.0;
}
typedef struct _VipsForeignSaveTiffFile {
VipsForeignSaveTiff parent_object;
char *filename;
} VipsForeignSaveTiffFile;
typedef VipsForeignSaveTiffClass VipsForeignSaveTiffFileClass;
G_DEFINE_TYPE( VipsForeignSaveTiffFile, vips_foreign_save_tiff_file,
vips_foreign_save_tiff_get_type() );
static int
vips_foreign_save_tiff_file_build( VipsObject *object )
{
VipsForeignSave *save = (VipsForeignSave *) object;
VipsForeignSaveTiff *tiff = (VipsForeignSaveTiff *) object;
VipsForeignSaveTiffFile *file = (VipsForeignSaveTiffFile *) object;
if( VIPS_OBJECT_CLASS( vips_foreign_save_tiff_file_parent_class )->
build( object ) )
return( -1 );
if( vips__tiff_write( save->ready, file->filename,
tiff->compression, tiff->Q, tiff->predictor,
tiff->profile,
tiff->tile, tiff->tile_width, tiff->tile_height,
tiff->pyramid,
tiff->squash,
tiff->miniswhite,
tiff->resunit, tiff->xres, tiff->yres,
tiff->bigtiff,
tiff->rgbjpeg,
tiff->properties,
save->strip ) )
return( -1 );
return( 0 );
}
static void
vips_foreign_save_tiff_file_class_init( VipsForeignSaveTiffFileClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *object_class = (VipsObjectClass *) class;
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
object_class->nickname = "tiffsave";
object_class->description = _( "save image to tiff file" );
object_class->build = vips_foreign_save_tiff_file_build;
VIPS_ARG_STRING( class, "filename", 1,
_( "Filename" ),
_( "Filename to save to" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsForeignSaveTiffFile, filename ),
NULL );
}
static void
vips_foreign_save_tiff_file_init( VipsForeignSaveTiffFile *file )
{
}
typedef struct _VipsForeignSaveTiffBuffer {
VipsForeignSaveTiff parent_object;
VipsArea *buf;
} VipsForeignSaveTiffBuffer;
typedef VipsForeignSaveTiffClass VipsForeignSaveTiffBufferClass;
G_DEFINE_TYPE( VipsForeignSaveTiffBuffer, vips_foreign_save_tiff_buffer,
vips_foreign_save_tiff_get_type() );
static int
vips_foreign_save_tiff_buffer_build( VipsObject *object )
{
VipsForeignSave *save = (VipsForeignSave *) object;
VipsForeignSaveTiff *tiff = (VipsForeignSaveTiff *) object;
void *obuf;
size_t olen;
VipsBlob *blob;
if( VIPS_OBJECT_CLASS( vips_foreign_save_tiff_buffer_parent_class )->
build( object ) )
return( -1 );
if( vips__tiff_write_buf( save->ready, &obuf, &olen,
tiff->compression, tiff->Q, tiff->predictor,
tiff->profile,
tiff->tile, tiff->tile_width, tiff->tile_height,
tiff->pyramid,
tiff->squash,
tiff->miniswhite,
tiff->resunit, tiff->xres, tiff->yres,
tiff->bigtiff,
tiff->rgbjpeg,
tiff->properties,
save->strip ) )
return( -1 );
/* vips__tiff_write_buf() makes a buffer that needs g_free(), not
* vips_free().
*/
blob = vips_blob_new( (VipsCallbackFn) g_free, obuf, olen );
g_object_set( object, "buffer", blob, NULL );
vips_area_unref( VIPS_AREA( blob ) );
return( 0 );
}
static void
vips_foreign_save_tiff_buffer_class_init( VipsForeignSaveTiffBufferClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *object_class = (VipsObjectClass *) class;
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
object_class->nickname = "tiffsave_buffer";
object_class->description = _( "save image to tiff buffer" );
object_class->build = vips_foreign_save_tiff_buffer_build;
VIPS_ARG_BOXED( class, "buffer", 1,
_( "Buffer" ),
_( "Buffer to save to" ),
VIPS_ARGUMENT_REQUIRED_OUTPUT,
G_STRUCT_OFFSET( VipsForeignSaveTiffBuffer, buf ),
VIPS_TYPE_BLOB );
}
static void
vips_foreign_save_tiff_buffer_init( VipsForeignSaveTiffBuffer *buffer )
{
}
#endif /*HAVE_TIFF*/
/**
@ -440,3 +557,67 @@ vips_tiffsave( VipsImage *in, const char *filename, ... )
return( result );
}
/**
* vips_tiffsave_buffer:
* @in: image to save
* @buf: return output buffer here
* @len: return output length here
* @...: %NULL-terminated list of optional named arguments
*
* Optional arguments:
*
* * @compression: use this #VipsForeignTiffCompression
* * @Q: %gint quality factor
* * @predictor: use this #VipsForeignTiffPredictor
* * @profile: filename of ICC profile to attach
* * @tile: set %TRUE to write a tiled tiff
* * @tile_width: %gint for tile size
* * @tile_height: %gint for tile size
* * @pyramid: set %TRUE to write an image pyramid
* * @squash: set %TRUE to squash 8-bit images down to 1 bit
* * @miniswhite: set %TRUE to write 1-bit images as MINISWHITE
* * @resunit: #VipsForeignTiffResunit for resolution unit
* * @xres: %gdouble horizontal resolution in pixels/mm
* * @yres: %gdouble vertical resolution in pixels/mm
* * @bigtiff: set %TRUE to write a BigTiff file
* * @properties: set %TRUE to write an IMAGEDESCRIPTION tag
* * @strip: set %TRUE to block metadata save
*
* As vips_tiffsave(), but save to a memory buffer.
*
* The address of the buffer is returned in @buf, the length of the buffer in
* @len. You are responsible for freeing the buffer with g_free() when you
* are done with it.
*
* See also: vips_tiffsave(), vips_image_write_to_file().
*
* Returns: 0 on success, -1 on error.
*/
int
vips_tiffsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
{
va_list ap;
VipsArea *area;
int result;
area = NULL;
va_start( ap, len );
result = vips_call_split( "tiffsave_buffer", ap, in, &area );
va_end( ap );
if( !result &&
area ) {
if( buf ) {
*buf = area->data;
area->free_fn = NULL;
}
if( len )
*len = area->length;
vips_area_unref( area );
}
return( result );
}

View File

@ -131,6 +131,8 @@
#include <vips/vips.h>
#include <vips/debug.h>
#include "pforeign.h"
#ifdef HAVE_EXIF
#ifdef UNTAGGED_EXIF
#include <exif-data.h>
@ -146,7 +148,6 @@
#endif /*HAVE_EXIF*/
#include "jpeg.h"
#include "vipsjpeg.h"
/* New output message method - send to VIPS.
*/

View File

@ -166,6 +166,8 @@
* - tag alpha as UNASSALPHA since it's not pre-multiplied, thanks Peter
* 17/8/16
* - use wchar_t TIFFOpen on Windows
* 14/10/16
* - add buffer output
*/
/*
@ -218,8 +220,7 @@
#include <vips/vips.h>
#include <vips/internal.h>
#include <tiffio.h>
#include "pforeign.h"
#include "tiff.h"
/* Max number of alpha channels we allow.
@ -234,9 +235,17 @@ typedef struct _Write Write;
struct _Layer {
Write *write; /* Main write struct */
/* The filename for this layer, for file output.
*/
char *lname;
/* The memory area for this layer, for memory output.
*/
void *buf;
size_t len;
int width, height; /* Layer size */
int sub; /* Subsample factor for this layer */
char *lname; /* Name of this TIFF file */
TIFF *tif; /* TIFF file we write this layer to */
/* The image we build. We only keep a few scanlines of this around in
@ -263,8 +272,16 @@ struct _Layer {
*/
struct _Write {
VipsImage *im; /* Original input image */
/* File to write to, or NULL.
*/
char *filename; /* Name we write to */
/* Memory area to output, or NULL.
*/
void **obuf;
size_t *olen;
Layer *layer; /* Top of pyramid */
VipsPel *tbuf; /* TIFF output buffer */
int tls; /* Tile line size */
@ -287,94 +304,6 @@ struct _Write {
int strip; /* Don't write metadata */
};
/* Open TIFF for output.
*/
TIFF *
vips__tiff_openout( const char *path, gboolean bigtiff )
{
TIFF *tif;
const char *mode = bigtiff ? "w8" : "w";
#ifdef DEBUG
printf( "vips__tiff_openout( \"%s\", \"%s\" )\n", path, mode );
#endif /*DEBUG*/
/* Need the utf-16 version on Windows.
*/
#ifdef OS_WIN32
{
GError *error = NULL;
wchar_t *path16;
if( !(path16 = (wchar_t *)
g_utf8_to_utf16( path, -1, NULL, NULL, &error )) ) {
vips_g_error( &error );
return( NULL );
}
tif = TIFFOpenW( path16, mode );
g_free( path16 );
}
#else /*!OS_WIN32*/
tif = TIFFOpen( path, mode );
#endif /*OS_WIN32*/
if( !tif ) {
vips_error( "tiff",
_( "unable to open \"%s\" for output" ), path );
return( NULL );
}
return( tif );
}
/* Open TIFF for input.
*/
TIFF *
vips__tiff_openin( const char *path )
{
/* No mmap --- no performance advantage with libtiff, and it burns up
* our VM if the tiff file is large.
*/
const char *mode = "rm";
TIFF *tif;
#ifdef DEBUG
printf( "vips__tiff_openin( \"%s\" )\n", path );
#endif /*DEBUG*/
/* Need the utf-16 version on Windows.
*/
#ifdef OS_WIN32
{
GError *error = NULL;
wchar_t *path16;
if( !(path16 = (wchar_t *)
g_utf8_to_utf16( path, -1, NULL, NULL, &error )) ) {
vips_g_error( &error );
return( NULL );
}
tif = TIFFOpenW( path16, mode );
g_free( path16 );
}
#else /*!OS_WIN32*/
tif = TIFFOpen( path, mode );
#endif /*OS_WIN32*/
if( !tif ) {
vips_error( "tiff",
_( "unable to open \"%s\" for input" ), path );
return( NULL );
}
return( tif );
}
static Layer *
pyramid_new( Write *write, Layer *above, int width, int height )
{
@ -393,6 +322,8 @@ pyramid_new( Write *write, Layer *above, int width, int height )
layer->sub = above->sub * 2;
layer->lname = NULL;
layer->buf = NULL;
layer->len = 0;
layer->tif = NULL;
layer->image = NULL;
layer->write_y = 0;
@ -414,15 +345,18 @@ pyramid_new( Write *write, Layer *above, int width, int height )
* We need lname to be freed automatically: it has to stay
* alive until after write_gather().
*/
if( !above )
layer->lname = vips_strdup( VIPS_OBJECT( write->im ),
write->filename );
else {
char *lname;
if( write->filename ) {
if( !above )
layer->lname = vips_strdup( VIPS_OBJECT( write->im ),
write->filename );
else {
char *lname;
lname = vips__temp_name( "%s.tif" );
layer->lname = vips_strdup( VIPS_OBJECT( write->im ), lname );
g_free( lname );
lname = vips__temp_name( "%s.tif" );
layer->lname =
vips_strdup( VIPS_OBJECT( write->im ), lname );
g_free( lname );
}
}
return( layer );
@ -805,9 +739,17 @@ pyramid_fill( Write *write )
if( vips_region_buffer( layer->strip, &strip_size ) )
return( -1 );
if( !(layer->tif =
vips__tiff_openout( layer->lname, write->bigtiff )) ||
write_tiff_header( write, layer ) )
if( layer->lname )
layer->tif = vips__tiff_openout(
layer->lname, write->bigtiff );
else {
layer->tif = vips__tiff_openout_buffer( write->im,
write->bigtiff, &layer->buf, &layer->len );
}
if( !layer->tif )
return( -1 );
if( write_tiff_header( write, layer ) )
return( -1 );
}
@ -829,6 +771,7 @@ write_delete_temps( Write *write )
if( layer->lname ) {
#ifndef DEBUG
unlink( layer->lname );
VIPS_FREE( layer->buf );
#else
printf( "write_delete_temps: leaving %s\n",
layer->lname );
@ -846,7 +789,6 @@ layer_free( Layer *layer )
VIPS_UNREF( layer->strip );
VIPS_UNREF( layer->copy );
VIPS_UNREF( layer->image );
VIPS_FREEF( TIFFClose, layer->tif );
}
@ -920,9 +862,9 @@ get_resunit( VipsForeignTiffResunit resunit )
/* Make and init a Write.
*/
static Write *
write_new( VipsImage *im, const char *filename,
write_new( VipsImage *im, const char *filename,
VipsForeignTiffCompression compression, int Q,
VipsForeignTiffPredictor predictor,
VipsForeignTiffPredictor predictor,
char *profile,
gboolean tile, int tile_width, int tile_height,
gboolean pyramid,
@ -939,7 +881,8 @@ write_new( VipsImage *im, const char *filename,
if( !(write = VIPS_NEW( im, Write )) )
return( NULL );
write->im = im;
write->filename = vips_strdup( VIPS_OBJECT( im ), filename );
write->filename = filename ?
vips_strdup( VIPS_OBJECT( im ), filename ) : NULL;
write->layer = NULL;
write->tbuf = NULL;
write->compression = get_compression( compression );
@ -1687,7 +1630,7 @@ vips__tiff_write( VipsImage *in, const char *filename,
/* Make output image.
*/
if( !(write = write_new( in, filename,
if( !(write = write_new( in, filename,
compression, Q, predictor, profile,
tile, tile_width, tile_height, pyramid, squash,
miniswhite, resunit, xres, yres, bigtiff, rgbjpeg,
@ -1723,4 +1666,80 @@ vips__tiff_write( VipsImage *in, const char *filename,
return( 0 );
}
int
vips__tiff_write_buf( VipsImage *in,
void **obuf, size_t *olen,
VipsForeignTiffCompression compression, int Q,
VipsForeignTiffPredictor predictor,
char *profile,
gboolean tile, int tile_width, int tile_height,
gboolean pyramid,
gboolean squash,
gboolean miniswhite,
VipsForeignTiffResunit resunit, double xres, double yres,
gboolean bigtiff,
gboolean rgbjpeg,
gboolean properties, gboolean strip )
{
Write *write;
vips__tiff_init();
if( vips_check_coding_known( "vips2tiff", in ) )
return( -1 );
/* Make output image.
*/
if( !(write = write_new( in, NULL,
compression, Q, predictor, profile,
tile, tile_width, tile_height, pyramid, squash,
miniswhite, resunit, xres, yres, bigtiff, rgbjpeg,
properties, strip )) )
return( -1 );
write->obuf = obuf;
write->olen = olen;
if( vips_sink_disc( write->im, write_strip, write ) ) {
write_free( write );
return( -1 );
}
if( !TIFFWriteDirectory( write->layer->tif ) )
return( -1 );
if( write->pyramid ) {
/* Free lower pyramid resources ... this will TIFFClose() (but
* not delete) the smaller layers ready for us to read from
* them again.
*/
if( write->layer->below )
pyramid_free( write->layer->below );
/* Append smaller layers to the main file.
*/
if( write_gather( write ) ) {
write_free( write );
return( -1 );
}
}
/* Now close the top layer, and we'll get a pointer we can return
* to our caller.
*/
TIFFClose( write->layer->tif );
write->layer->tif = NULL;
*obuf = write->layer->buf;
*olen = write->layer->len;
/* Now our caller owns it, we must not free it.
*/
write->layer->buf = NULL;
write_free( write );
return( 0 );
}
#endif /*HAVE_TIFF*/

View File

@ -52,9 +52,9 @@
#include <vips/vips.h>
#include <webp/encode.h>
#include "pforeign.h"
#include "webp.h"
#include <webp/encode.h>
typedef int (*webp_import)( WebPPicture *picture,
const uint8_t *rgb, int stride );

View File

@ -1,64 +0,0 @@
/* simple interface to our jpg functions
*/
/*
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
*/
#ifndef VIPS_VIPSJPEG_H
#define VIPS_VIPSJPEG_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
extern const char *vips__jpeg_suffs[];
int vips__jpeg_write_file( VipsImage *in,
const char *filename, int Q, const char *profile,
gboolean optimize_coding, gboolean progressive, gboolean strip,
gboolean no_subsample, gboolean trellis_quant,
gboolean overshoot_deringing, gboolean optimize_scans, int quant_table );
int vips__jpeg_write_buffer( VipsImage *in,
void **obuf, size_t *olen, int Q, const char *profile,
gboolean optimize_coding, gboolean progressive, gboolean strip,
gboolean no_subsample, gboolean trellis_quant,
gboolean overshoot_deringing, gboolean optimize_scans, int quant_table );
int vips__isjpeg_buffer( const void *buf, size_t len );
int vips__isjpeg( const char *filename );
int vips__jpeg_read_file( const char *name, VipsImage *out,
gboolean header_only, int shrink, gboolean fail, gboolean readbehind,
gboolean autorotate );
int vips__jpeg_read_buffer( const void *buf, size_t len, VipsImage *out,
gboolean header_only, int shrink, int fail, gboolean readbehind,
gboolean autorotate );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_VIPSJPEG_H*/

View File

@ -107,9 +107,9 @@
#include <vips/internal.h>
#include <vips/debug.h>
#include <png.h>
#include "pforeign.h"
#include "vipspng.h"
#include <png.h>
#if PNG_LIBPNG_VER < 10003
#error "PNG library too old."
@ -1003,7 +1003,7 @@ write_grow( Write *write, size_t grow_len )
write->alloc = VIPS_MAX( proposed_alloc, new_len );
/* Our result mujst be freedd with g_free(), so it's OK to use
/* Our result must be freedd with g_free(), so it's OK to use
* g_realloc().
*/
write->buf = g_realloc( write->buf, write->alloc );

View File

@ -1,60 +0,0 @@
/* common defs for png read/write
*/
/*
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
*/
#ifndef VIPS_PNG_H
#define VIPS_PNG_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
int vips__png_header( const char *name, VipsImage *out );
int vips__png_read( const char *name, VipsImage *out, gboolean readbehind );
gboolean vips__png_ispng_buffer( const void *buf, size_t len );
int vips__png_ispng( const char *filename );
gboolean vips__png_isinterlaced( const char *filename );
extern const char *vips__png_suffs[];
int vips__png_read_buffer( const void *buffer, size_t length,
VipsImage *out, gboolean readbehind );
int vips__png_header_buffer( const void *buffer, size_t length,
VipsImage *out );
int vips__png_write( VipsImage *in, const char *filename,
int compress, int interlace, const char *profile,
VipsForeignPngFilter filter, gboolean strip );
int vips__png_write_buf( VipsImage *in,
void **obuf, size_t *olen, int compression, int interlace,
const char *profile, VipsForeignPngFilter filter, gboolean strip );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_PNG_H*/

View File

@ -1,64 +0,0 @@
/* common defs for webp read/write
*/
/*
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
*/
#ifndef VIPS_WEBP_H
#define VIPS_WEBP_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
extern const char *vips__webp_suffs[];
int vips__iswebp_buffer( const void *buf, size_t len );
int vips__iswebp( const char *filename );
int vips__webp_read_file_header( const char *name, VipsImage *out, int shrink );
int vips__webp_read_file( const char *name, VipsImage *out, int shrink );
int vips__webp_read_buffer_header( const void *buf, size_t len,
VipsImage *out, int shrink );
int vips__webp_read_buffer( const void *buf, size_t len,
VipsImage *out, int shrink );
int vips__webp_write_file( VipsImage *out, const char *filename,
int Q, gboolean lossless, VipsForeignWebpPreset preset,
gboolean smart_subsample, gboolean near_lossless,
int alpha_q );
int vips__webp_write_buffer( VipsImage *out, void **buf, size_t *len,
int Q, gboolean lossless, VipsForeignWebpPreset preset,
gboolean smart_subsample, gboolean near_lossless,
int alpha_q );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_WEBP_H*/

View File

@ -55,7 +55,7 @@
#include <vips/vips.h>
#include <vips/internal.h>
#include "webp.h"
#include "pforeign.h"
/* How many bytes do we need to read from the start of the file to be able to
* validate the header?

View File

@ -47,9 +47,9 @@
#include <vips/vips.h>
#ifdef HAVE_LIBWEBP
#include "pforeign.h"
#include "webp.h"
#ifdef HAVE_LIBWEBP
typedef struct _VipsForeignLoadWebp {
VipsForeignLoad parent_object;

View File

@ -45,9 +45,9 @@
#include <vips/vips.h>
#ifdef HAVE_LIBWEBP
#include "pforeign.h"
#include "webp.h"
#ifdef HAVE_LIBWEBP
typedef struct _VipsForeignSaveWebp {
VipsForeignSave parent_object;

View File

@ -249,6 +249,7 @@ class TestForeign(unittest.TestCase):
self.file_loader("tiffload", self.tiff_file, tiff_valid)
self.buffer_loader("tiffload_buffer", self.tiff_file, tiff_valid)
self.save_load_buffer("tiffsave_buffer", "tiffload_buffer", self.colour)
self.save_load("%s.tif", self.mono)
self.save_load("%s.tif", self.colour)
self.save_load("%s.tif", self.cmyk)