X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fgfx2gfx.c;h=67951a1b0c53a33eaa671538d7378b90f4f0d703;hb=a61b92b4ac72cd15ee0f3165f2e7a2f5ac00f156;hp=0a2d4d211b75495012982ee47040d58bc3e94825;hpb=744b018cc664f3e9ff48deb6b56a1b3c51066de6;p=swftools.git diff --git a/src/gfx2gfx.c b/src/gfx2gfx.c index 0a2d4d2..67951a1 100644 --- a/src/gfx2gfx.c +++ b/src/gfx2gfx.c @@ -30,11 +30,15 @@ #include "../../swftools/lib/gfxsource.h" #include "../../swftools/lib/gfxdevice.h" #include "../../swftools/lib/gfxpoly.h" +#include "../../swftools/lib/devices/pdf.h" #include "../../swftools/lib/devices/swf.h" #include "../../swftools/lib/devices/text.h" #include "../../swftools/lib/devices/render.h" +#include "../../swftools/lib/devices/file.h" #include "../../swftools/lib/devices/bbox.h" +#ifdef HAVE_LRF #include "../../swftools/lib/devices/lrf.h" +#endif #include "../../swftools/lib/devices/ocr.h" #include "../../swftools/lib/devices/rescale.h" #include "../../swftools/lib/devices/record.h" @@ -49,7 +53,7 @@ static char * outputname = 0; static int loglevel = 3; static char * pagerange = 0; static char * filename = 0; -static const char * format = "ocr"; +static const char * format = 0; int args_callback_option(char*name,char*val) { if (!strcmp(name, "o")) @@ -200,8 +204,16 @@ int main(int argn, char *argv[]) exit(1); } + if(!format) { + char*x = strrchr(outputname, '.'); + if(x) + format = x+1; + } + + gfxresult_t*result = 0; - if(!strcmp(format, "lrf")) { +#ifdef HAVE_LRF + if(!strcasecmp(format, "lrf")) { gfxdevice_t lrf; gfxdevice_lrf_init(&lrf); @@ -234,17 +246,27 @@ int main(int argn, char *argv[]) } } result = out->finish(out); - } else { + } else +#endif + { gfxdevice_t _out,*out=&_out; - if(!strcmp(format, "ocr")) { + if(!strcasecmp(format, "ocr")) { gfxdevice_ocr_init(out); - } if(!strcmp(format, "swf")) { + } else if(!strcasecmp(format, "swf")) { gfxdevice_swf_init(out); - } if(!strcmp(format, "img")) { + } else if(!strcasecmp(format, "img") || !strcasecmp(format, "png")) { gfxdevice_render_init(out); - } if(!strcmp(format, "txt")) { + out->setparameter(out, "antialize", "4"); + } else if(!strcasecmp(format, "txt")) { gfxdevice_text_init(out); - } + } else if(!strcasecmp(format, "log")) { + gfxdevice_file_init(out, "/tmp/device.log"); + } else if(!strcasecmp(format, "pdf")) { + gfxdevice_pdf_init(out); + } else { + msg(" Invalid output format: %s", format); + exit(1); + } int pagenr; for(pagenr = 1; pagenr <= doc->num_pages; pagenr++)