1 /* vips7 compat stub for vips_dzsave()
2 *
3 * 11/6/13
4 * - from im_vips2tiff()
5 */
6
7 /*
8
9 This file is part of VIPS.
10
11 VIPS is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 02110-1301 USA
25
26 */
27
28 /*
29
30 These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
31
32 */
33
34 /* Turn on IM_REGION_ADDR() range checks, don't delete intermediates.
35 #define DEBUG
36 */
37
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif /*HAVE_CONFIG_H*/
41 #include <vips/intl.h>
42
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <string.h>
46
47 #include <vips/vips.h>
48 #include <vips/vips7compat.h>
49
50 int
im_vips2dz(IMAGE * in,const char * filename)51 im_vips2dz( IMAGE *in, const char *filename )
52 {
53 char *p, *q;
54 char name[FILENAME_MAX];
55 char mode[FILENAME_MAX];
56 char buf[FILENAME_MAX];
57
58 int i;
59 VipsForeignDzLayout layout = VIPS_FOREIGN_DZ_LAYOUT_DZ;
60 char *suffix = ".jpeg";
61 int overlap = 0;
62 int tile_size = 256;
63 VipsForeignDzDepth depth = VIPS_FOREIGN_DZ_DEPTH_ONEPIXEL;
64 gboolean centre = FALSE;
65 VipsAngle angle = VIPS_ANGLE_D0;
66
67 /* We can't use im_filename_split() --- it assumes that we have a
68 * filename with an extension before the ':', and filename here is
69 * actually a dirname.
70 *
71 * Just split on the first ':'.
72 */
73 im_strncpy( name, filename, FILENAME_MAX );
74 if( (p = strchr( name, ':' )) ) {
75 *p = '\0';
76 im_strncpy( mode, p + 1, FILENAME_MAX );
77 }
78 else
79 strcpy( mode, "" );
80
81 strcpy( buf, mode );
82 p = &buf[0];
83
84 if( (q = im_getnextoption( &p )) ) {
85 if( (i = vips_enum_from_nick( "im_vips2dz",
86 VIPS_TYPE_FOREIGN_DZ_LAYOUT, q )) < 0 )
87 return( -1 );
88 layout = i;
89 }
90
91 if( (q = im_getnextoption( &p )) )
92 suffix = g_strdup( q );
93 if( (q = im_getnextoption( &p )) )
94 overlap = atoi( q );
95 if( (q = im_getnextoption( &p )) )
96 tile_size = atoi( q );
97
98 if( (q = im_getnextoption( &p )) ) {
99 if( (i = vips_enum_from_nick( "im_vips2dz",
100 VIPS_TYPE_FOREIGN_DZ_DEPTH, q )) < 0 )
101 return( -1 );
102 depth = i;
103 }
104
105 if( (q = im_getnextoption( &p )) ) {
106 if( im_isprefix( "cen", q ) )
107 centre = TRUE;
108 }
109
110 if( (q = im_getnextoption( &p )) ) {
111 if( (i = vips_enum_from_nick( "im_vips2dz",
112 VIPS_TYPE_ANGLE, q )) < 0 )
113 return( -1 );
114 angle = i;
115 }
116
117 if( vips_dzsave( in, name,
118 "layout", layout,
119 "suffix", suffix,
120 "overlap", overlap,
121 "tile_size", tile_size,
122 "depth", depth,
123 "centre", centre,
124 "angle", angle,
125 NULL ) )
126 return( -1 );
127
128 return( 0 );
129 }
130