Does not leverage previous compilations? #38

Open
opened 2024-12-02 02:13:59 +01:00 by Benjamin_Loison · 30 comments
According to:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAQPSbsMCx5LDvUzOCZMu9hfN9FjSIiyJmSuboe68gri4w
RGcJwLCouQEA8opLoZdHJzY72d9NvEaDAQMdhKhHKNzW+iNGI0Kep8m3Q3MTvjD5
1EwBCQIQfIKM9Ydr1BHmLnD1dYxdoLHTRBJknB4RFojfSSDZjmIF9AWYsAXapBmw
R6dpG7Ojf0YgXMQgBcte+n2n5nzbRA/ggfyEn4Do
=SQoP
-----END PGP MESSAGE-----

Journaux et fichiers de sortie > Nettoyer le cache des fichiers does not seem to agree.

<details> <summary>According to:</summary> ``` -----BEGIN PGP MESSAGE----- hF4DTQa9Wom5MBgSAQdAQPSbsMCx5LDvUzOCZMu9hfN9FjSIiyJmSuboe68gri4w RGcJwLCouQEA8opLoZdHJzY72d9NvEaDAQMdhKhHKNzW+iNGI0Kep8m3Q3MTvjD5 1EwBCQIQfIKM9Ydr1BHmLnD1dYxdoLHTRBJknB4RFojfSSDZjmIF9AWYsAXapBmw R6dpG7Ojf0YgXMQgBcte+n2n5nzbRA/ggfyEn4Do =SQoP -----END PGP MESSAGE----- ``` </details> *Journaux et fichiers de sortie* > *Nettoyer le cache des fichiers* does not seem to agree.
Author
Owner
Related to [Improve_websites_thanks_to_open_source/issues/727](https://codeberg.org/Benjamin_Loison/Improve_websites_thanks_to_open_source/issues/727).
Author
Owner

Still compiling on PLMLaTeX after 8 minutes when not in draft.
It seems to have taken about 10 minutes.

With draft mode it takes 9 seconds.

The resolution does not seem to blame but the loseless compression.

Compilation time in seconds of article (as of commit 7c9d421303ca83f287950bc1c05e610e7851dd42):

work laptop PLMLaTeX
draft 0.61 5.20 (8.52x slower)
not draft 117.13 247.61 (2.11x slower)

#40#issuecomment-3599
benjaminloison/kile/issues/24#Bash script to monitor compilations

Should first ensure that actual figures are to blame by generating same resolution but single color images.

if support PNG and JPG then 60.9 MB over 62.7 MB.
So if switch to 1.8 MB, will use 34x less binary data.

DuckDuckGo search Linux generate single color PNG.

Bash script:
for fileExtension in jpg png
do
    convert -size 3840x2160 canvas:#ffff00 image.$fileExtension
done
file image.{jpg,png}
Output:
image.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 3840x2160, components 3
image.png: PNG image data, 3840 x 2160, 1-bit colormap, non-interlaced

works fine to generate a yellow image.

Local not draft is about 0.74 seconds, so this shows that the loseless compression is to blame.

Still compiling on PLMLaTeX after 8 minutes when not in draft. It seems to have taken about 10 minutes. With draft mode it takes 9 seconds. The resolution does not seem to blame but the loseless compression. Compilation time in seconds of article (as of commit `7c9d421303ca83f287950bc1c05e610e7851dd42`): | | work laptop | PLMLaTeX |---------|-------------|----------------------- | draft | 0.61 | 5.20 (8.52x slower) | not draft | 117.13 | 247.61 (2.11x slower) [#40#issuecomment-3599](https://gitea.lemnoslife.com/Benjamin_Loison/overleaf/issues/40#issuecomment-3599) [benjaminloison/kile/issues/24#Bash script to monitor compilations](https://invent.kde.org/benjaminloison/kile/-/issues/24#Bash%20script%20to%20monitor%20compilations) Should first ensure that actual figures are to blame by generating same resolution but single color images. if support PNG and JPG then 60.9 MB over 62.7 MB. So if switch to 1.8 MB, will use 34x less binary data. DuckDuckGo search *Linux generate single color PNG*. <details> <summary>Bash script:</summary> ```bash for fileExtension in jpg png do convert -size 3840x2160 canvas:#ffff00 image.$fileExtension done file image.{jpg,png} ``` </details> <details> <summary>Output:</summary> ``` image.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 3840x2160, components 3 image.png: PNG image data, 3840 x 2160, 1-bit colormap, non-interlaced ``` </details> works fine to generate a yellow image. Local not draft is about 0.74 seconds, so this shows that the loseless compression is to blame.
Author
Owner

Spaces for resolution in -size works fine.

Spaces for resolution in `-size` works fine.
Author
Owner
file *.{png,JPG} | grep -Eo '[0-9]+ *x *[0-9]+'

works fine.

```bash file *.{png,JPG} | grep -Eo '[0-9]+ *x *[0-9]+' ``` works fine.
Author
Owner

Maybe the slowness is due to .svg.

Maybe the slowness is due to `.svg`.
Author
Owner
Bash script:
for file in actual_figures/*.{png,JPG}
do
    #echo $file
    #echo `basename $file`
    convert -size "`file $file | grep -Eo '[0-9]+ *x *[0-9]+'`" canvas:#ffff00 `basename $file`
done

All the generated images are about 13 KB.

<details> <summary>Bash script:</summary> ```bash for file in actual_figures/*.{png,JPG} do #echo $file #echo `basename $file` convert -size "`file $file | grep -Eo '[0-9]+ *x *[0-9]+'`" canvas:#ffff00 `basename $file` done ``` </details> All the generated images are about 13 KB.
Author
Owner

Being able to specify quality as percentage as for JPG convert would be nice, otherwise have to manually compute and enforce such initial file size portion.

DuckDuckGo search Linux convert PNG lossy compress.

Being able to specify quality as percentage as for JPG `convert` would be nice, otherwise have to manually compute and enforce such initial file size portion. DuckDuckGo search *Linux convert PNG lossy compress*.
Author
Owner

https://pngquant.org
pngquant has 5.3k stars.

https://pngquant.org [pngquant](https://github.com/kornelski/pngquant) has 5.3k stars.
Author
Owner

For testing can try generating PNG as .jpg.

Unclear if want to have JPG compression or rescale without rescaling the size used in the article.

Note that rescaling means interpolating.

For testing can try generating PNG as `.jpg`. Unclear if want to have JPG compression or rescale without rescaling the size used in the article. Note that rescaling means interpolating.
Author
Owner

Can append .jpg to ease the JPG compression.

Can append `.jpg` to ease the JPG compression.
Author
Owner
Bash script:
for file in actual_figures/*.png
do
    fileName=`basename $file`
    convert -quality 100 -alpha remove $file $fileName.jpg
    mv $fileName{.jpg,}
done

0.77s of compilation locally with quality 1.

How to have lossy compression while having transparency?

Note that JPG compression is useless for images already being JPG, assuming that all are lossy compressed.

<details> <summary>Bash script:</summary> ```bash for file in actual_figures/*.png do fileName=`basename $file` convert -quality 100 -alpha remove $file $fileName.jpg mv $fileName{.jpg,} done ``` </details> 0.77s of compilation locally with quality 1. How to have lossy compression while having transparency? Note that JPG compression is useless for images already being JPG, assuming that all are lossy compressed.
Author
Owner

0.68s for quality 25.
0.70s for quality 50.
0.72s for quality 75.
0.95s for quality 100.

If less than a second, then it seems fine.

This looks astonishingly fast but the PDF image quality seems to match.

0.68s for quality 25. 0.70s for quality 50. 0.72s for quality 75. 0.95s for quality 100. If less than a second, then it seems fine. This looks astonishingly fast but the PDF image quality seems to match.
Author
Owner

Maybe JPG can be written as is in the PDF contrarily to PNG.

Maybe JPG can be written as is in the PDF contrarily to PNG.
Author
Owner

DuckDuckGo and Google search JPG compression with transparency.

DuckDuckGo and Google search *JPG compression with transparency*.
Author
Owner

Just setting transparency with white would meet my needs.

Just setting transparency with white would meet my needs.
Author
Owner

DuckDuckGo and Google search Linux convert png to jpg with transparent pixels to white.

DuckDuckGo and Google search *Linux convert png to jpg with transparent pixels to white*.
Author
Owner

-background white does not help.

`-background white` does not help.
Author
Owner

Maybe could use an intermediary PNG setting transparency to white.

Maybe could use an intermediary PNG setting transparency to white.
Author
Owner
https://imagemagick.org/script/mogrify.php
Author
Owner

-alpha remove works fine to have white instead of transparency (by default black), source: the Stack Overflow answer 8437562.

`-alpha remove` works fine to have white instead of transparency (by default black), source: [the Stack Overflow answer 8437562](https://stackoverflow.com/a/8437562).
Author
Owner

Now PLMLaTeX compile in 8.09s (that is 14x faster than previously on my laptop and 31x faster than previously on PLMLaTeX).

Now PLMLaTeX compile in 8.09s (that is 14x faster than previously on my laptop and 31x faster than previously on PLMLaTeX).
Author
Owner

Note that previously the PDF was about 81.6 MB and now it is about 84.9 MB. So the PDF size does not seem to matter much.

Note that previously the PDF was about 81.6 MB and now it is about 84.9 MB. So the PDF size does not seem to matter much.
Author
Owner
Related to [Benjamin_Loison/firefox/issues/73](https://codeberg.org/Benjamin_Loison/firefox/issues/73).
Author
Owner

0.85s locally with initial JPG.
3.46s on PLMLaTeX.

That is respectively to #issuecomment-3623 32x and 72x.

0.85s locally with initial JPG. 3.46s on PLMLaTeX. That is respectively to [#issuecomment-3623](#issuecomment-3623) 32x and 72x.
Author
Owner
Related to [Improve_websites_thanks_to_open_source/issues/733#issuecomment-3114463](https://codeberg.org/Benjamin_Loison/Improve_websites_thanks_to_open_source/issues/733#issuecomment-3114463).
Author
Owner

Note that could modify LaTeX code to actually use .jpg instead of .png but as it is a temporary measure in theory let us stick with .png but JPG encoded.

Note that could modify LaTeX code to actually use `.jpg` instead of `.png` but as it is a temporary measure in theory let us stick with `.png` but JPG encoded.
Author
Owner

Specifying svg-inkscape/ to workaround #42 does not seem to involve delay.

Specifying `svg-inkscape/` to workaround #42 does not seem to involve delay.
Author
Owner

I guess that the workload is quite important as it now takes on PLMLaTeX 20 seconds.

I guess that the workload is quite important as it now takes on PLMLaTeX 20 seconds.
Author
Owner

Maybe PNG transparency or only few of the considered PNG are to blame.

Maybe PNG transparency or only few of the considered PNG are to blame.
Author
Owner

Can probably leverage this JPG trick with beamer.

Can probably leverage this JPG trick with `beamer`.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/overleaf#38
No description provided.