same here on Linux openSUSE, Ubuntu and maybe more.
If the LibRaw/libraw.pc.in:8 is never substituted from the configure/configure.ac then its maybe safe to remove that from LibRaw/libraw.pc.in .
And it was not so complicated. In case of anyone having the same problem :
- Download the win32 zip of LibRaw (available on this website)
- open the makefile.mingw present in the LibRaw root folder and add the option "-mno-cygwin" to the cflags (this was obvious...)
- rename the Makefile.mingw in Makefile
- compile LibRaw using cygwin and make
You will now have a libraw.a present in the lib folder of LibRaw. This library can be used with codeblocks. You'll probably need to add the ws2_32 lib just after the libraw lib or you'll get undefined references to ntohs4.
But from *my* point of view, it is too early to go shared, because too many things will change in LibRaw in near future. We definitely will switch to .so, but not now.
So, if you wish to make .so package for Unix/Linux systems, you'll do it on your own risk.
I'll say it again: Look at the UNIX world and see how it's done. LibRaw is not so unique. Plenty of other software libraries have encountered these issues, and yet they distribute as shared libraries right from the start.
Believe it or not, it can work. What's more -- and I hope you take this to heart -- library versioning is not a problem you need to solve. It's been solved elsewhere. Please investigate before you go down that path.
Sure, dcraw_emu appends .tiff or .ppm to existing image filename.
This is very useful if someone (e.g. me) uses both dcraw and dcraw_emu in parallel (for example, for results comparsion): one program does not overwrites results of another one.
Also, if you have both DSCF0001.ARW a DSCF0001.NEF (from Sony and Nikon, respectively), 'dcraw DSCF0001.*' will produce only one resulting file, while dcraw_emu will save both results in separate files.
Just to ensure I didn't get anything wrong: dcraw_emu appends to the output filename, rather than changing the extension, ie 'foo.nef' becomes 'foo.nef.tiff'; this is clearly not what the user expects, and there is no way to specify the resulting filename.
The patch I propose addresses the unexpected behaviour, also bringing it inline with DCRAW's behaviour. I see no good reasons for keeping the unexpected behaviour, and I was careful to use bounded copies etc.
I was thinking this patch should go into the libraw 0.13 stream, no? If not, for what reasons?
Again, if I have software-1 compiled with 0.12 and then install software-2 which requires 0.13, I need to rebuild software-1. For many users this is unacceptable too.
There is a very good solution: shared library versioning. It works well for near-stable products/libraries, not for new versions every 2-4 weeks (current LibRaw).
When LibRaw becomes more stable in terms of API, we'll definitely switch to shared libraries with versioning.
This is an old, old debate that goes back to when shared libraries were first developed. Your examples are fine, but consider the common case of wanting to take advantage of the bugs fixed in 0.12.3. Users of 0.12.2 need to rebuild all software that depends on libraw. For many users, this is unacceptable.
One common way to deal with the API/ABI problem is to say that the API won't change for a given release number, say, 0.12. In 0.13, the API might change (or it might not). Software writers can deal with this as they like.
I would encourage you to examine how other open-source projects deal with this problem. Almost all open-source libraries out there with unstable APIs release their software as shared libraries.
Some people would say there is no such thing as a stable API; even mature libraries, like GTK, are still undergoing revision.
Finally, note that packaging libraw into a .so does *not* force everyone to use it as such. Application writers may statically link in the .o's if they want.
I didn't know that the raw data can come compressed from the camera, thanks for the tip. Just curious, can you tell me which kind of compression can be found usually? deflate?, other?...
I want the data unpacked, so i will reuse the unprocessed_raw sample as you suggest, using the P1.colors=1.
I'm sorry for all the questions, i really value your help.
- imagine someone installed, say, Program1 0.AA.BB with LibRaw 0.11 (shared)
- then he/she wants to try, say, Program2. Progam 2 requires LibRaw 0.13-Beta (shared) because it uses exposure correction feature.
So, user SHOULD rebuild/reinstall Program1 with LibRaw 0.13. But he wanted only to play 5 minutes with Program2, nothing more.....
The shared library are very good idea if
- API/ABI is very stable (but frozen API stops development of new features)
- API is made via non-virtual function calls instead of direct access to parameters structure. This way produces zillions of getters/setters with no idea behind. Also, it is harder to make C++ derived classes, because virtual methods table is fixed too, so no way to add/change function calls.
- there are good .SO/DLL version management, so each program uses own version of LibRaw.so/dll. But this broke the idea of quick 'security/bug fixes'.
You may be *stable* (in terms of API/ABI) but it will slow progress because programmer will need to do tricks (to stabilize APIs and so) instead of doing things.
I hope, after verisions 0.14 or 0.17 LibRaw will be stabilized: we need plugin registration interface, so all extensions will run with stable internals. But not now.
Thanks for the "dirty trick" info.
I will add the P1.colors=1 to my code and try again.
About your first suggestion, you mention three steps:
1) Call LibRaw::open_file()
2) Position to libraw_internal_data.unpacker_data.data_offset
3) Read libraw_internal_data.unpacker_data.data_size bytes
So i try to code you suggestion:
int main(int i, char *img[])
{
i=1;
int tempimg, row, col;
// step one: Open file
LibRaw RawProcessor;
tempimg = RawProcessor.open_file(img[i]);
#define RAW RawProcessor.libraw_internal_data.unpacker_data
// step two: positioning libraw_internal_data.unpacker_data.data_offset
tmpimg = RawProcessor.unpack();
/* how to position it in data.offset?... */
// step three: Read libraw_internal_data.unpacker_data.data_size
for(row=0;row<RAW.data_size.iheight;row++)
for(col=0;col<RAW.data_size.iwidth;col++)
RAW[row*RAW.data_size.iwidth+col][0] = RAW[row*RAW.data_size.iwidth+col][RawProcessor.COLOR(row,col)];
// mode coding, not finished yet...
RawProcessor.recycle();
return 0;
}
Am i in the right direction or i'm completely lost?...
That's fine, I understand that when the API/ABI changes this isn't so simple. But that doesn't mean each version can't be a shared library (i.e. libraw.so). That way if a user upgrades from 0.12.2 to 0.12.3, they get all the benefits of bug fixes without having to recompile all the software that uses libraw.
Obviously my cleaning wasn't good, i ran the unprocessed_raw with a raw image file of 11.2MB and the result was a .tiff file with 18.4MB, so i have check my code. Here is the small routine (without validations) that i did:
---
int main(int i, char *rawimg[])
{
// Initialization
LibRaw RawProcessor;
RawProcessor.imgdata.params.document_mode = 2;
RawProcessor.imgdata.params.output_bps = 16;
RawProcessor.imgdata.params.output_tiff = 1;
RawProcessor.imgdata.params.user_flip = 0;
RawProcessor.imgdata.params.no_auto_bright = 1;
RawProcessor.imgdata.params.filtering_mode = (LibRaw_filtering)(LIBRAW_FILTERING_DEFAULT);
// Opening file and unpack
int tmpimg;
i = 1;
tmpimg = RawProcessor.open_file(rawimg[i]);
tmpimg = RawProcessor.unpack();
// extracting raw image data
int row, col;
char rawfn[1024];
for(row=0;row<RawProcessor.imgdata.sizes.iheight;row++)
for(col=0;col<RawProcessor.imgdata.sizes.iwidth;col++)
RawProcessor.imgdata.image[row*RawProcessor.imgdata.sizes.iwidth+col][0]=
RawProcessor.imgdata.image[row*RawProcessor.imgdata.sizes.iwidth+col]
[RawProcessor.COLOR(row,col)];
// formating and saving image data
snprintf(rawfn,sizeof(rawfn),"%s.tiff",rawimg[i]);
tmpimg = RawProcessor.dcraw_ppm_tiff_writer(rawfn);
// cleaning image processor
RawProcessor.recycle();
return 0;
}
---
If the unprocessed_raw extract only the raw data, without process anything, why the resultant file is bigger that the original?.
According with your suggestion, how can i do the step two (position to libraw_internal_data.unpacker_data.data_offset), and the step three (Read libraw_internal_data.unpacker_data.data_size bytes)?
For the step three, i assume can be done using a "for" structure, but if you can show a basic example code for your suggestion it will be really helpful for me, because i'm not an expert.
I took the unprocessed_raw.cpp, clean it a little bit the code and processed a 11MB image raw file, but the resultant have 55MB, so i assume that there is a post-processing when saving the file in .tiff format.
I basically want to extract the raw image data, without metadata, read it, make a little processing and then save it in a new file.
In order to do that, your suggestion looks what i need to do, but can you please give a reference code about how to implement it?. I'm not asking for an elaborate coding, only a few lines in order to follow the idea.
I'm not c++ expert, so if the question is basic or simple, i'm sorry.
This issue will be fixed in coming 0.12.4 and 0.13.0-Release.
Thanks for report.
same here on Linux openSUSE, Ubuntu and maybe more.
If the LibRaw/libraw.pc.in:8 is never substituted from the configure/configure.ac then its maybe safe to remove that from LibRaw/libraw.pc.in .
LibRaw/libraw.pc.in:8
Requires: @PACKAGE_REQUIRES@
Problem solved, Hurray !!!
And it was not so complicated. In case of anyone having the same problem :
- Download the win32 zip of LibRaw (available on this website)
- open the makefile.mingw present in the LibRaw root folder and add the option "-mno-cygwin" to the cflags (this was obvious...)
- rename the Makefile.mingw in Makefile
- compile LibRaw using cygwin and make
You will now have a libraw.a present in the lib folder of LibRaw. This library can be used with codeblocks. You'll probably need to add the ws2_32 lib just after the libraw lib or you'll get undefined references to ntohs4.
Regards
You're right.
But from *my* point of view, it is too early to go shared, because too many things will change in LibRaw in near future. We definitely will switch to .so, but not now.
So, if you wish to make .so package for Unix/Linux systems, you'll do it on your own risk.
I'll say it again: Look at the UNIX world and see how it's done. LibRaw is not so unique. Plenty of other software libraries have encountered these issues, and yet they distribute as shared libraries right from the start.
Believe it or not, it can work. What's more -- and I hope you take this to heart -- library versioning is not a problem you need to solve. It's been solved elsewhere. Please investigate before you go down that path.
Sure, dcraw_emu appends .tiff or .ppm to existing image filename.
This is very useful if someone (e.g. me) uses both dcraw and dcraw_emu in parallel (for example, for results comparsion): one program does not overwrites results of another one.
Also, if you have both DSCF0001.ARW a DSCF0001.NEF (from Sony and Nikon, respectively), 'dcraw DSCF0001.*' will produce only one resulting file, while dcraw_emu will save both results in separate files.
Just to ensure I didn't get anything wrong: dcraw_emu appends to the output filename, rather than changing the extension, ie 'foo.nef' becomes 'foo.nef.tiff'; this is clearly not what the user expects, and there is no way to specify the resulting filename.
The patch I propose addresses the unexpected behaviour, also bringing it inline with DCRAW's behaviour. I see no good reasons for keeping the unexpected behaviour, and I was careful to use bounded copies etc.
I was thinking this patch should go into the libraw 0.13 stream, no? If not, for what reasons?
Thanks, Daniel
Again, if I have software-1 compiled with 0.12 and then install software-2 which requires 0.13, I need to rebuild software-1. For many users this is unacceptable too.
There is a very good solution: shared library versioning. It works well for near-stable products/libraries, not for new versions every 2-4 weeks (current LibRaw).
When LibRaw becomes more stable in terms of API, we'll definitely switch to shared libraries with versioning.
This is an old, old debate that goes back to when shared libraries were first developed. Your examples are fine, but consider the common case of wanting to take advantage of the bugs fixed in 0.12.3. Users of 0.12.2 need to rebuild all software that depends on libraw. For many users, this is unacceptable.
One common way to deal with the API/ABI problem is to say that the API won't change for a given release number, say, 0.12. In 0.13, the API might change (or it might not). Software writers can deal with this as they like.
I would encourage you to examine how other open-source projects deal with this problem. Almost all open-source libraries out there with unstable APIs release their software as shared libraries.
Some people would say there is no such thing as a stable API; even mature libraries, like GTK, are still undergoing revision.
Finally, note that packaging libraw into a .so does *not* force everyone to use it as such. Application writers may statically link in the .o's if they want.
Thanks for the answer.
I didn't know that the raw data can come compressed from the camera, thanks for the tip. Just curious, can you tell me which kind of compression can be found usually? deflate?, other?...
I want the data unpacked, so i will reuse the unprocessed_raw sample as you suggest, using the P1.colors=1.
I'm sorry for all the questions, i really value your help.
But another problem raise:
- imagine someone installed, say, Program1 0.AA.BB with LibRaw 0.11 (shared)
- then he/she wants to try, say, Program2. Progam 2 requires LibRaw 0.13-Beta (shared) because it uses exposure correction feature.
So, user SHOULD rebuild/reinstall Program1 with LibRaw 0.13. But he wanted only to play 5 minutes with Program2, nothing more.....
The shared library are very good idea if
- API/ABI is very stable (but frozen API stops development of new features)
- API is made via non-virtual function calls instead of direct access to parameters structure. This way produces zillions of getters/setters with no idea behind. Also, it is harder to make C++ derived classes, because virtual methods table is fixed too, so no way to add/change function calls.
- there are good .SO/DLL version management, so each program uses own version of LibRaw.so/dll. But this broke the idea of quick 'security/bug fixes'.
You may be *stable* (in terms of API/ABI) but it will slow progress because programmer will need to do tricks (to stabilize APIs and so) instead of doing things.
I hope, after verisions 0.14 or 0.17 LibRaw will be stabilized: we need plugin registration interface, so all extensions will run with stable internals. But not now.
Please describe, what kind of data do you want:
- compressed (as in file)
- or unpacked ?
If you wand 'file' data (compressed by lossless jpeg or so), you need to position to data offset and read the data manually (and unpack them)
If you want unpacked data (huffman decoded or so), just use unprocessed_raw sample as your base.
Thanks for the "dirty trick" info.
I will add the P1.colors=1 to my code and try again.
About your first suggestion, you mention three steps:
1) Call LibRaw::open_file()
2) Position to libraw_internal_data.unpacker_data.data_offset
3) Read libraw_internal_data.unpacker_data.data_size bytes
So i try to code you suggestion:
Am i in the right direction or i'm completely lost?...
Really appreciate any comments you can give me.
That's fine, I understand that when the API/ABI changes this isn't so simple. But that doesn't mean each version can't be a shared library (i.e. libraw.so). That way if a user upgrades from 0.12.2 to 0.12.3, they get all the benefits of bug fixes without having to recompile all the software that uses libraw.
To turn on pretty printing of code use
<code>
.... your code here
</code>
Also, to pass through antispam filter and captcha, it is better to register on this site once...
, I'll install plugin for right code display, but not today.The 'dirty trick' in unprocessed_raw.cpp is P1.colors=1; This is instruction to dump only first component for the internal tiff writer.
The result is larger than source RAW because:
Thanks for your answer.
Obviously my cleaning wasn't good, i ran the unprocessed_raw with a raw image file of 11.2MB and the result was a .tiff file with 18.4MB, so i have check my code. Here is the small routine (without validations) that i did:
---
---
If the unprocessed_raw extract only the raw data, without process anything, why the resultant file is bigger that the original?.
According with your suggestion, how can i do the step two (position to libraw_internal_data.unpacker_data.data_offset), and the step three (Read libraw_internal_data.unpacker_data.data_size bytes)?
For the step three, i assume can be done using a "for" structure, but if you can show a basic example code for your suggestion it will be really helpful for me, because i'm not an expert.
Thank you for your time and help.
If you use unchanged unprocessed_raw sample, what size has the result?
I took the unprocessed_raw.cpp, clean it a little bit the code and processed a 11MB image raw file, but the resultant have 55MB, so i assume that there is a post-processing when saving the file in .tiff format.
I basically want to extract the raw image data, without metadata, read it, make a little processing and then save it in a new file.
In order to do that, your suggestion looks what i need to do, but can you please give a reference code about how to implement it?. I'm not asking for an elaborate coding, only a few lines in order to follow the idea.
I'm not c++ expert, so if the question is basic or simple, i'm sorry.
Unfortunately, LibRaw is binary incompatible between major versions (i.e. 0.13 vs 0.12), so binary upgrade is really not possible.
Compatibility is ensured only within stable versions of one release (0.12.3 should be compatible with 0.12.99).
This is other side of active development....
This is not bug, this is feature. So, no need to fix it
LibRaw 0.12 is updated too.
The github/master version is already fixed in another way:
configure checks will set $LIBS
and Makefile.am uses $(LIBS) instead of $(LCMS_LIBS)
This is commit URL: https://github.com/LibRaw/LibRaw/commit/73229a04fb2a44159df3baa8f812b473...
Thanks for report!
The problem was in Makefile.am, the new one is pushed to GitHub/master (i.e. 0.13-alpha branch)
It is only quick fix, the problem will be solved in more general way
For float data output we need to change entire processing pipeline to floating point.
There are no such plans for LibRaw team: we're open to contributions, but will not spend much own effort on postprocessing phase.
Pages