Skip to content

Commit

Permalink
Add image resizer script and update image alt text in blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
fskelly committed Nov 29, 2024
1 parent d3bf233 commit 4cb62df
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion content/posts/2024/new-bambu-printer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags = ['3D Printing']

<!--more-->

{{< figure src="https://raw.githubusercontent.com/fskelly/fskelly.me/main/static/2024/new-bambu-printer/arrival-boxes.jpg" height="400" width="400" >}}
{{< figure src="https://raw.githubusercontent.com/fskelly/fskelly.me/main/static/2024/new-bambu-printer/arrival-boxes.jpg" alt="Arrival Boxes">}}
{{< figure src="https://raw.githubusercontent.com/fskelly/fskelly.me/main/static/2024/new-bambu-printer/top.jpg" height="400" width="400" >}}
{{< figure src="https://raw.githubusercontent.com/fskelly/fskelly.me/main/static/2024/new-bambu-printer/accessories.jpg" height="400" width="400" >}}
{{< figure src="https://raw.githubusercontent.com/fskelly/fskelly.me/main/static/2024/new-bambu-printer/screen.jpg" height="400" width="400" >}}
Expand Down
23 changes: 23 additions & 0 deletions image-resizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
from tkinter import Tk, filedialog
from PIL import Image

def resize_images(directory, target_size):
for filename in os.listdir(directory):
if filename.endswith((".jpg", ".jpeg", ".png", ".bmp")):
img_path = os.path.join(directory, filename)
with Image.open(img_path) as img:
img = img.resize(target_size, Image.LANCZOS) # Use LANCZOS instead of ANTIALIAS
img.save(img_path)
print(f"Resized and saved: {filename}")

# Create a file browser dialog
root = Tk()
root.withdraw() # Hide the root window
directory_path = filedialog.askdirectory(title="Select Directory with Images")

if directory_path:
target_size = (800, 600) # Adjust the target size as needed
resize_images(directory_path, target_size)
else:
print("No directory selected, exiting.")
Binary file modified static/2024/new-bambu-printer/accessories.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/2024/new-bambu-printer/arrival-boxes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/2024/new-bambu-printer/screen.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/2024/new-bambu-printer/side.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/2024/new-bambu-printer/top.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4cb62df

Please sign in to comment.