int main() { gdImagePtr im; char path[2048]; FILE *fp; im = gdImageCreateTrueColor(20, 20); if (!im) { return 0; } sprintf(path, "%s/webp/tmpbug00111.webp", GDTEST_TOP_DIR); fp = fopen(path, "wb"); gdImageWebp(im, fp); fclose(fp); unlink(path); gdImageDestroy(im); return 0; }
int main(int argc, char **argv) { gdImagePtr ptr; char* buffer; int size; int res; if (argc<2) { printf("Usage: %s <input_file>\n", argv[0]); return 0; } size = read_file(argv[1], &buffer); if (size <= 0) { return 0; } char ext[6]; res = read_extenstion(buffer, size, ext); if (res < 0) { //printf("ext: %s\n", ext); //printf("extention not correct\n"); exit(0); } switch (res) { case 1: //open png printf("openning png\n"); ptr = gdImageCreateFromPngPtr(size-5, (void *)buffer); break; case 2: //open gif printf("openning gif\n"); ptr = gdImageCreateFromGifPtr(size-5, (void *)buffer); break; case 3: //open jpg printf("openning jpg\n"); ptr = gdImageCreateFromJpegPtr(size-5, (void *)buffer); break; case 4: //open tga printf("openning tga\n"); ptr = gdImageCreateFromTgaPtr(size-5, (void *)buffer); break; case 5: //open tiff printf("openning tiff\n"); ptr = gdImageCreateFromTiffPtr(size-5, (void *)buffer); break; // case 6: // //open webp // printf("openning webp\n"); // exit(0); // //gdImageWebpPtr() // break; default: printf("error!\n"); exit(0); } printf("ptr: %p\n", ptr); //gdImagePtr ptr2; int new_size; FILE *output; output = fopen("/dev/null", "wb"); gdImageWebp(ptr, output); return 0; // char * filename = argv[1]; // printf("opening: %s\n", filename); // FILE *in; // in = fopen(filename, "r"); // if (in!=NULL) // { // im = gdImageCreateFromPng(in); // printf("imageptr: %p\n", im); // } //printf("Main\n"); return 0; }