Skip to content

Commit

Permalink
24/12/18
Browse files Browse the repository at this point in the history
Former-commit-id: 813d8b3
  • Loading branch information
WindRunnerMax committed Dec 17, 2024
1 parent 9375d11 commit 18ef327
Show file tree
Hide file tree
Showing 66 changed files with 63 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
node_modules
*.log
.cache
dist
build
.temp
55 changes: 55 additions & 0 deletions .scripts/screenshot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import os
from PIL import Image


def compress_image(input_file_path, output_file_path, quality=85, max_width=800, max_height=800):
"""Compress the image, resize it and save it to the output path."""
with Image.open(input_file_path) as img:
# 获取原图尺寸
original_width, original_height = img.size

# 计算缩小比例,并重新计算宽度和高度
aspect_ratio = original_width / original_height
if original_width > max_width or original_height > max_height:
if aspect_ratio > 1: # 宽>高
new_width = max_width
new_height = int(max_width / aspect_ratio)
else: # 高>宽
new_height = max_height
new_width = int(max_height * aspect_ratio)
img = img.resize((new_width, new_height), Image.LANCZOS)
else:
new_width = original_width
new_height = original_height

img.save(output_file_path, optimize=True, quality=quality)


def scan_and_compress_images(directory, size_threshold=800*1024, quality=85):
"""
Scan the directory for .png and .jpg files larger than size_threshold and compress them.
:param directory: Directory to scan for images.
:param size_threshold: Size threshold in bytes (default 800KB).
:param quality: Quality of the compressed image (default 85).
"""
for root, _, files in os.walk(directory):
for file_name in files:
if file_name.lower().endswith((".png", ".jpg", ".jpeg")):
file_path = os.path.join(root, file_name)
file_size = os.path.getsize(file_path)

if file_size > size_threshold and file_path.find(".temp") == -1:
print(
f"Compressing: {file_path} {file_size / (1024*1024):.2f} MB"
)
if not os.path.exists(os.path.join(root, ".temp")):
os.makedirs(os.path.join(root, ".temp"))
output_file_path = os.path.join(root, f".temp/{file_name}")
compress_image(file_path, output_file_path, quality)


if __name__ == "__main__":
# Replace with the path to your directory
directory_to_scan = os.path.realpath(os.path.join(os.getcwd(), "../"))
scan_and_compress_images(directory_to_scan)
Binary file added Environment/screenshots/2023-04-14-18-52-41.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Binary file added Environment/screenshots/2023-04-14-18-53-04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Binary file added Environment/screenshots/2023-04-14-18-53-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Binary file added Environment/screenshots/2023-04-14-18-53-27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Binary file added Environment/screenshots/2023-04-14-18-55-31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Binary file added Environment/screenshots/2023-04-14-18-55-47.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

2 changes: 1 addition & 1 deletion I18N/Vue/Vue学习笔记.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ vue-cli

### 2. Lifecycle

![](screenshots/2023-04-14-21-09-50.png)
<img src="https://v2.cn.vuejs.org/images/lifecycle.png" width="600px" referrerpolicy="no-referrer">

### 3. Filters
Filters can filter data, for example, displaying 1 as OK in a printed table.
Expand Down
Binary file added MyLife/screenshots/2022-03-26-09-36-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2022-03-26-09-36-19.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2022-11-26-15-57-28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2022-11-26-15-57-28.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2022-11-26-16-02-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2022-11-26-16-02-11.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2022-11-26-16-09-27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2022-11-26-16-09-27.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-01-14-20-46-49.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-01-14-20-46-49.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-01-14-20-52-08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-01-14-20-52-08.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-01-14-20-52-47.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-01-14-20-52-47.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-01-14-20-53-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-01-14-20-53-18.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-04-02-16-24-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-04-02-16-24-19.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-04-22-10-34-28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-04-22-10-34-28.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-21-20-42-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-21-20-42-15.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-21-21-19-31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-21-21-19-31.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-21-22-20-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-21-22-20-11.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-21-22-22-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-21-22-22-14.png.REMOVED.git-id

This file was deleted.

2 changes: 1 addition & 1 deletion MyLife/screenshots/2023-06-21-23-15-36.png.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c67af199206fd773b15dd1a8020f42489d06cda9
1fca1ab9f8550a8f9ecef85bbe817bec16ef72c3
Binary file added MyLife/screenshots/2023-06-23-17-05-25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-23-17-05-25.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-25-20-17-17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-25-20-17-17.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-25-20-17-50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-25-20-17-50.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-30-20-02-44.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-30-20-02-44.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-30-20-04-27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-30-20-04-27.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-30-20-05-43.png
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-30-20-05-43.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-30-20-06-15.png
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-30-20-06-15.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-30-20-08-59.png
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-30-20-08-59.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-30-20-09-06.png
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-30-20-09-06.png.REMOVED.git-id

This file was deleted.

Binary file added MyLife/screenshots/2023-06-30-20-10-07.png
1 change: 0 additions & 1 deletion MyLife/screenshots/2023-06-30-20-10-07.png.REMOVED.git-id

This file was deleted.

4 changes: 3 additions & 1 deletion Vue/Vue学习笔记.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ vue-cli

### 2. 生命周期

![](screenshots/2023-04-14-21-09-50.png)
<img src="https://v2.cn.vuejs.org/images/lifecycle.png" width="600px" referrerpolicy="no-referrer">

<p></p>

### 3.过滤器
过滤器可将数据进行过滤,例如可以在打印表格中将1显示为OK
Expand Down
Binary file removed Vue/screenshots/2023-04-14-21-09-50.png
Diff not rendered.

0 comments on commit 18ef327

Please sign in to comment.