main
Federico Poni 8 months ago
parent b135ddb6c6
commit f549b5efb3

@ -179,7 +179,7 @@ css='
width: 70%;
display: block;
}
}"
}
'
# Function to compress and generate HTML links
@ -191,6 +191,7 @@ compress_and_generate_links() {
declare -a text_files
declare -a picture_files
declare -a gif_files
declare -a video_files
declare -a audio_files
declare -a other_files
@ -204,9 +205,9 @@ compress_and_generate_links() {
*.jpg|*.png|*.heic|*.svg|*.JPG|*.PNG|*.HEIC|*.SVG)
picture_files+=("$file")
;;
# |*.gif|*.GIF)
# gif_files+=("$file")
# ;;
*.gif|*.GIF)
gif_files+=("$file")
;;
*.mp4|*.mov|*.mkv|*.avi|*.MP4)
video_files+=("$file")
;;
@ -300,9 +301,9 @@ compress_and_generate_links() {
compressed_file="$folder"/"$compressed_folder/$(basename "$picture_file")_compressed.jpg"
if [ ! -f "$compressed_file" ]; then
if $dither; then
convert "$picture_file" -dither Riemersma -colors $n_colors_dither -quality 85 "$compressed_file"
convert "$picture_file" -dither Riemersma -colors $n_colors_dither -quality 50 -resize 400x "$compressed_file"
else
convert "$picture_file" -quality 85 "$compressed_file"
convert "$picture_file" -quality 50 -resize 400x "$compressed_file"
fi
fi
echo "<div>
@ -312,6 +313,25 @@ compress_and_generate_links() {
done
fi
# Compress and display picture files in the subfolder
if [ ${#gif_files[@]} -gt 0 ]; then
# echo "<div class='pics'>" >> "$index_file"
for gif_file in "${gif_files[@]}"; do
compressed_file="$folder"/"$compressed_folder/$(basename "$gif_file")_compressed.gif"
if [ ! -f "$compressed_file" ]; then
if $dither; then
convert "$gif_file" -dither Riemersma -colors $n_colors_dither -colors 8 -resize 50% "$compressed_file"
else
convert "$gif_file" -colors 8 -resize 50% "$compressed_file"
fi
fi
echo "<div>
<a href="\"/$compressed_file"\"><img loading=\"lazy\" src=\"/$compressed_file\" alt=\"Compressed Image\"></a>
<a href=\"$(basename "$gif_file")\" target=\"_blank\">Original ⇝ $(basename "$gif_file")</a>
</div>" >> "$index_file"
done
fi
# Compress and display video files in the subfolder
if [ ${#video_files[@]} -gt 0 ]; then
# echo "<div class='vids'>" >> "$index_file"

Loading…
Cancel
Save