Closed ikosa closed 2 years ago
Can you provide a sample photo?
https://drive.google.com/file/d/1CiWRQ8CbbZE8rwyzszn-IQs7cVMTlADI/view?usp=sharing
Before Import: c1f0c3c903091137f89284438d1218200e671ab1 (3.910.816 bytes) After Import: d325a48cef9d3dc8e37e5447709e5730af04782e (3.858.820 bytes)
I think this can be repeated with all portrait photos.
I think I understand where it's coming from:
If we then sync again, the following happens:
@ildyria @kamil4 Let's discuss how to approach this. I see two ways:
Do not rotate original file Do not rotate the original file and only rotate the smaller versions Rational: If we rotate the original file, it's not the original file anymore (upload -> download results in a different file)
Keep rotation of original file Do the rotation of the original file before checking for duplicate Rational: Keeps the logic as we have it now.
How about compute the checksum before the rotation ? Rotate if necessary after the checksum. Sure, checksum of the rotated image won't match what is in the DB, but that solve the problem.
Additionally, this approach is also fine with the "rotation" photo editor which we added recently: we do not recompute the hash of the picture after rotation.
I was a little to fast -> we do calculate the checksum before the rotation -> this can't be the issue.
Hash is calculated before the rotation that is the main problem. The order of rotation and hash calculation has to be changed. Or a quick fix can be a recalculation after rotation which is a bit waste. I comment out the rotation line so far everything seems ok even if in IE.
Status ?
I have not been aware of this problem until now. As I rewrote most of the the import logic I feel as I would be in charge to fix this issue if it still exists. It probably does as I tried not to change any logic. The problem never occurred to me as it is not covered by our automatic tests.
I need to check with the current code what the best solution could be.
Yeah, I was not aware of this issue either, and in particular its possible connection with the interactive rotate functionality. I rewrote the interactive rotation support at one point and I remember wondering back then what to do about checksums, duplicates, and such. I implemented something but it wasn't clear-cut and I still have some doubts about what the right thing to do is.
It seems like this is something we should try to comprehensively address.
It seems like this is something we should try to comprehensively address.
I just say, (m:n)-relationship ... :wink:
I'm closing this as I can't reproduce the problem on current master.
The file size update was definitely addressed as part of #888 (funny as I wasn't even aware of this issue at the time).
The checksum
in the database is always the checksum of the original file and does not change when the image is rotated (be it during import or manually later). So it will match during the next import attempt and the file will be skipped, as expected.
Detailed description of the problem
During the import process if a photo needs to be rotated file size and checksum changes. Because of that if you sync the same folder again all rotated photos will imported again and duplicated.
Another minor problem with this issue is it is not good that your files are changed especially if you select delete imported. I didnt dig deeper to understand how rotation changing the file size (i get smaller files after rotation in my tests. aprox 3.4MB->3.2MB) İt will be good to bind this behavior to a config.
inspected cause of this issue: In photoFunctions checksum is calculated before rotation.
Output of the diagnostics