Open EmilDohne opened 1 day ago
The ceremonial API dance I do for this case is the following:
// During create(), provide _just_ the format extension (psd here) that OIIO will recognize
// It will perform a stat/existence check on the "file" but no further filesystem access should occur.
unique_ptr<ImageInput> in = ImageInput::create("psd");
if (!in) {
return nullptr;
}
// Set the ioproxy and use empty "" path during open()
in->set_ioproxy(&mem_reader);
bool ok = in->open("", newspec, config);
...
Ah thats smart! I wasnt aware you could do this, when I tried passing the filename or e.g. .exr
in would be nullptr
but I'll try what you suggested!
Is your feature request related to a problem? Please describe. I'm currently implementing smart objects into my Photoshop reader/writer API and those (sometimes) store the raw file bytes directly in memory rather than having a file on disk it references. From what I can tell though OpenImageIO requires a valid filepath to read from an IOProxy. I've thrown together a hacky solution that works but it requires a temporary file to be created in order to actually read the file.
If there is a way to do this natively feel free to point me to it and I'll close this ticket :)
Describe the solution you'd like A way to create an imageinput purely from memory.
Describe alternatives you've considered I looked into using an
OIIO::ImageBuf
for this purpose but it looked like it only supported being backed from pixel buffers? Unsure about this.