Skip to content

Commit a560d7d

Browse files
committed
better vips7 compat
revise the vips7 PNG wrapper to work with libspng, though performance may be poor thanks SkyDiverCool #2233
1 parent 2df5768 commit a560d7d

File tree

4 files changed

+16
-69
lines changed

4 files changed

+16
-69
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
compile
22
.pytest_cache
3+
.dirstamp
34
a.out
45
*.log
56
*.trs

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
30/4/21 start 8.10.7
2+
- better vips7 PNG load compatibility [SkyDiverCool]
3+
14
22/12/20 start 8.10.6
25
- don't seek on bad file descriptors [kleisauke]
36
- check for null memory sources [kleisauke]

configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# also update the version number in the m4 macros below
44

5-
AC_INIT([vips], [8.10.6], [vipsip@jiscmail.ac.uk])
5+
AC_INIT([vips], [8.10.7], [vipsip@jiscmail.ac.uk])
66
# required for gobject-introspection
77
AC_PREREQ(2.62)
88

@@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
1818
# user-visible library versioning
1919
m4_define([vips_major_version], [8])
2020
m4_define([vips_minor_version], [10])
21-
m4_define([vips_micro_version], [6])
21+
m4_define([vips_micro_version], [7])
2222
m4_define([vips_version],
2323
[vips_major_version.vips_minor_version.vips_micro_version])
2424

@@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date -u -r $srcdir/ChangeLog`
3838
# binary interface changes not backwards compatible?: reset age to 0
3939

4040
LIBRARY_CURRENT=54
41-
LIBRARY_REVISION=7
41+
LIBRARY_REVISION=8
4242
LIBRARY_AGE=12
4343

4444
# patched into include/vips/version.h

libvips/deprecated/im_png2vips.c

Lines changed: 9 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -48,82 +48,26 @@
4848

4949
#include "../foreign/pforeign.h"
5050

51-
static int
52-
png2vips( const char *name, IMAGE *out, gboolean header_only )
51+
int
52+
im_png2vips( const char *name, IMAGE *out )
5353
{
5454
char filename[FILENAME_MAX];
5555
char mode[FILENAME_MAX];
56-
char *p, *q;
57-
int seq;
56+
VipsImage *x;
5857

5958
im_filename_split( name, filename, mode );
6059

61-
seq = 0;
62-
p = &mode[0];
63-
if( (q = im_getnextoption( &p )) ) {
64-
if( im_isprefix( "seq", q ) )
65-
seq = 1;
66-
}
67-
68-
/* We need to be compatible with the pre-sequential mode
69-
* im_png2vips(). This returned a "t" if given a "p" image, since it
70-
* used writeline.
71-
*
72-
* If we're writing the image to a "p", switch it to a "t".
73-
*
74-
* Don't do this for header read, since we don't want to force a
75-
* malloc if all we are doing is looking at fields.
76-
*/
77-
78-
if( !header_only &&
79-
!seq &&
80-
out->dtype == VIPS_IMAGE_PARTIAL ) {
81-
if( vips__image_wio_output( out ) )
82-
return( -1 );
83-
}
84-
85-
/* spngload does not define these vips7 compat functions.
86-
*/
87-
#if defined(HAVE_PNG) && !defined(HAVE_SPNG)
88-
{
89-
VipsSource *source;
90-
int result;
91-
92-
if( !(source = vips_source_new_from_file( filename )) )
60+
if( vips_pngload( filename, &x, NULL ) )
9361
return( -1 );
94-
if( header_only )
95-
result = vips__png_header_source( source, out );
96-
else
97-
result = vips__png_read_source( source, out, TRUE );
98-
VIPS_UNREF( source );
99-
100-
if( result )
101-
return( result );
102-
}
103-
#else
104-
vips_error( "im_png2vips",
105-
"%s", _( "no PNG support in your libvips" ) );
106-
107-
return( -1 );
108-
#endif /*HAVE_PNG && !HAVE_SPNG*/
62+
if( vips_image_write( x, out ) ) {
63+
VIPS_UNREF( x );
64+
return( -1 );
65+
}
66+
VIPS_UNREF( x );
10967

11068
return( 0 );
11169
}
11270

113-
int
114-
im_png2vips( const char *name, IMAGE *out )
115-
{
116-
return( png2vips( name, out, FALSE ) );
117-
}
118-
119-
/* By having a separate header func, we get lazy.c to open via disc/mem.
120-
*/
121-
static int
122-
im_png2vips_header( const char *name, IMAGE *out )
123-
{
124-
return( png2vips( name, out, TRUE ) );
125-
}
126-
12771
static int
12872
ispng( const char *filename )
12973
{
@@ -145,7 +89,6 @@ vips_format_png_class_init( VipsFormatPngClass *class )
14589
object_class->description = _( "PNG" );
14690

14791
format_class->is_a = ispng;
148-
format_class->header = im_png2vips_header;
14992
format_class->load = im_png2vips;
15093
format_class->save = im_vips2png;
15194
format_class->suffs = png_suffs;

0 commit comments

Comments
 (0)