tikz-gallery-generator

Custum build of stapix for tikz.pablopie.xyz

Commit
1e444b4fa16b3b2dbdb6da8d2e42495222c262c1
Parent
c8c8976a20630694e2fd2f88904e7bec022b6523
Author
Pablo <pablo-pie@riseup.net>
Date

Added TODOs

Also renamed some functions

Diffstats

2 files changed, 23 insertions, 4 deletions

Status Name Changes Insertions Deletions
Modified src/image.rs 2 files changed 8 2
Modified src/main.rs 2 files changed 15 2
diff --git a/src/image.rs b/src/image.rs
@@ -64,7 +64,10 @@ enum PixelBuffer {
 
 /// Parses the Y Cb Cr data from a JPEG, downsampling to fit `TARGET_HEIGHT`
 /// along the way
-pub fn parse_jpeg(path: &Path, target_height: usize) -> Result<Image, ()> {
+pub fn parse_and_downsample_jpeg(
+  path: &Path,
+  target_height: usize,
+) -> Result<Image, ()> {
   let options = DecoderOptions::default()
     .jpeg_set_out_colorspace(ColorSpace::YCbCr);
 
@@ -136,7 +139,10 @@ pub fn parse_jpeg(path: &Path, target_height: usize) -> Result {
 
 /// Parses the Y Cb Cr data from a PNG, downsampling to fit `TARGET_HEIGHT`
 /// along the way
-pub fn parse_png(path: &Path, target_height: usize) -> Result<Image, ()> {
+pub fn parse_and_downsample_png(
+  path: &Path,
+  target_height: usize,
+) -> Result<Image, ()> {
   let options = DecoderOptions::default()
     .png_set_strip_to_8bit(true);
 
diff --git a/src/main.rs b/src/main.rs
@@ -438,6 +438,19 @@ fn render_thumbnail(pic: &GalleryEntry, thumb_path: &Path) -> Result<(), ()> {
 
   match pic.file_format {
     FileFormat::TeX => {
+      // TODO: [optimize]: remove the dependency on tikztosvg?
+      // TODO: [optimize]: use pdflatex instead of lualatex?
+      // TODO: [optimize]: include the packages+TikZ libraries in a per file
+      //                   basis?
+      // TODO: [optimize]: do the PDF -> SVG conversion in house?
+      //
+      //                   you can use poppler+caire as in pdf2svg:
+      //                   https://github.com/dawbarton/pdf2svg/blob/master/pdf2svg.c
+      //
+      //                   you could also try MuPDF, which seems to be more
+      //                   efficient:
+      //                   https://github.com/ArtifexSoftware/mupdf/blob/master/include/mupdf/fitz/output-svg.h
+
       // tikztosvg -o thumb_path
       //           -p relsize
       //           -p xfrac
@@ -482,13 +495,13 @@ fn render_thumbnail(pic: &GalleryEntry, thumb_path: &Path) -> Result<(), ()> {
     FileFormat::Jpeg => {
       // NOTE: even if the picture is no taller than TARGET_HEIGHT * 2, it is
       //       faster to downsample and then encode
-      let img = image::parse_jpeg(&pic.path, TARGET_HEIGHT)?;
+      let img = image::parse_and_downsample_jpeg(&pic.path, TARGET_HEIGHT)?;
       image::encode_webp(&img, thumb_path)?;
     }
     FileFormat::Png => {
       // NOTE: even if the picture is no taller than TARGET_HEIGHT * 2, it is
       //       faster to downsample and then encode
-      let img = image::parse_png(&pic.path, TARGET_HEIGHT)?;
+      let img = image::parse_and_downsample_png(&pic.path, TARGET_HEIGHT)?;
       image::encode_webp(&img, thumb_path)?;
     }
   }