Cabbage Logo
Back to Cabbage Site

Importing an image using cabbageCreate

I’m creating an image widget that is importing a png file for it’s background using cabbageCreate. I’m using just the name of the file which is in the same folder as the main csd file. This does not work. But if I do the very same widget code in the Cabbage header of the csd file with just the name of the image file, everything works.

I then went back and included the full path for the image that I was including, and it was able to display it correctly. While I get that the full path worked and why, I’m not sure how I could find that full path, other than to hardcode it in.

Is there a reason why the image can’t be found by looking in the project folder (the same folder with the csd file).

Mike

Huh, just tried to import a filmstrip into an rslider using cabbageCreate, and it still can’t find the file unless it uses a full path.

It has been a while since I have tried to include any overlay files, but I don’t remember having to use full paths for the files.

Yes, this had to change, see here:

Thanks, Rory. I did miss that…

I’m considering doing this and was wondering if anyone has a working example of importing an image from file with cabbageCreate?

It should be straightforward, as long as you pass the full path? Is it not working?

SBackground = "bounds(0, 0, 650, 353), file('C:/Users/Dale/Documents/Frame.svg'), presetIgnore(1)"
cabbageCreate "image", SBackground

Should be correct or?

You should use "s for the path, so you’ll need to escape them. This works for me:

SBackground = "bounds(0, 0, 650, 353), file(\"C:/Users/rory/OneDrive/Csoundfiles/buttonOff.png\")"
cabbageCreate "image", SBackground
1 Like

My solution to this was to create an opcode that takes three for name and returns the full pay for the file. I figured that would make it easier to change back, if it ever works in the future. I can’t remember if Rory said this was the way things would be from here on out…