Skip to content

Commit fca9941

Browse files
committed
update
1 parent f4cf635 commit fca9941

160 files changed

Lines changed: 67 additions & 6 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/my-portfolio.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_includes/layouts/base.njk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
<!-- Open Graph Meta Tags -->
1414
<meta property="og:title" content="{{ title or metadata.title }}">
1515
<meta property="og:description" content="Explore the portfolio of Yousef Mohamed, showcasing expertise in Concept Art, Graphic Design, Animation, and more.">
16-
<meta property="og:image" content="https://yousefmohamed.studio/img/icons/logo-512x512.webp">
16+
<meta property="og:image" content="https://yousefmohamed.studio/img/optimized/logo-512x512.webp">
1717
<meta property="og:url" content="https://yousefmohamed.studio{{ page.url | url }}">
1818
<meta property="og:type" content="website">
1919

2020
<!-- Twitter Card Meta Tags -->
2121
<meta name="twitter:card" content="summary_large_image">
2222
<meta name="twitter:title" content="{{ title or metadata.title }}">
2323
<meta name="twitter:description" content="Explore the portfolio of Yousef Mohamed, showcasing expertise in Concept Art, Graphic Design, Animation, and more.">
24-
<meta name="twitter:image" content="https://yousefmohamed.studio/img/icons/logo-512x512.webp">
24+
<meta name="twitter:image" content="https://yousefmohamed.studio/img/optimized/logo-512x512.webp">
2525

2626
<!-- JSON-LD Structured Data -->
2727
<script type="application/ld+json">
@@ -39,13 +39,13 @@
3939
],
4040
"jobTitle": "Environment & Prop Concept Artist",
4141
"description": "Multidisciplinary Visual Artist specializing in Concept Art, Graphic Design, 2D Animation, Editing, and VFX.",
42-
"image": "https://yousefmohamed.studio/img/icons/logo-512x512.webp"
42+
"image": "https://yousefmohamed.studio/img/optimized/logo-512x512.webp"
4343
}
4444
</script>
4545

4646
<!-- Favicon and Apple Touch Icon -->
47-
<link rel="icon" href="/img/icons/favicon.ico" type="image/x-icon">
48-
<link rel="apple-touch-icon" href="/img/icons/logo-512x512.webp">
47+
<link rel="icon" href="/img/optimized/favicon.ico" type="image/x-icon">
48+
<link rel="apple-touch-icon" href="/img/optimized/logo-512x512.webp">
4949

5050
<!-- Preload Fonts -->
5151
<link rel="preload" href="/fonts/Roboto-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">

compress_images.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import os
2+
from PIL import Image
3+
import pillow_heif
4+
from concurrent.futures import ThreadPoolExecutor
5+
6+
pillow_heif.register_heif_opener()
7+
8+
INPUT_DIR = "img"
9+
OUTPUT_DIR = "img/optimized"
10+
SUPPORTED_FORMATS = (".jpg", ".jpeg", ".png", ".webp")
11+
WEBP_QUALITY = 82
12+
AVIF_QUALITY = 50
13+
14+
os.makedirs(OUTPUT_DIR, exist_ok=True)
15+
16+
17+
def optimize_image(file_path, root_dir, output_dir):
18+
try:
19+
with Image.open(file_path) as img:
20+
if img.mode == "P":
21+
img = img.convert("RGBA" if "transparency" in img.info else "RGB")
22+
23+
relative_path = os.path.relpath(root_dir, INPUT_DIR)
24+
target_dir = os.path.normpath(os.path.join(output_dir, relative_path))
25+
os.makedirs(target_dir, exist_ok=True)
26+
27+
base_name = os.path.splitext(os.path.basename(file_path))[0]
28+
29+
webp_path = os.path.join(target_dir, f"{base_name}.webp")
30+
img.save(webp_path, "WEBP", quality=WEBP_QUALITY, method=6)
31+
32+
try:
33+
avif_path = os.path.join(target_dir, f"{base_name}.avif")
34+
img.save(avif_path, "AVIF", quality=AVIF_QUALITY)
35+
except Exception:
36+
pass
37+
except Exception:
38+
pass
39+
40+
41+
def batch_optimize_images(input_dir, output_dir):
42+
tasks = []
43+
with ThreadPoolExecutor() as executor:
44+
for root, _, files in os.walk(input_dir):
45+
if "optimized" in root:
46+
continue
47+
for file in files:
48+
if file.lower().endswith(SUPPORTED_FORMATS):
49+
file_path = os.path.join(root, file)
50+
tasks.append(executor.submit(optimize_image, file_path, root, output_dir))
51+
52+
for task in tasks:
53+
task.result()
54+
55+
56+
if __name__ == "__main__":
57+
batch_optimize_images(INPUT_DIR, OUTPUT_DIR)
6.92 KB
Binary file not shown.
11.4 KB

img/optimized/projects/--.avif

542 Bytes
Binary file not shown.

img/optimized/projects/--.webp

158 Bytes

img/optimized/projects/--0.avif

3.8 KB
Binary file not shown.

img/optimized/projects/--0.webp

7.22 KB

0 commit comments

Comments
 (0)