-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fails on ` in filename #1
Comments
Two issues, actually - backtrace at the end belongs to the second one, which should now be fixed (as of c2299f7). But the initial problem is mostly unrelated to that.
What's more creepy is the "sh -c" running from somewhere within CImg and pHash invocaton.
Yuck! Apparently, it does that for the formats that aren't recognized by CImg/libpHash natively, so I guess one easy workaround would be to pre-filter images to make sure there're only valid formats. But that said, I don't feel like poking and fixing either CImg (huge chunk of C++ in a single header file) or libpHash, so my advice would be for you to do something like "convert" (imagemagick tool) on all the files and only run the tool on those that were processed successfully, so that the aforementioned libs won't have to chew them further. Guess I can merge a patch for an option that does such pre-screening, but I think it's out of scope of the tool and a wrong way to go - proper soluton would be to look into the libs and fix them, otherwise there's no telling when they'll choke next. I'll add a warning to the README, but unless you have some better idea on how to deal with that, the issue should probably be closed as "wontfix". |
I know, and I was horrified about invoking sh -c without proper quoting! Luckily I didn't any have filenames with rm * in them :) I'll log some bugs with CImg and/or libpHash. Perhaps a command line switch to ignore the files that are failing, by catching the exception? |
Hm, indeed, I'm not sure how errors there are handled (and if checked at all), and will look into it, though I guess errors should be non-fatal by default. I've noticed that libpHash produced "0" as hash for some images in the past, but don't remember looking much into why (as there were only few cases), while in fact it might be indication that it can't process the image. Thanks for the pointer. |
Interesting thing to note is that there's relatively new (~1 month old) release of libpHash that may as well not have any problems. I'm still using 0.9.4, which is like 2 years old, so there's a good chance issue might've been noticed. EDIT: Even the latest (1.5.3) CImg, on the other hand, has the code like this in several places:
And "load_other" does basically:
SF tracker doesn't seem to have a Bug for it, too, which, as I've looked at the code already, guess I'll create, if you won't beat me to it. I think I'll propose adding something like and env-var there to control this fallback, but not yet sure if it's sane, gotta think on it some more. |
Filed a ticket about the issue with CImg - https://sourceforge.net/p/cimg/bugs/49/ (just fyi). |
Thanks! |
Given current resolution of CImg issue in question, I guess there won't be any cleaner way to fix the problem w/o rebuilding pHash with new CImg.h, though I'll probably file a report to pHash to add ./configure option for pHash to disable shell fallback when it will eventually be closed. As of aa7a272, script shouldn't stumble on files which cause errors and just print something like "Failed to get image hash ('images/A BC`s0.gif'): [ENOENT] No such file or directory" to stderr (along with CImg output there) and treat the file as unhashable and skip it's processing in the future if same --hash-db is used. Thanks for reporting the thing (might save some trouble for CImg users, in particular). |
DEBUG:root:Processing path: ./inc/A BC`s0.gif
sh: -c: line 0: unexpected EOF while looking for matching
' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching
'sh: -c: line 1: syntax error: unexpected end of file
[CImg] *** CImgIOException *** [instance(0,0,0,0,0x0,non-shared)] CImg::load(): Failed to recognize format of file './inc/A BC`s0.gif'.
Traceback (most recent call last):
File "/Users/aaditya/bin/image_matcher.py", line 195, in
if name == 'main': main()
File "/Users/aaditya/bin/image_matcher.py", line 192, in main
if optz.reported_db is not None: optz.reported_db.sync()
AttributeError: 'bool' object has no attribute 'sync'
The text was updated successfully, but these errors were encountered: