Skip to content

Commit ec21b6e

Browse files
A Dynamic Collection of Shell Scripts with Educational Purpose
1 parent 10d6598 commit ec21b6e

1 file changed

Lines changed: 82 additions & 1 deletion

File tree

scripts/resize-mult16

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,73 @@
44

55
: <<'DOCUMENTATION'
66
resize-mult16 - Check if images are multiples of 16 and optionally resize them
7-
Requires: ImageMagick (magick command)
7+
Version: 1.0
8+
License: GPLv3
9+
Author: Felipe Facundes
10+
11+
DESCRIPTION:
12+
This script checks if image dimensions are multiples of 16 and optionally resizes
13+
them to the nearest multiple. This is particularly useful for Godot game engine
14+
TileMaps and texture optimization.
15+
16+
WHY MULTIPLES OF 16 FOR GODOT?
17+
───────────────────────────────
18+
• Performance Optimization: Godot's rendering engine is optimized for textures
19+
with dimensions that are powers of two (16, 32, 64, 128, 256, 512, 1024, etc.).
20+
• TileMap Compatibility: Godot's TileMap system uses 16x16 tiles by default.
21+
Images not multiples of 16 may be cropped or display incorrectly.
22+
• Memory Alignment: Modern GPUs process textures more efficiently when dimensions
23+
are powers of two, reducing memory fragmentation.
24+
• Mipmapping: Proper mipmap generation requires power-of-two dimensions for
25+
consistent texture filtering across different LOD levels.
26+
• Best Practice: Keep images under 4096x4096 (4K) for broader hardware
27+
compatibility and better performance.
28+
29+
RECOMMENDED PRACTICES:
30+
──────────────────────
31+
1. Sprite sheets: Should have dimensions that are multiples of 16
32+
2. Tile sets: Each tile should be 16x16, 32x32, 64x64, etc.
33+
3. Texture atlases: Maintain power-of-two dimensions
34+
4. UI elements: Align to 16-pixel grid for crisp rendering
35+
36+
REQUIREMENTS:
37+
• ImageMagick (magick command)
38+
39+
EXAMPLES:
40+
resize-mult16 image.png # Check single image
41+
resize-mult16 -r image.png # Resize with confirmation
42+
resize-mult16 -rf *.png # Force resize all PNGs
43+
resize-mult16 -l -r # Batch process all images
44+
resize-mult16 -p -c black image.png # Pad with black borders
45+
resize-mult16 -d image.png # Dry run (simulation)
46+
47+
OPTIONS:
48+
-h, --help Show this help message
49+
-r, --resize Automatically resize to nearest multiple of 16
50+
-f, --force Force resize without confirmation
51+
-p, --pad Pad images instead of stretching
52+
-c COLOR, --color COLOR Padding color (default: transparent)
53+
-i METHOD, --interpolation METHOD Interpolation method (default: box)
54+
-v, --verbose Show detailed information
55+
-n, --no-backup Don't create backup of original files
56+
-d, --dry-run Simulate actions without modifying files
57+
-l, --loop Batch process all matching images
58+
-o DIR, --output DIR Output directory for resized images
59+
60+
TIPS FOR GODOT USERS:
61+
─────────────────────
62+
1. Import Settings: In Godot, set texture filter to "Nearest" for pixel art
63+
2. TileMap Setup: Use 16x16 cell size for default tiles
64+
3. Atlas Textures: Create texture atlases with dimensions like 256x256, 512x512
65+
4. Performance: Textures over 2048x2048 may impact mobile performance
66+
5. Compression: Use .png for lossless, .jpg for background images
67+
68+
SEE ALSO:
69+
• Godot Documentation: https://docs.godotengine.org/
70+
• ImageMagick: https://imagemagick.org/
71+
72+
BUGS & FEEDBACK:
73+
Please report issues to: https://github.com/felipefacundes/shell_utils
874
DOCUMENTATION
975

1076
# Default values
@@ -565,12 +631,27 @@ loop_monitor() {
565631
exit 0
566632
}
567633

634+
# Display Godot-specific recommendations
635+
show_godot_tips() {
636+
echo "GODOT OPTIMIZATION TIPS:"
637+
echo "──────────────────────────"
638+
echo "1. Tile Size: Default is 16x16. Use multiples for best results."
639+
echo "2. Max Texture Size: Keep under 4096x4096 for compatibility."
640+
echo "3. Texture Filter: Use 'Nearest' for pixel art, 'Linear' for smooth."
641+
echo "4. Compression: PNG for UI/sprites, JPG for backgrounds."
642+
echo "5. Atlas Creation: Group small textures into power-of-two atlases."
643+
echo "6. Mipmaps: Disable for 2D sprites, enable for 3D textures."
644+
echo "7. VRAM: Monitor texture memory in Godot's debugger."
645+
echo ""
646+
}
647+
568648
# Main function
569649
main() {
570650
# Parse command line arguments
571651
while [[ $# -gt 0 ]]; do
572652
case $1 in
573653
-h|--help)
654+
show_godot_tips
574655
show_usage
575656
;;
576657
-r|--resize)

0 commit comments

Comments
 (0)