[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(mgp-users 00143) converting presentations to html...



any plans for supporting anything other than gifs?

the attached patch will let you specify file formats such as jpeg,
png, gif (and may be others), if you've got imagemagick installed.
it's supposed to be an example of functionality, not a polished
product :-)

warning: conversion appears to be MUCH slower :-(

example command line invocation:

  mgp -D directory -z jpeg test.mgp

anything imagemagick can handle, you should be able to pass through
the -z option.

--- mgp.c-dist	Fri Apr  2 16:55:08 1999
+++ mgp.c	Sun Apr  4 20:49:02 1999
@@ -77,6 +77,8 @@
 
 static char *tsfile = NULL;
 static char *dumpdir = NULL;
+/* file format extension -- use what 'convert' from imagemagick uses */
+static char *gformat = NULL;
 
 char *gsdevice = DEFAULT_GSDEV;
 
@@ -202,7 +204,7 @@
 		mgpwdir = p;
 	}
 
-#define ACCEPTOPTS	"BdvVob:c:g:f:hlGp:qt:Q:PST:D:CORw:X:x:n"
+#define ACCEPTOPTS	"BdvVob:c:g:f:hlGp:qt:Q:PST:D:z:CORw:X:x:n"
 	while ((opt = getopt(argc, argv, ACCEPTOPTS)) != -1) {
 #undef ACCEPTOPTS
 		switch (opt) {
@@ -263,6 +265,10 @@
 			tbar_mode = 1;
 			break;
 
+		case 'z':
+		        gformat = optarg;
+                        break;
+
 		case 'Q':
 			b_quality = atoi(optarg);
 			quality_flag = 1;
@@ -404,6 +410,12 @@
 	FILE *txt;
 	int page;
 	char *childdebug;
+        /* hope this works... */
+	char *gr_format = "jpeg";
+
+        if (gformat) {
+	  gr_format = gformat;
+	}
 
 	/* check if we can write to the directory */
 	sprintf(buf, "%s/%ld", dumpdir, (long)time((time_t *)NULL));
@@ -426,20 +438,22 @@
 		draw_page(&state, NULL);
 
 		/*
-		 * dump out gif image
+		 * dump out image (default is jpeg)
 		 */
 		fprintf(stderr, "(full image)");
-		sprintf(buf, "xwintoppm -silent -name MagicPoint | "
-			"ppmquant 256 %s | "
-			"ppmtogif %s > %s/mgp%05d.gif",
-			childdebug, childdebug, dumpdir, page);
+		sprintf(buf, "import -window MagicPoint -colors 256 "
+                             "%s/mgp%05d.%s %s",
+                             dumpdir, page, gr_format, childdebug);
 		system(buf);	/*XXX security hole*/
+                /* there's got to be a better way... */
+                sprintf(buf, "cp %s/mgp%05d.%s %s/mgp%05d.idx.%s %s",
+                             dumpdir, page, gr_format, 
+                             dumpdir, page, gr_format, childdebug);
+                system(buf);    /*XXX security hole -- relative path + usual */
 		fprintf(stderr, "(thumbnail)");
-		sprintf(buf, "giftopnm %s/mgp%05d.gif | "
-			"pnmscale 0.25 | ppmquant 256 %s | "
-			"ppmtogif %s > %s/mgp%05d.idx.gif",
-			dumpdir, page, childdebug, childdebug,
-			dumpdir, page);
+		sprintf(buf, "mogrify -geometry 25%% -colors 256 "
+                             "%s/mgp%05d.idx.%s",
+                             dumpdir, page, gr_format);
 		system(buf);	/*XXX security hole*/
 
 		/*
@@ -474,14 +488,15 @@
 		fprintf(html, "<BR>Page %d: %s<BR>\n", page, page_title(page));
 		fprintf(html, "<HR>\n");
 		if (window_width < 0 || window_height < 0) {
-			fprintf(html, "<IMG SRC=\"mgp%05d.gif\" "
+			fprintf(html, "<IMG SRC=\"mgp%05d.%s\" "
 				"ALT=\"Page %d\">\n",
-				page, page);
+				page, gr_format, 
+                                page);
 		} else {
-			fprintf(html, "<IMG SRC=\"mgp%05d.gif\" "
+			fprintf(html, "<IMG SRC=\"mgp%05d.%s\" "
 				"WIDTH=%d HEIGHT=%d ALT=\"Page %d\"><BR>\n",
-				page, window_width, window_height,
-				page);
+				page, gr_format, 
+                                window_width, window_height, page);
 		}
 		fprintf(html, "<HR>Generated by "
 		    "<A HREF=\"http://www.mew.org/mgp/\";>MagicPoint</A>\n"
@@ -539,16 +554,20 @@
 	for (page = start_page; page <= maxpage; page++) {
 		if (window_width < 0 || window_height < 0) {
 			fprintf(html, "<A HREF=\"mgp%05d.html\">"
-				"<IMG SRC=\"mgp%05d.idx.gif\" "
+				"<IMG SRC=\"mgp%05d.idx.%s\" "
 				"ALT=\"Page %d\"></A>\n",
-				page, page, page);
+				page, 
+                                page, gr_format,
+                                page);
 		} else {
 			fprintf(html, "<A HREF=\"mgp%05d.html\">"
-				"<IMG SRC=\"mgp%05d.idx.gif\" "
+				"<IMG SRC=\"mgp%05d.idx.%s\" "
 				"WIDTH=%d HEIGHT=%d "
 				"ALT=\"Page %d\"></A>\n",
-				page, page, window_width / 4,
-				window_height / 4, page);
+				page,
+                                page, gr_format,
+                                window_width / 4, window_height / 4, 
+                                page);
 		}
 	}
 	fprintf(html, "<HR>\n");