Page MenuHome

VSE, Python: bpy.ops.sequencer.image_strip_add() will truncate the directory name if the 'directory' variable does not end with a path separator
Confirmed, NormalPublicBUG

Description

System Information
Operating system: Windows, Linux

Blender Version
Broken: 2.93
Worked: 2.92

Short description of error
bpy.ops.sequencer.image_strip_add() does not read the 'directory' variable correctly: it will truncate off the final subdirectory if the variable does not end in the path separator ('\' or '/').
For instance, attempting to import 'test.jpg' in the 'C:\tmp' folder as:

bpy.ops.sequencer.image_strip_add(directory="C:\\tmp', files=[{'name': 'test.jpg'}]

will result in a strip with the source of 'C:\test.jpg', rather than 'C:\tmp\test.jpg' as it should be.
Note that in Blender 2.92, it would load the correct file in the correct path with the same code.

Exact steps for others to reproduce the error
Run the following code in blender (change the first two lines to point to an actual image file):

folder = 'C:\\tmp'
file = 'test.jpg'
import bpy
area = False
for screenarea in bpy.context.window.screen.areas:
    if screenarea.type == 'SEQUENCE_EDITOR':
        area = screenarea
if area:
    override = bpy.context.copy()
    override['area'] = area
    bpy.ops.sequencer.image_strip_add(override, directory=folder, files=[{'name':file}], frame_start=1, frame_end=100)

Lines 4-10 are required to just get the operator working and are not related to the bug.

Event Timeline

Richard Antalik (ISS) changed the task status from Needs Triage to Confirmed.Mon, Jun 7, 6:46 AM
Richard Antalik (ISS) changed the subtype of this task from "Report" to "Bug".