php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
gd2topng.c
Go to the documentation of this file.
1
2#include <stdio.h>
3#include "gd.h"
4
5/* A short program which converts a .png file into a .gd file, for
6 your convenience in creating images on the fly from a
7 basis image that must be loaded quickly. The .gd format
8 is not intended to be a general-purpose format. */
9
10int
11main (int argc, char **argv)
12{
13 gdImagePtr im;
14 FILE *in, *out;
15 if (argc != 3)
16 {
17 fprintf (stderr, "Usage: gd2topng filename.gd2 filename.png\n");
18 exit (1);
19 }
20 in = fopen (argv[1], "rb");
21 if (!in)
22 {
23 fprintf (stderr, "Input file does not exist!\n");
24 exit (1);
25 }
26 im = gdImageCreateFromGd2 (in);
27 fclose (in);
28 if (!im)
29 {
30 fprintf (stderr, "Input is not in GD2 format!\n");
31 exit (1);
32 }
33 out = fopen (argv[2], "wb");
34 if (!out)
35 {
36 fprintf (stderr, "Output file cannot be written to!\n");
37 gdImageDestroy (im);
38 exit (1);
39 }
40#ifdef HAVE_LIBPNG
41 gdImagePng (im, out);
42#else
43 fprintf(stderr, "No PNG library support available.\n");
44#endif
45 fclose (out);
46 gdImageDestroy (im);
47
48 return 0;
49}
fprintf($stream, string $format, mixed ... $values)
fclose($stream)
fopen(string $filename, string $mode, bool $use_include_path=false, $context=null)
void gdImagePng(gdImagePtr im, FILE *out)
gdImagePtr gdImageCreateFromGd2(FILE *in)
Definition gd_gd2.c:245
gdImage * gdImagePtr
Definition gd.h:248
int main(void)
Definition gddemo.c:7
void gdImageDestroy(gdImagePtr im)
Definition gd.c:247
exit(string|int $status=0)
out($f, $s)