cr2hdr DELETING original photos!?

Started by sinuspi, February 18, 2017, 04:41:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sinuspi

I did a fresh installation of CR2HDR BETA 3 today, only to find it DELETES original DNG files after converting. What the hell!? Sure, it adds a -dualiso suffix, but only after overwriting the original file! And there's no option to disable that behaviour in the settings. Not to mention it also fails to copy the original's EXIF data to the dual-ISO file, so now I'm left with a bunch of nicely converted, but de-EXIF-ed files, thanks a lot. :/

Walter Schulz

Already answered before you wrote that one ....

dmilligan

This is mainly an issue on Windows because it's file system is case-insensitive (though it could be an issue on other systems that are using a case-insenstive filesystem e.g. on the SD card). cr2hdr uses the input filename with the last three letters replaced with "DNG" (uppercase) for the output filename:

        snprintf(out_filename, sizeof(out_filename), "%s", filename);
        out_filename[len-3] = 'D';
        out_filename[len-2] = 'N';
        out_filename[len-1] = 'G';


On Windows, this means that if you give it a file that ends with .dng, it will replace that filename to end with .DNG and assume that its either a different file, or you are simply asking it to re-convert an existing converted file. On Windows, this will actually be the same file. You can use the --skip-existing command line option to prevent overwriting, but then it simply won't convert your file.

Also, if you give cr2hdr a filename with less than 3 characters, this code results in a buffer underflow, which didn't actually cause a crash or anything on my system when I tried it, but you end up with an output file called simply "NG" or just "G". It also screws up if you give it unicode characters, for example I tried a file called "test.:)" (0x1F642) and it said the output file was: "test.?DNG", but it just overwrote the original.

There's also this comment in the code:

            /* note: we only save uppercase .DNGs, so a case-sensitive extension check should be fine */

which is also not a very safe assumption to make.

Bottom line: this file handling code probably needs to be cleaned up. This would probably be considered an easy coding task, great for someone interested in getting started with contributing to ML.

sinuspi

Oh my... Directly replacing the last 3 letters with "DNG" is probably one of the most horribly unsafe piece of code I've seen... O_O

Fsck it, I'm game. Where's the source code and how can I contribute?

@Walter Schulz: Huh, indeed I thought I mentioned this already, but wasn't sure if I did or only intended to. I need to replace some memory chips in my head, I guess. :P

dmilligan


sinuspi

Since I have zero experience with BitBucket specifically, I wonder why it lets me edit and "commit" the file..? I thought I'd have to fork the project and then submit a pull request, and yet there's the "Commit" button, beckoning... What's with that?

dmilligan

It lets you basically do a pull request entirely from a browser.


sinuspi

Right, I know how to fork and request pulls, but I was baffled by the apparent ability to edit and commit to the main repo, NOT my own fork.

sinuspi

OK, here goes nothing. I committed a pull request trying to add an "--append-suffix" option to cr2hdr, making it write to "filename-DualISO.DNG", avoiding overwriting "filename.DNG". It's dry code, as I couldn't afford the time to set up a proper build env, so it may crash and burn... <_<