Convert overwrites input when acting on raw (CR2, NEF, etc.)
Posted: 2012-03-09T16:33:23-07:00
In version 6.7.5-10 on Windows (which includes a copy of convert that reports as 6.7.5-9), Q16, binary distribution, 32-bit, statically linked, executing the following command:
convert some_raw_file.cr2 output.jpg
...results in the raw file being overwritten with itself in addition to the jpeg file being generated. This is most visible as a change in the modification date for the file. The actual contents of the raw file appear to be identical pre- and post-convert. I believe that the raw (e.g., .cr2) file should not be written to during this command. Indeed, the raw file is not overwritten with earlier versions of convert.
For example, this does not occur with a 64-bit, Q16, Windows binary copy of convert that reports as version 6.6.7-1 (the only old copy of IM I had around). In that old version, only reading takes place; the raw file is never opened for writing.
This is not just a stat (i.e., file system) artifact. Inspection with Process Monitor reveals that the file is indeed being written, as shown in this snippet from the log:
(...snip...)
4:24:06.0571321 PM convert.exe 6596 ReadFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 24,903,680, Length: 262,144, Priority: Normal
4:24:06.0577580 PM convert.exe 6596 ReadFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 25,165,824, Length: 262,144, Priority: Normal
4:24:06.0582826 PM convert.exe 6596 ReadFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 25,427,968, Length: 34,963, Priority: Normal
4:24:06.0583923 PM convert.exe 6596 ReadFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 END OF FILE Offset: 25,462,931, Length: 262,144, Priority: Normal
4:24:06.0630140 PM convert.exe 6596 CloseFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS
4:24:20.0027346 PM convert.exe 6596 CreateFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Desired Access: Generic Write, Read Attributes, Disposition: OpenIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Opened
4:24:20.0038856 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 0, Length: 262,144, Priority: Normal
4:24:20.0043010 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 262,144, Length: 262,144, Priority: Normal
4:24:20.0046506 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 524,288, Length: 262,144, Priority: Normal
4:24:20.0050095 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 786,432, Length: 262,144, Priority: Normal
4:24:20.0055029 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 1,048,576, Length: 262,144, Priority: Normal
4:24:20.0059948 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 1,310,720, Length: 262,144, Priority: Normal
(...snip...)
This problem occurs with all Canon and Nikon raw files that I have tried. To aid in diagnosis, I've placed an example raw file for download on my site.
I'm assuming this is a bug?
Thanks,
Jeff
p.s. - ImageMagick is awesome
*Edit: Pasted the wrong data from Process Monitor. Corrected.
convert some_raw_file.cr2 output.jpg
...results in the raw file being overwritten with itself in addition to the jpeg file being generated. This is most visible as a change in the modification date for the file. The actual contents of the raw file appear to be identical pre- and post-convert. I believe that the raw (e.g., .cr2) file should not be written to during this command. Indeed, the raw file is not overwritten with earlier versions of convert.
For example, this does not occur with a 64-bit, Q16, Windows binary copy of convert that reports as version 6.6.7-1 (the only old copy of IM I had around). In that old version, only reading takes place; the raw file is never opened for writing.
This is not just a stat (i.e., file system) artifact. Inspection with Process Monitor reveals that the file is indeed being written, as shown in this snippet from the log:
(...snip...)
4:24:06.0571321 PM convert.exe 6596 ReadFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 24,903,680, Length: 262,144, Priority: Normal
4:24:06.0577580 PM convert.exe 6596 ReadFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 25,165,824, Length: 262,144, Priority: Normal
4:24:06.0582826 PM convert.exe 6596 ReadFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 25,427,968, Length: 34,963, Priority: Normal
4:24:06.0583923 PM convert.exe 6596 ReadFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 END OF FILE Offset: 25,462,931, Length: 262,144, Priority: Normal
4:24:06.0630140 PM convert.exe 6596 CloseFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS
4:24:20.0027346 PM convert.exe 6596 CreateFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Desired Access: Generic Write, Read Attributes, Disposition: OpenIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Opened
4:24:20.0038856 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 0, Length: 262,144, Priority: Normal
4:24:20.0043010 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 262,144, Length: 262,144, Priority: Normal
4:24:20.0046506 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 524,288, Length: 262,144, Priority: Normal
4:24:20.0050095 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 786,432, Length: 262,144, Priority: Normal
4:24:20.0055029 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 1,048,576, Length: 262,144, Priority: Normal
4:24:20.0059948 PM convert.exe 6596 WriteFile C:\Users\Jeff\Pictures\aaaa\IMG_9543.CR2 SUCCESS Offset: 1,310,720, Length: 262,144, Priority: Normal
(...snip...)
This problem occurs with all Canon and Nikon raw files that I have tried. To aid in diagnosis, I've placed an example raw file for download on my site.
I'm assuming this is a bug?
Thanks,
Jeff
p.s. - ImageMagick is awesome
*Edit: Pasted the wrong data from Process Monitor. Corrected.