-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
JPEG: Automatically check and repair broken/invalid images #2463
Comments
Found this here, although I'm really not sure how this should fix it: - golang/go#45902 (comment) According to the tests I added, the error "unexpected EOF" remains! At least this change shouldn't break anything either.... Help is more than welcome if someone has more time to read through all the issue comments.
Thank you very much! Even doing that manually helped me a lot with errors like It would be a great joy for me if PhotoPrism could do that automatically! 😸 |
Would be willing to take a stab at this (no promises though). Are there any examples of some broken/invalid jpegs I could use for testing/debugging? |
Certainly there are! Thank you very much for giving it a try! Here are my two (rather large) samples: |
@lastzero looking at the database tables it seems like we should be able to identify all the broken images by looking at files table and checking for non empty file_error. |
It is possible that files that cannot be read at all and are not yet indexed will be skipped. Accordingly, there is no entry for them in the files table. |
How about something like #2721? Could of course be made configurable. |
Signed-off-by: Michael Mayer <michael@photoprism.app>
Signed-off-by: Michael Mayer <michael@photoprism.app>
We have added a new cache/media folder for this, which contains the fixed JPEG files with a hash as filename. This way we make sure that images are updated when the original JPEG changes. |
…m#1673 photoprism#2463 Signed-off-by: Michael Mayer <michael@photoprism.app>
For reference, I don't think this is fully fixed |
Let's create a new issue for that, because we will never be able to fix all possible (broken) file problems. |
Here is the follow up issue |
Signed-off-by: Michael Mayer <michael@photoprism.app>
@Lash-L @maxime1992 It seems that Go's JPEG decoder received a fix earlier this year:
It would be great if anyone still following this issue could check if this resolves the problems with indexing affected JPEG files! Our current workaround is to open the image with ImageMagick and then save an error-free copy. So this requires additional software, slows down indexing and consumes additional disk space... |
Interesting. I guess I could help with testing (next week though) but unsure what you'd like for me to test? Do you want to make a temporary branch with photoprism where I could test this? Also, if you prefer to directly try it out on your own (might be faster than me), I had made an issue and provided a file that had the issue in the first place here: #3363 If you try out with that file and it works, you can consider it's fixed 👌 |
@maxime1992 One way to test this with our stable release would be to index previously affected files with ImageMagick enabled / disabled via You should also see info or debug logs when a file cannot be read with the built-in image library: Note that the "ImageMagick" fallback does not just work for the EOF error, but all encoding issues that the Go library can't handle. So you should not expect that every "broken" JPEG file can now be indexed without it. We've started collecting JPEG test samples here, although we could use more as these two files probably don't cover all (potential) problems: |
I just tested the preview. It seems that the files still cannot be indexed when ImageMagick is disabled. |
@maxime1992 While the changes did not help to read the "broken" JPEGs without re-encoding them, they broke the repair mechanism that we implemented for Samsung S21 panorama images. I've just added a fix for this, see: An updated preview build will be available for testing soon! |
I got this error what could be the reason? |
@holzfelix could you send us a sample file to samples@photoprism.app so that we can have a look at this? |
Go happily refuses to open JPEGs if they contain any glitches. As a user with such files, you still want to index and view them. It would therefore make sense to automate the repair of JPEGs, especially since the process is always the same.
Step 1: Use GraphicsMagick to check a JPEG for issues
GraphicsMagick is a great tool for this task. Depending on what operating system you are using, you may need to install it first: http://www.graphicsmagick.org/identify.html
Now run this command and check the report for any problems:
Note that ImageMagick may also have a command for this. This describes the specific process I used and that worked for me. There are variants and it can likely be optimized so that fewer tools and libraries need to be installed.
Step 2: Use the ImageMagick
convert
command to create a valid copy of the imageTo create a valid copy of the original JPEG:
Any glitches should then be fixed i.e. the repaired copy
fixed.jpg
can be opened without problems.Related Issues:
The text was updated successfully, but these errors were encountered: