-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
424 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import argparse | ||
import os | ||
import subprocess | ||
|
||
def create_thumbnail(image_path, thumb_path): | ||
"""Generates a thumbnail for an image using FFmpeg.""" | ||
cmd = [ | ||
'ffmpeg', '-i', image_path, | ||
'-vf', 'scale=w=min(iw\\,375):h=min(ih\\,375):force_original_aspect_ratio=decrease', | ||
'-qscale:v', '2', # Quality scale for JPEG and WebP | ||
thumb_path | ||
] | ||
subprocess.run(cmd, check=True) | ||
|
||
def create_html(directory, images): | ||
"""Creates an index.html file in the specified directory based on the provided images.""" | ||
if not images: | ||
return # Do not create HTML if no images are processed | ||
|
||
html_path = os.path.join(directory, 'index.html') | ||
html_content = [] | ||
html_header = ''' | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Photo Album</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/css/lightgallery.min.css" /> | ||
</head> | ||
<body> | ||
<div id="lightgallery"> | ||
''' | ||
html_footer = ''' | ||
</div> | ||
<script src="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/js/lightgallery.min.js"></script> | ||
<script> | ||
lightGallery(document.getElementById('lightgallery'), { | ||
selector: 'a' | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
''' | ||
|
||
for img, thumb in images: | ||
html_content.append(f''' | ||
<a href="{os.path.relpath(img, start=directory)}"> | ||
<img src="{os.path.relpath(thumb, start=directory)}" alt="Thumbnail of {os.path.basename(img)}" style="max-width:100%;height:auto;"> | ||
</a> | ||
''') | ||
|
||
html_full = html_header + "\n".join(html_content) + html_footer | ||
with open(html_path, 'w') as file: | ||
file.write(html_full) | ||
|
||
def process_directory(directory, recursive, dryrun): | ||
"""Processes a single directory to create thumbnails and an HTML file.""" | ||
images = [] | ||
image_extensions = ['.jpg', '.jpeg', '.png', '.webp'] # Supported image extensions | ||
for filename in os.listdir(directory): | ||
extension = os.path.splitext(filename)[1].lower() | ||
if extension in image_extensions and not filename.startswith("thumb"): | ||
full_image_path = os.path.join(directory, filename) | ||
thumb_filename = f"thumb-375-{filename}" | ||
thumb_path = os.path.join(directory, thumb_filename) | ||
|
||
if not dryrun: | ||
if not os.path.exists(thumb_path): | ||
create_thumbnail(full_image_path, thumb_path) | ||
images.append((full_image_path, thumb_path)) | ||
|
||
if not dryrun: | ||
create_html(directory, images) | ||
else: | ||
for img, thumb in images: | ||
print(f'Will process image: {img}') | ||
print(f'Will create thumbnail: {thumb}') | ||
|
||
def walk_directory(directory, recursive, dryrun): | ||
"""Walks through the directory and processes each directory found.""" | ||
if recursive: | ||
for root, dirs, files in os.walk(directory): | ||
process_directory(root, recursive, dryrun) | ||
else: | ||
process_directory(directory, recursive, dryrun) | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Generate a simple image gallery using FFmpeg, optionally recursively.') | ||
parser.add_argument('directory', type=str, help='Directory containing images to process.') | ||
parser.add_argument('-r', '--recursive', action='store_true', help='Process images recursively in subdirectories.') | ||
parser.add_argument('--dryrun', action='store_true', help='Output the processing steps without creating files.') | ||
|
||
args = parser.parse_args() | ||
walk_directory(args.directory, args.recursive, args.dryrun) | ||
|
||
if __name__ == "__main__": | ||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Photo Album</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/css/lightgallery.min.css" /> | ||
</head> | ||
<body> | ||
<div id="lightgallery"> | ||
|
||
<a href="album-11.jpg"> | ||
<img src="thumb-375-album-11.jpg" alt="Thumbnail of album-11.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-13.jpg"> | ||
<img src="thumb-375-album-13.jpg" alt="Thumbnail of album-13.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-12.jpg"> | ||
<img src="thumb-375-album-12.jpg" alt="Thumbnail of album-12.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
</div> | ||
<script src="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/js/lightgallery.min.js"></script> | ||
<script> | ||
lightGallery(document.getElementById('lightgallery'), { | ||
selector: 'a' | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Photo Album</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/css/lightgallery.min.css" /> | ||
</head> | ||
<body> | ||
<div id="lightgallery"> | ||
|
||
<a href="1_album-2.jpg"> | ||
<img src="thumb-375-1_album-2.jpg" alt="Thumbnail of 1_album-2.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="2_album-5.jpg"> | ||
<img src="thumb-375-2_album-5.jpg" alt="Thumbnail of 2_album-5.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="3_album-4.jpg"> | ||
<img src="thumb-375-3_album-4.jpg" alt="Thumbnail of 3_album-4.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
</div> | ||
<script src="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/js/lightgallery.min.js"></script> | ||
<script> | ||
lightGallery(document.getElementById('lightgallery'), { | ||
selector: 'a' | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Photo Album</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/css/lightgallery.min.css" /> | ||
</head> | ||
<body> | ||
<div id="lightgallery"> | ||
|
||
<a href="1_album-3.jpg"> | ||
<img src="thumb-375-1_album-3.jpg" alt="Thumbnail of 1_album-3.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="2_album-15.jpg"> | ||
<img src="thumb-375-2_album-15.jpg" alt="Thumbnail of 2_album-15.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="3_album-6.jpg"> | ||
<img src="thumb-375-3_album-6.jpg" alt="Thumbnail of 3_album-6.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
</div> | ||
<script src="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/js/lightgallery.min.js"></script> | ||
<script> | ||
lightGallery(document.getElementById('lightgallery'), { | ||
selector: 'a' | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Photo Album</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/css/lightgallery.min.css" /> | ||
</head> | ||
<body> | ||
<div id="lightgallery"> | ||
|
||
<a href="album-9.jpg"> | ||
<img src="thumb-375-album-9.jpg" alt="Thumbnail of album-9.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-8.jpg"> | ||
<img src="thumb-375-album-8.jpg" alt="Thumbnail of album-8.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-16.jpg"> | ||
<img src="thumb-375-album-16.jpg" alt="Thumbnail of album-16.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-17.jpg"> | ||
<img src="thumb-375-album-17.jpg" alt="Thumbnail of album-17.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-15.jpg"> | ||
<img src="thumb-375-album-15.jpg" alt="Thumbnail of album-15.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-14.jpg"> | ||
<img src="thumb-375-album-14.jpg" alt="Thumbnail of album-14.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-11.jpg"> | ||
<img src="thumb-375-album-11.jpg" alt="Thumbnail of album-11.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-13.jpg"> | ||
<img src="thumb-375-album-13.jpg" alt="Thumbnail of album-13.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-12.jpg"> | ||
<img src="thumb-375-album-12.jpg" alt="Thumbnail of album-12.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-5.jpg"> | ||
<img src="thumb-375-album-5.jpg" alt="Thumbnail of album-5.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-4.jpg"> | ||
<img src="thumb-375-album-4.jpg" alt="Thumbnail of album-4.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-6.jpg"> | ||
<img src="thumb-375-album-6.jpg" alt="Thumbnail of album-6.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-7.jpg"> | ||
<img src="thumb-375-album-7.jpg" alt="Thumbnail of album-7.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-3.jpg"> | ||
<img src="thumb-375-album-3.jpg" alt="Thumbnail of album-3.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-2.jpg"> | ||
<img src="thumb-375-album-2.jpg" alt="Thumbnail of album-2.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
|
||
<a href="album-1.jpg"> | ||
<img src="thumb-375-album-1.jpg" alt="Thumbnail of album-1.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
</div> | ||
<script src="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/js/lightgallery.min.js"></script> | ||
<script> | ||
lightGallery(document.getElementById('lightgallery'), { | ||
selector: 'a' | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
docs/_medias/portes-ouvertes-2024/source/vertical/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Photo Album</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/css/lightgallery.min.css" /> | ||
</head> | ||
<body> | ||
<div id="lightgallery"> | ||
|
||
<a href="album-10.jpg"> | ||
<img src="thumb-375-album-10.jpg" alt="Thumbnail of album-10.jpg" style="max-width:100%;height:auto;"> | ||
</a> | ||
|
||
</div> | ||
<script src="https://cdn.jsdelivr.net/npm/lightgallery.js/dist/js/lightgallery.min.js"></script> | ||
<script> | ||
lightGallery(document.getElementById('lightgallery'), { | ||
selector: 'a' | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Binary file added
BIN
+25 KB
docs/_medias/portes-ouvertes-2024/source/vertical/thumb-375-album-10.jpg
Oops, something went wrong.
Oops, something went wrong.