Skip to content

Shrink largest images to at most 1024x1024 pixels#174

Merged
peterjc merged 1 commit into
mainfrom
20260618-resize
Jun 18, 2026
Merged

Shrink largest images to at most 1024x1024 pixels#174
peterjc merged 1 commit into
mainfrom
20260618-resize

Conversation

@peterjc

@peterjc peterjc commented Jun 18, 2026

Copy link
Copy Markdown
Member

Looks for files over 300k, with current height or width over 2000 pixels, and resizes those to up to 1024x1024. Uses ImageMagick:

$ find . -type f -size +300k -exec file \{\} \;| awk -F: '{if ($2 ~/image/) print $1}'| while IFS= read -r file_path; do if (( $(identify -ping -format '%w' "$file_path") > 2000 )) || (( $(identify -ping -format '%h' "$file_path") > 2000 )); then identify -ping -format '%w %h %f' "$file_path";echo;mogrify -resize 1024x1024\> "$file_path";fi;done

(Should really ignore the SVG files)

Based on earlier suggestion by Bastian in #135, but narrower in scope - I worried that resizing thing just over the 1024 limit will be more likely to have visual degradation.

Looks for files over 300k, with current height or width over 2000 pixels,
and resizes those to up to 1024x1024. Uses ImageMagick:

$ find . -type f -size +300k -exec file \{\} \;| awk -F: '{if ($2 ~/image/) print $1}'| while IFS= read -r file_path; do if (( $(identify -ping -format '%w' "$file_path") > 2000 )) || (( $(identify -ping -format '%h' "$file_path") > 2000 )); then identify -ping -format '%w %h %f' "$file_path";echo;mogrify -resize 1024x1024\> "$file_path";fi;done

(Should really ignore the SVG files)

Based on earlier suggestion by Bastian.
This was referenced Jun 18, 2026
@peterjc peterjc merged commit 6641e35 into main Jun 18, 2026
1 check passed
@peterjc peterjc deleted the 20260618-resize branch June 18, 2026 15:31
@nlharris

Copy link
Copy Markdown
Member

Thanks for doing this. I was worried that this could break images on the web pages, but I took a quick look at a few pages and everything looks ok.

@peterjc

peterjc commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

Thanks for double checking Nomi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants