1 /* Write a ppm file.
2  *
3  * 20/12/11
4  * 	- just a compat stub
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 #ifdef HAVE_CONFIG_H
35 #include <config.h>
36 #endif /*HAVE_CONFIG_H*/
37 #include <vips/intl.h>
38 
39 #include <string.h>
40 
41 #include <vips/vips.h>
42 #include <vips/vips7compat.h>
43 
44 int
im_vips2ppm(IMAGE * in,const char * filename)45 im_vips2ppm( IMAGE *in, const char *filename )
46 {
47 	int ascii;
48 	char name[FILENAME_MAX];
49 	char mode[FILENAME_MAX];
50 
51 	/* Default to binary output ... much smaller.
52 	 */
53 	ascii = 0;
54 
55 	/* Extract write mode from filename.
56 	 */
57 	im_filename_split( filename, name, mode );
58 	if( strcmp( mode, "" ) != 0 ) {
59 		if( im_isprefix( "binary", mode ) )
60 			ascii = 0;
61 		else if( im_isprefix( "ascii", mode ) )
62 			ascii = 1;
63 		else {
64 			im_error( "im_vips2ppm",
65 				"%s", _( "bad mode string, "
66 					"should be \"binary\" or \"ascii\"" ) );
67 			return( -1 );
68 		}
69 	}
70 
71 	return( vips_ppmsave( in, name, "ascii", ascii, NULL ) );
72 }
73