0

I made a HTML file with images as base64. I started bash-scripting to make a folders images be base64-printed into this html-file. I worked, I share the code:

cat html_head.txt > fil.html
for i in *.jpg; do echo $(cat html_image_cell_start.txt) "data:image/jpeg;base64, " $(base64 $i) $(cat html_image_cell_end.txt) >> fil.html; done
cat html_foot.txt >> fil.html

But these image files were previously made by resizing (original images) using a script like:

for i in *.jpg; do convert -auto-orient -thumbnail 160 $i thumb-$i; done;

And that worked.

Now I would like to have both steps in one and same loop.

Here's the question: can I pipe the data/image coming from convert to the base64 (linux-)function, instead of saving it to file (thumb-)?

Later, it would be appended to textfile ("html" file).

I would gladly take an answer, that shows this (the loop isn't needed).

Here are the named files, and their content:

html_head.txt

<!doctype html><html><head></head><body>

html_image_cell_start.txt

<img src="

html_image_cell_end.txt

">

html_foot.txt

</body> </html>
Giacomo1968
  • 53,069
  • 19
  • 162
  • 212

1 Answers1

0

Imagemagick commandline

 convert -auto-orient -thumbnail 160 $i jpg:- | base64
Gerard H. Pille
  • 1,346
  • 1
  • 8
  • 8
  • Great! Now I have 3 lines that makes a "thumbs-gallery" when beeing run in a folder with jpeg-images, you want to see? Thanks – Valter Ekholm Dec 15 '20 at 21:06