Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support raw formats on windows #25

Open
til-schneider opened this issue Aug 29, 2019 · 7 comments
Open

Support raw formats on windows #25

til-schneider opened this issue Aug 29, 2019 · 7 comments

Comments

@til-schneider
Copy link
Contributor

til-schneider commented Aug 29, 2019

Reading raw camera formats is currently only supported on macOS and Linux - not on Windows.

The problem on Windows is that node-libraw doesn't compile on Windows. I forked node-libraw and tried some things but I didn't get it to work.

There is a compile error in the code of LibRaw (LibRaw is wrapped by node-libraw). Compiling LibRaw should generally be possible, since they provide downloads for Windows.

Here is the error (see full log):

c:\projects\ansel\node_modules\libraw\vendor\libraw\src\libraw_c_api.cpp(277): error C2491: 'libraw_set_demosaic': definition of dllimport function not allowed [C:\projects\ansel\node_modules\libraw\build\vendor\libraw.vcxproj]

According to Microsoft's description of error C2491, the code of LibRaw marks DLL imports the wrong way - see source code of libraw_c_api.cpp. So I wonder why the LibRaw-Team can build this on windows. I also tried to build node-libraw as static library, but this doesn't work either.

I'm a relative nowise when it comes to building C code. I don't know what else to do. So if anybody can help here - please go ahead.

@stefano-xy
Copy link

stefano-xy commented Feb 16, 2020

Try to add #define LIBRAW_LIBRARY_BUILD before the #include of libraw.h, without that it seems the DllDef macro is not expanded properly. If it works, please contribute it back to upstream.

Sorry I could not test it myself due to lack of time, I've just had a quick look at the upstream code.

@til-schneider
Copy link
Contributor Author

til-schneider commented Jun 28, 2020

Sorry for the long time not answering. I didn't have a Windows building environment all the time. Now I set one up and managed to try your hint.

Unfortunately it still doesn't build.

I still get the same error (I'm using LibRaw 0.19.5):

c:\users\til\workspace\picturama\submodules\node-libraw\vendor\libraw\src\libraw_c_api.cpp(277): error C2491: "libraw_set_demosaic": definition of dllimport function not allowed [C:\Users\Til\workspace\picturama\subm
odules\node-libraw\build\vendor\libraw.vcxproj]

@akjoshi
Copy link

akjoshi commented Jan 19, 2021

FYI - I checked with Libraw team in github LibRaw/LibRaw#161 (comment) and the team has confirmed that it's build-able in windows using both Microsoft compiler and gcc (mingw32).

@til-schneider
Copy link
Contributor Author

Thank you for asking the Libraw team. I already knew that Libraw itself builds on Windows. What I didn't get to work yet is building Libraw as node package (using gyp). But I'm no C expert and don't know what else to do. So if anyone can help here, please go ahead.

Maybe the hint from @LibRaw's comment can help:

[...] building without windows-specific memory mapped input stream is also possible

@akjoshi
Copy link

akjoshi commented Feb 7, 2021

I submitted a pull request in node-libraw repo to support windows compilation.

m0g/node-libraw#8 (comment)

@rohrlaf
Copy link

rohrlaf commented May 26, 2021

Have you considered compiling LibRaw directly with WASM, which is Emscripten for C++: https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm

This could get rid of the additional layer provided by node-libraw and also offer performance improvements as it will be pre-compiled and optimised code to be executed.

Maybe this proof-of-concept might help as well: https://github.com/arbarlow/libraw-wasm-example

@til-schneider
Copy link
Contributor Author

til-schneider commented Jun 6, 2021

I'm not sure, whether checking out the pull request of @akjoshi or compiling LibRaw with WASM is the better way to go. In the end, performance is most important for Picturama (because it sucks if switching between photos is not fast).

@rohrlaf: Why do you think, performance would be better with WASM? My experience with Emscripten was the exact opposite. For HEIC/HEIF support, I ended up creating node-libheif, because using a native binding was 3x faster than using Emscripten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants