|
@@ -53,7 +53,7 @@ var funcmap = template.FuncMap{
|
|
|
},
|
|
|
}
|
|
|
|
|
|
-func convertPDFToPNG(filename string) error {
|
|
|
+func convertPDFToBMP(filename string) error {
|
|
|
out, err := exec.Command("pdftoppm", filename, "./data/screen", "-png").CombinedOutput()
|
|
|
if string(out) != "" {
|
|
|
return fmt.Errorf("pdftoppm: %s", string(out))
|
|
@@ -61,6 +61,20 @@ func convertPDFToPNG(filename string) error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
+ out, err = exec.Command("convert", "./data/screen-1.png",
|
|
|
+ "-rotate", "-90",
|
|
|
+ "-resize", "800x480!",
|
|
|
+ "-dither", "none",
|
|
|
+ "-remap", "./data/palette.gif",
|
|
|
+ "BMP3:./data/screen.bmp",
|
|
|
+ ).CombinedOutput()
|
|
|
+ if string(out) != "" {
|
|
|
+ return fmt.Errorf("covert: %s", string(out))
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
@@ -93,14 +107,14 @@ func serveScreen(res http.ResponseWriter, req *http.Request) {
|
|
|
panic(err)
|
|
|
}
|
|
|
|
|
|
- log.Println("Converting pdf to png.")
|
|
|
- err = convertPDFToPNG("./data/screen.pdf")
|
|
|
+ log.Println("Converting PDF to monochrome BMP.")
|
|
|
+ err = convertPDFToBMP("./data/screen.pdf")
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
|
|
|
|
log.Println("Serving screen.png...")
|
|
|
- http.ServeFile(res, req, "./data/screen-1.png")
|
|
|
+ http.ServeFile(res, req, "./data/screen.bmp")
|
|
|
}
|
|
|
|
|
|
func main() {
|