Sub topic 11
Saving or Packing the Image with Your File
What this chapter assumes
You should already be able to build a material with an Image Texture node, connect it to the Principled BSDF Base Color, and set its color space. You should also know how to open the UV Editor and Image Editor. This chapter covers what happens to the image when you save the .blend file, close Blender, and open the file again, perhaps on another computer.
Why an image can disappear
A .blend file stores meshes, materials, node trees, and UV coordinates. It does not store the pixels of an image by default. An Image Texture node points to an image datablock, which is Blender's internal record for one image. That record usually holds a file path, and the pixels are read from that path when the file opens.
This causes three common problems:
- You move or rename the image file, and the .blend can no longer find it.
- You send the .blend to someone else without the image.
- You create or paint an image inside Blender and never write it to disk.
In the first two cases the texture shows up in the viewport as a flat magenta color. In the third case the pixels are lost when you close Blender. Your UV coordinates survive in all three cases, because they live on the mesh. Only the image data is at risk.
Three places an image can live
| Storage | Where the pixels are | Survives closing Blender | Travels with the .blend |
|---|---|---|---|
| External file | A PNG, JPEG, EXR or similar on disk, referenced by path | Yes, if the path still resolves | No, copy the file too |
| Packed | Embedded inside the .blend | Yes | Yes |
| Generated, unsaved | Created in memory by Blender | Only if never edited | Only the generator settings |
An unedited generated image, such as the UV test grid from the distortion chapter, is rebuilt from its type and size when the file opens. Once you paint on it, the image is "dirty", meaning its pixels differ from what can be regenerated or read from disk. A dirty image must be saved or packed. Otherwise the edits are lost.
Option 1: keep the image as an external file
Most production work keeps textures as separate files. They stay editable in other programs, several .blend files can share them, and the .blend stays small.
Saving an image to disk
In the Image Editor, the Image menu offers three commands:
- Save (Alt+S) writes the image to its current path.
- Save As (Shift+Alt+S) writes it to a new path and makes the datablock point there from now on.
- Save a Copy writes a file but leaves the datablock pointing at its old location.
The Save As dialog lets you choose the file format, color depth, and compression. The format should match what the image contains:
- Use 8-bit PNG for ordinary color textures.
- Use 16-bit PNG or EXR for height or displacement data, where 8 bits can cause visible banding.
- Use JPEG only for photographs where small losses are acceptable. It discards information every time you save.
The color space setting belongs to the datablock, not the file. Saving does not change it. If you reload a Non-Color data image as sRGB, the shading changes even though the file is identical.
Relative and absolute paths
A path that starts with // is relative to the .blend file. For example, //textures/brick_color.png means a textures folder next to the .blend. The material script in this tutorial uses this form. An absolute path such as C:\Users\you\brick_color.png breaks as soon as the file moves to another machine.
To keep a project portable:
- Save the .blend first. Relative paths need a known file location, so an unsaved file cannot use them.
- Put textures in a folder next to the .blend, such as
textures. - Choose File > External Data > Make Paths Relative.
On Windows, a relative path cannot cross drive letters. If the .blend is on D: and the image is on C:, the path stays absolute.
Finding broken links
Use File > External Data > Report Missing Files to list images that cannot be found. Find Missing Files searches a folder you choose for files with matching names. Run it before you hand a project to someone else.
Option 2: pack the image into the .blend
Packing copies the image file's bytes into the .blend. After that, Blender reads the pixels from inside the file and no longer needs the external file.
- Image > Pack in the Image Editor packs one image.
- File > External Data > Pack Resources packs every external resource that can be packed, including all images.
- File > External Data > Automatically Pack Resources packs all of them again each time you save. It is convenient, but it can quietly make a file large.
A packed image keeps its original format. A packed PNG is stored as PNG bytes, so packing does not recompress it. The .blend grows by roughly the size of the image files. A scene with twenty 4K textures can add hundreds of megabytes, and every save then rewrites all of that data.
Unpacking
Unpacking writes the embedded bytes back out to a file. In File > External Data > Unpack Resources, or Image > Unpack for one image, Blender offers these choices:
| Choice | Effect |
|---|---|
| Use files in current directory | Use the file in `//textures` if it exists, otherwise create it |
| Write files to current directory | Write to `//textures`, overwriting what is there |
| Use files in original location | Use the file at the old path, creating it if needed |
| Write files to original location | Write to the old path, overwriting |
| Remove Pack | Discard the embedded copy and keep the existing path |
The two "write" choices overwrite files. If an artist has improved the file on disk since you packed it, writing the old packed copy over it destroys that work. Prefer the "use" choices unless you want to replace the file.
Editing a packed image
If you paint on a packed image, the changes exist only in memory until you store them again. The Image Editor shows an asterisk next to the image name when it has unsaved edits. After editing, save the image, pack it again, and confirm the asterisk is gone before you close the file. Treat a packed image the same as any other dirty image.
Choosing between them
As a rule of thumb:
- Pack for small projects, quick shares, assets you want in one file, and images that exist only inside Blender.
- Keep external for large textures, shared libraries, and pipelines where other programs edit the textures.
- Mix them. A project can pack a few small images and link the big ones. Each image datablock is handled separately.
Zero-user images and fake users
Blender removes datablocks that have no users when you save and reopen a file. If you delete the Image Texture node that used an image, the image has no users and is dropped, even if you packed it. To keep an image that no node currently uses, give it a fake user. In the Image Editor, click the shield icon next to the image name. In Python, set img.use_fake_user = True.
Common failures
- Magenta texture after moving the file. The path no longer resolves. Run Find Missing Files, or fix the path in the Image Texture node.
- Texture is fine on your machine but missing on a colleague's. The path was absolute. Make paths relative and ship the textures folder, or pack.
- Painted pixels gone after reopening. The image was never saved or packed. Look for the asterisk before closing.
- .blend file suddenly huge. Automatically Pack Resources is on, or high-resolution images were packed. Unpack the large ones.
- Duplicate images named
brick_color.png.001. The same file was loaded more than once. In scripts, passcheck_existing=Truetobpy.data.images.loadso Blender reuses an existing datablock. - Image looks washed out after reloading. The color space on the datablock was reset or set incorrectly. Reselect sRGB for color images or Non-Color for data images.
Doing it with Python
The script below reports the storage state of every image in the file. It skips the Render Result and compositor Viewer images, which are not stored as ordinary image files.
import os
import bpy
for img in bpy.data.images:
if img.type in {'RENDER_RESULT', 'COMPOSITING'}:
continue
if img.packed_file:
state = "packed"
elif img.source == 'FILE':
path = bpy.path.abspath(img.filepath)
state = "on disk" if os.path.exists(path) else "MISSING"
if img.is_dirty:
state += ", unsaved edits"
else:
state = f"{img.source.lower()}, not stored"
print(f"{img.name}: {state}")The next script makes every image safe to close. It packs generated images, saves edited file images back to their paths, and warns about images whose files are gone.
import os
import bpy
for img in bpy.data.images:
if img.type in {'RENDER_RESULT', 'COMPOSITING'}:
continue
if img.packed_file:
continue
if img.source == 'GENERATED':
img.pack(as_png=True)
print(f"Packed generated image {img.name}")
elif img.source == 'FILE':
path = bpy.path.abspath(img.filepath)
if os.path.exists(path):
if img.is_dirty:
img.save()
print(f"Saved edits to {path}")
else:
print(f"WARNING: {img.name} points to a missing file: {path}")
bpy.ops.file.make_paths_relative()Run it with the .blend already saved at least once, or make_paths_relative has nothing to be relative to. To pack everything at once, bpy.ops.file.pack_all() does the same job as Pack Resources. bpy.ops.file.unpack_all(method='USE_LOCAL') reverses it into the local textures folder.
Exercise
You painted a dirt mask on an image created with bpy.data.images.new("DirtMask", 2048, 2048). You save the .blend, close Blender, and reopen it. The mask is blank. Why, and give two ways to prevent it.
Show answer
The image was generated in memory and edited, so it was dirty. A .blend does not store pixels for unsaved or unpacked images, and a generated image is rebuilt blank from its settings. Prevent it by saving the image to a file with Image > Save As (ideally into //textures), or by packing it with Image > Pack, or in Python img.pack(as_png=True).
Exercise
A colleague opens your .blend and every texture is magenta. The Image Texture nodes show paths like C:\Users\you\Desktop\bricks.png. Name the cause and two fixes you could apply before sending the file again.
Show answer
The paths are absolute and point to your machine. Fix 1: save the .blend, put the textures in a textures folder beside it, and use File > External Data > Make Paths Relative, then send the folder with the .blend. Fix 2: pack all images with File > External Data > Pack Resources so the .blend is self-contained.
Exercise
You packed a PNG, edited it in the Image Editor, and saved the .blend. The Image Editor header still shows an asterisk. What does it mean, and what should you do?
Show answer
The asterisk means the image has unsaved edits. The in-memory pixels differ from the stored copy. Save the image again or pack it again, then check that the asterisk is gone before closing the file.