php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
gdtopng.c
Go to the documentation of this file.
1#include <stdio.h>
2#include "gd.h"
3
4/* A short program which converts a .png file into a .gd file, for
5 your convenience in creating images on the fly from a
6 basis image that must be loaded quickly. The .gd format
7 is not intended to be a general-purpose format. */
8
9int
10main (int argc, char **argv)
11{
12 gdImagePtr im;
13 FILE *in, *out;
14 if (argc != 3)
15 {
16 fprintf (stderr, "Usage: gdtopng filename.gd filename.png\n");
17 exit (1);
18 }
19 in = fopen (argv[1], "rb");
20 if (!in)
21 {
22 fprintf (stderr, "Input file does not exist!\n");
23 exit (1);
24 }
25 im = gdImageCreateFromGd (in);
26 fclose (in);
27 if (!im)
28 {
29 fprintf (stderr, "Input is not in GD format!\n");
30 exit (1);
31 }
32 out = fopen (argv[2], "wb");
33 if (!out)
34 {
35 fprintf (stderr, "Output file cannot be written to!\n");
36 gdImageDestroy (im);
37 exit (1);
38 }
39 gdImagePng (im, out);
40 fclose (out);
41 gdImageDestroy (im);
42
43 return 0;
44}
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 gdImageCreateFromGd(FILE *in)
Definition gd_gd.c:142
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)