Opening an image with 'relative path' selected, gets absolute path. #38808

Closed
opened 2014-02-24 14:25:49 +01:00 by Jasper van Nieuwenhuizen · 21 comments

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.

**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.

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @jasperge-2

Added subscriber: @jasperge-2
Campbell Barton self-assigned this 2014-02-24 14:46:13 +01:00

Added subscriber: @dfelinto

Added subscriber: @dfelinto

confirmed on OSX

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 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("//")) ```

This issue was referenced by blender/blender-addons-contrib@b6bb6d1b2c

This issue was referenced by blender/blender-addons-contrib@b6bb6d1b2c6f16c3c325242d15ef6d65d40f1a74

This issue was referenced by b6bb6d1b2c

This issue was referenced by b6bb6d1b2c6f16c3c325242d15ef6d65d40f1a74

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit b6bb6d1b2c.

Closed by commit b6bb6d1b2c.

Added subscriber: @sebastian_k

Added subscriber: @sebastian_k

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.
rel_path.zip

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. [rel_path.zip](https://archive.blender.org/developer/F144144/rel_path.zip)

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'

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)

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)
Member

Added subscriber: @jensverwiebe

Added subscriber: @jensverwiebe
Member

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

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_k noticed, re-opening same image makes path absolute, fixing.

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_k noticed, re-opening same image makes path absolute, fixing.

This issue was referenced by 5115e86246

This issue was referenced by 5115e862460203c5e31bb5d62acc3fda2b0cc2bd

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 5115e86246.

Closed by commit 5115e86246.

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.

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_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.

@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.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#38808
No description provided.