decker-edu / decker

A markdown based tool for slide deck creation.
GNU General Public License v3.0
55 stars 13 forks source link

Compiling image lineblocks take too long #13

Closed mbotsch closed 1 year ago

mbotsch commented 1 year ago

Given a high-resolution image large.jpg with 2160 × 3840 pixels.

This single-slide deck takes 0.3s to compile:

# This is fast

![](data/image-1.jpg){ height=500px }
![](data/image-2.jpg){ height=500px }

Using line-blocks for image rows, this single-slide deck takes 5.5s to compile:

# This is slow

| ![](data/image-1.jpg){ height=500px }
| ![](data/image-2.jpg){ height=500px }

The line blocks seem to do some computation on the images (detecting width/height?), which are very inefficient, at least on my system (MacOS 12.5, M1 MacBookPro).

@monofon: Is the performance similarly bad on your machine? @salbeira: Can you please test whether it behaves similarly on Linux and Windows?

monofon commented 1 year ago

Who would have guessed. Reading a 138 MB PNG image just to get the size takes 9.3 seconds on my machine. That is rather disappointing ☹️.

Changed the way image size is determined in 84e656c8b8c11eadafe41ad041daab2d16d078b1.

Give it a try.

mbotsch commented 1 year ago

Doesn't compile on my machine:

/Users/botsch/git/decker/src/Text/Decker/Filter/Media.hs:11:1: error:
    Could not load module ‘Conduit’
    It is a member of the hidden package ‘conduit-1.3.4.2’.
    Perhaps you need to add ‘conduit’ to the build-depends in your .cabal file.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
11 | import Conduit (runConduit, runConduitRes, sourceFile, withSourceFile, (.|))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/botsch/git/decker/src/Text/Decker/Filter/Media.hs:13:1: error:
    Could not find module ‘Data.Conduit.ImageSize’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
13 | import Data.Conduit.ImageSize (Size (Size, height, width), sinkImageInfo, sinkImageSize)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Anything special I have to do?

monofon commented 1 year ago

Committer zu blöd Error. Pull again.

mbotsch commented 1 year ago

Much better. Thanks!