Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import os
- count = 0
- for image in bpy.data.images:
- if image.filepath:
- old_path = bpy.path.abspath(image.filepath)
- base, ext = os.path.splitext(old_path)
- # Skip if there's no extension (like generated images)
- if ext:
- new_path = base + ".webp"
- # Optional: only replace if the .webp file exists
- if os.path.exists(new_path):
- image.filepath = bpy.path.relpath(new_path)
- count += 1
- else:
- print(f"⚠️ Skipped (no webp found): {old_path}")
- print(f"✅ Replaced {count} image(s) with .webp versions.")
Advertisement
Add Comment
Please, Sign In to add comment