Page MenuHome

Opening an image with 'relative path' selected, gets absolute path.
Closed, ResolvedPublic

Description

System Information
OS X 10.8.5 (12F45)
NVIDIA GeForce GT 650M 1024 MB

Blender Version
8d023c1
Broken: 2.69.11 8d023c1
Worked: 2.69.0 r60991

Short description of error
If you open an image and check the option 'relative path' it returns the absolute path.

Exact steps for others to reproduce the error

  1. Open Blender.
  2. Save the file.
  3. Open an image (as texture, in the UV/Image Editor, in the Compositor, it doesn't seem to matter) and check the option 'relative path'.
  4. The path of the image is absolute, not relative.

It seems like the error is in 'bpy.ops.image.open()'. If you have opened an image in the UV/Image Editor and after that use the browse button under 'source' ('bpy.ops.buttons.file_browse()') it does return the relative path.

Event Timeline

Dalai Felinto (dfelinto) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Feb 24 2014, 11:37 PM

confirmed on OSX

It seems that even in 2.69 opening an image via script would always set the path to be absolute.
For example:

bpy.ops.image.open(filepath="/Users/dfelinto/blender/bugs/grid.tif", relative_path=True)
print bpy.data.images['grid.tif'].filepath.startswith("//"))

It seems this error came back somehow.
I am getting the exact same broken behavior in 2.73.8 (86a2e9d).
Here's a sample folder with image and blendfile. Notice the image is loaded with relative path. However, if i open the same image with alt+o or the open image button, it gets an absolut path, even though the relative path checkbox is activated.

Hmm, it seems there are some strange things going on. If I open your test file, I indeed have the error. But if I open another image, it does have a relative path. Also with other files. If I completely remove the image (shift + click on the X), save the file and re-open, I can also open the image with relative path.

Blender version 2.73.8 (cdc1dab)

I found it.
The cause of the problem is in image_ops.c line 1090:

	/* only image path after save, never ibuf */
	if (is_relative_path) {
		if (!exists) {
			BLI_path_rel(ima->name, bmain->name);
		}
	}

Either the !exist must be changesd or we need an extra test. But this way the path for
an existing file would never be changed, a new file will !

I think we can/should remove the "!exists" test.

Cambo ?

Jens

The logic for exists is:

  • If you have an image loaded, use the existing image
  • If you have an existing image, don't manipulate its path. (assume this is already set as the user desired).

This came from the observation that dragging and dropping an image, could modify its path.


However as @Sebastian Koenig (sebastian_k) noticed, re-opening same image makes path absolute, fixing.

I still find this a bit fuzzy.
The checkbox for relative/absolute is available still, so as a user I would expect that it works. Especially because in all image related buttons in Cycles the textbox to change the source path is not available, only from inside the image editor.

@Sebastian Koenig (sebastian_k), it is awkward.

The issue with using existing data its already used elsewhere & IMHO opening an image really shouldn't modify existing loaded data.

We could have a notification when loading an image "Info: Using existing image", Then at least the user know whats going on, it could even notify that the existing image has different relative setting.

If they want to change paths then - they can select the image and change the paths.