Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Created April 16, 2023 15:12
Show Gist options
  • Save BlogBlocks/bf6cba6b10877c0f38a2a3e8b9eea408 to your computer and use it in GitHub Desktop.
Save BlogBlocks/bf6cba6b10877c0f38a2a3e8b9eea408 to your computer and use it in GitHub Desktop.
Replaces a new file called "Untitled.jpeg" with a file using a date-time as a name
#!/bin/bash
# Define the directory containing the images
dir=$(pwd)
# Create the HTML header
cat <<EOF > gallery.html
<!DOCTYPE html>
<html>
<head>
<title>Image Gallery</title>
<style>
.gallery {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
.gallery img {
width: 250px;
height: 250px;
object-fit: cover;
margin: 10px;
}
</style>
</head>
<body>
<p>highly detailed, super sharp image, oil painting of a Beautiful female insect full body half cyborg, half insect full-length portrait| detailed face symmetric steampunk insect cyborg-insect intricate detailed| to scale| hyperrealistic| cinematic lighting art style of H.R. Giger mdjrny-v4 style</p><br/>
<p>full body cyborg| full-length portrait| detailed face| symmetric| steampunk| cyberpunk| cyborg| intricate detailed| to scale| hyperrealistic| cinematic lighting| digital art| concept art| mdjrny-v4 style</p><br />
<a href="https://huggingface.co/Joeythemonster/anything-midjourney-v-4-1" target="_blank">huggingface.co Joeythemonster anything-midjourney-v-4-1</a><br />
<a href="https://huggingface.co/prompthero/openjourney" target="_blank">prompthero_openjourney</a><br />
<div class="gallery"> <hr>
EOF
# Loop through each image in the directory and add it to the gallery
for file in "$dir"/*.jpg; do
echo " <img src=\"$file\">" >> gallery.html
done
# Create the HTML footer
cat <<EOF >> gallery.html
</div>
</body>
</html>
EOF
echo "Gallery created at gallery.html"
#!/bin/bash
# Replace with the directory you want to monitor
folder=/home/jack/Desktop/HDD500/collections/newdownloads/512x512
echo "Monitoring folder ${folder} for new downloads..."
while true; do
inotifywait -q -m -e close_write -r "$folder" | while read -r directory events filename; do
if [ "$filename" = "Untitled.jpeg" ]; then
echo "New download detected: ${filename}"
newfile=$(date +"%Y-%m-%d-%H-%M-%S").jpg
mv "${folder}/${filename}" "${folder}/${newfile}"
sleep 3 # add a 2-second delay before running mogrify
mogrify -resize 1080x1080! -unsharp 0.25x0.25+8+0.065 "${folder}/${newfile}"
echo "File renamed and processed: ${newfile}"
mkgallery.sh
fi
done
done
# Replace with the directory you want to monitor
folder=/home/jack/Desktop/HDD500/collections/newdownloads/512x512
echo "Monitoring folder ${folder} for new downloads..."
while true; do
inotifywait -q -m -e close_write -r "$folder" | while read -r directory events filename; do
if [[ $filename == *.jpeg || $filename == *.jpg ]]; then
echo "New download detected: ${filename}"
newfile=$(date +"%Y-%m-%d-%H-%M-%S").jpg
mv "${folder}/${filename}" "${folder}/${newfile}"
sleep 3 # add a 2-second delay before running mogrify
mogrify -resize 1080x1080! -unsharp 0.25x0.25+8+0.065 "${folder}/${newfile}"
echo "File renamed and processed: ${newfile}"
mkgallery.sh
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment