Decimation / SmartImage

Reverse image search tool (SauceNao, IQDB, Ascii2D, trace.moe, and more)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Features: Input queue, auto-search, extra metadata

Decimation opened this issue · comments

So under the assumption that Auto-Search is functioning correctly, and you're able to select multiple images through [ Browse ].


  • When multiple images are dragged to the program, or selected through the context menu, a queue is created.

    • If a queue already exists, these images should be added to the end of the existing queue.
    • Selecting images through [ Browse ] should also append them to the end of any existing queue.
  • The default state of the program could have a [ Next ] button, perhaps below [ Run ].

    • This Next button when clicked would automatically search the next image in the queue.
    • If there is no "next image", or if it happens to be the last of a queue (could even be a queue of 1), it does nothing.
  • When you click the [ Delete ] button, the same behavior should occur. Switch to the next image in the queue, or do nothing if that was the last image.

That's the limit of my personal needs.


If you wanted to further integrate your existing setup with this queue system, here's some super optional ideas:

  • The [ Restart ] button could erase the entire queue, leaving you at square one.
  • I can't think of what [ Clear ] should do when you're in the middle of a queue. I assume it would be messy to allow a "priority" system, such that any image dropped into the program after hitting [ Clear ] would move to the front of the queue, being the next item searched. This sounds like a pain to be honest, so I'll leave discretion up to you.
  • A separate [ Queue ] button, when clicked, displays the queue to you by filenames [Hard] OR a counter for how many items remain in the queue [Easy].

Thanks a lot!

Here is what I have currently working for the Queue:

Enqueuing items

  • Check the Queue checkbox to enable it
  • Click [Browse] and select the input images
    • The selected files are enqueued

Usage

  • The front of the queue is shown in the input field
  • Click [Run] to run the search
  • Click [Next] to dequeue the next item in the queue

Examples

Using the file picker:

VsDebugConsole_2023-05-17_.22h24m48s._ScCcJhTkoE.mp4

Using the dialog:

VsDebugConsole_2023-05-17_.22h57m02s._zGP5CesqLd.mp4

Progress

This is what I've gotten working in the past 4 hours or so since I started working on it. I have yet to iron things out and make some adjustments per your request.

It's insane that you managed to cook this up in 4 hours.


How do you plan on handling a queue that has 20+ items, and displaying those in that [ Queue ] menu? At a certain point the entire list would be too long to fit in the box.

Since this was a optional request, I really don't want you slaving over it.

The easy solution would be to display the first X items, and just add an ellipses at the bottom if there's more than X remaining in the queue.

The hard solution would be to enable some sort of scroll, which would allow you to Remove items from the queue that exist after the first X items.

Completely up to you!


Scalability in general is something I'm curious about, I wonder how big does the queue have to be before your PC/SmartImage starts chugging. I suppose it wouldn't be hard to calculate for your own personal machine, but it might differ on a user-basis.


Something else I also wonder is, if you'd be able to "relinquish" files that have been inserted into SmartImage, so that you can manually delete them without receiving an error that SmartImage is using the file. This is super low priority since you have graciously added a Delete button, but also something to consider with long queues.

Thank you for your work!

How do you plan on handling a queue that has 20+ items, and displaying those in that [ Queue ] menu? At a certain point the entire list would be too long to fit in the box.
The hard solution would be to enable some sort of scroll, which would allow you to Remove items from the queue that exist after the first X items.

You can already scroll, up/down, left/right.

Thank you for your work!

No problem! And thank you for the generous donations.

Can you try out v3.0.3 RC?

The [Next] and [Queue] buttons don't seem to work when I drag multiple images into the client. They are greyed out.

Did you enable the queue as seen in the examples?
(Make sure you're toggling the checkbox to the left of the [Next] button)

Here is a more complete example showing both use-cases of the queue:

explorer_2023-05-27_.00h37m49s._ffSKjXob4P.mp4

1. Using the file picker [Browse]

Select multiple files using the dialog as you would any other program. You can Ctrl+Click to add to the selected files or Shift+Click to bulk select files.

2. Drag-and-drop into queue input [Queue]

This is still being worked on. Drag and drop files into the input field in the [Queue] dialog, and if the input is valid, it will be automatically added to the queue.

Single file drag-and-drop only works for now. I will see if I can find a way to implement multi-file drag-and-drop into the input field.

Also, there is a minor bug as seen in the example: if the file path has spaces (which results in the path being delimited with quotes "), the leading quote isn't cleared from the input field. The workaround is just deleting it. I have tried ironing this bug out -- and I'm sure I will eventually -- but this seems to be another issue with the Terminal.Gui shell library.

Single file drag-and-drop only works for now. I will see if I can find a way to implement multi-file drag-and-drop into the input field.

This explains it. Works decently with the [Browse] though. I assume auto-search is still in-progress too, since I can't toggle it yet.

I love the new colors, what a great idea!

Edit: Even with having to hit [Run] after [Next]/[Delete], this is as smooth and reliable as I expected it would be, thanks a lot for this. I really really hope others are using this tool for their own data hoarding and backlogs of images too.

Edit: Even with having to hit [Run] after [Next]/[Delete], this is as smooth and reliable as I expected it would be, thanks a lot for this. I really really hope others are using this tool for their own data hoarding and backlogs of images too.

Thank you! I appreciate it, and thank you for your donations. Feel free to suggest any features or improvements for SmartImage you would find like to see.

I am also working on image scanning within result data (the payload returned by the server URL in the results), and downloading image results (#41).

Auto-search is WIP but it's a bit tedious. Just to verify, you envision auto-search to start the search immediately after input verification and uploading, right (as it does when opening via the context menu)?

In the future, I may further upgrade the queue to run searches concurrently. The only problem is performance and overhead, both client-side and server-side. However this is just an idea in the backlog.

I am also working on image scanning within result data (the payload returned by the server URL in the results), and downloading image results (#41).

That's really ambitious, I hope you can pull that off. Downloading would allow others to retrieve a more "native" copy of the image they used to search.

Auto-search is WIP but it's a bit tedious. Just to verify, you envision auto-search to start the search immediately after input verification and uploading, right (as it does when opening via the context menu)?

Oh wow, I didn't expect it pose trouble. But yes you're correct, just like how it works with the context menu. After uploading is complete.

In the future, I may further upgrade the queue to run searches concurrently. The only problem is performance and overhead, both client-side and server-side. However this is just an idea in the backlog.

Yea this is something that would have to be done delicately, since some of the search engines you've provided have hard limits on the amount of searches that can be done in a given span of time. You'd probably have to program a back-off period between searches or something, either globally, or on a search engine basis. Honestly sounds like a lot of mapping, since you'd really only have to account for the largest back-off period of all the selected engines.

What's funny about this is that while SauceNao only allows 3 searches in a 30 second period, SmartImage still returns the resulting links, just with a broken raw SauceNao link.

Found a bug for this release:
Ascii2D and SauceNao are giving me errors when I hit [Run], queue or not. Sometimes the SmartImage UI does present the resulting urls, but the raw websites would produce that error:

Ascii2D:
image

SauceNao:
image

The other engines don't result in anything either.

Found a bug for this release: Ascii2D and SauceNao are giving me errors when I hit [Run], queue or not. Sometimes the SmartImage UI does present the resulting urls, but the raw websites would produce that error:

Ascii2D: image

SauceNao: image

The other engines don't result in anything either.

  • Are these bugs consistent (regardless of the input you use) or specific to certain inputs? Can you share the inputs which caused these errors, and your configuration?

  • Does the latest stable release (v3.0.2) have this issue?

  • Note: I also updated the executable for that release a few times, so make sure you're using the most recent v3.0.3 RC.

Are these bugs consistent (regardless of the input you use) or specific to certain inputs? Can you share the inputs which caused these errors, and your configuration?

https://github.com/Decimation/SmartImage/assets/41088844/99560c34-94d5-450e-b10b-e82728bdbb29
image

Does the latest stable release (v3.0.2) have this issue?

Yes

Note: I also updated the executable for that release a few times, so make sure you're using the most recent v3.0.3 RC.

Just tried it, same issue.
v3.0.3 worked earlier a few hours ago. I changed my IP address via VPN a few times as well.

Looking at the image you searched, https://files.catbox.moe/t87qii.jpg, it seems CatBox had an error uploading it, or the original image you used (which was uploaded to the aforementioned URL), is corrupt or of a unique format.

firefox_2023-05-28_(18h38m37s)_L22a2nex1Y

CatBox doesn't return any data from that URL which is why some of the engines don't return any results. The reason the [Raw] results give an error is because the API retrieves its data from the upload URL (which doesn't return any data as explained below), whereas the normal results are returned by the API with the image file itself used as the request payload (it's not using the upload URL).

curl 'https://files.catbox.moe/t87qii.jpg' > test.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

The fact this issue is only occurring now, and given CatBox is returning an error, makes me inclined to believe either (1) there's something with the images you're searching; or (2) CatBox can't properly handle the image. Can you share the image(s) you search which results in this error? Also, does this issue occur only when searching some of these images, or is it any image?

If there's something unique to the image format, I can work something out probably.

It's any image.
Screenshot_353251
DjOlhMIUcAAHjm1

It's any image. Screenshot_353251 DjOlhMIUcAAHjm1

I just tested uploading those images to CatBox and Litterbox, and it seems the issue is caused by CatBox itself; Litterbox uploads them just fine and returns the data properly. This isn't a bug with SmartImage itself, but I can add error handling to use Litterbox as a backup in case CatBox is having problems.

Great! Glad we found this lol.

After further research, it seems CatBox doesn't like images with EXIF/XMP metadata. If you clear the metadata, CatBox will work properly. You can clear metadata by using the following option in the Properties > Details dialog in Explorer:

explorer_2023-06-04_(13h00m42s)_LiMJlhxs7q

I am looking into ways to automate this in SmartImage.

After further research, it seems CatBox doesn't like images with EXIF/XMP metadata. If you clear the metadata, CatBox will work properly. You can clear metadata by using the following option in the Properties > Details dialog in Explorer:

explorer_2023-06-04_(13h00m42s)_LiMJlhxs7q

I am looking into ways to automate this in SmartImage.

Oh that's weird, cause I was dragging images with metadata for a long while til it randomly stopped working. Wonder if they changed anything.

@SakiSakiSakiSakiSaki Can you try out the latest v3.0.3 RC?

Just tried it out, the auto-search is intensely useful. You can just power through a bunch of images, one after another.

I noticed a few things:

As an aside:

  • For SauceNao, would it be possible to also grab these links to Boorus as well?
    image
    Sometimes the results populate in SmartImage, sometimes they don't.

Thanks a lot for this!

Point 1 & 2

Multi-file drag-and-drop does not work for the input field (it never has). I can try to make a workaround for this, but it's another limitation of Terminal.Gui. To use the queue, use the [Browse] button to select multiple files (after enabling it as described earlier in the thread).

Point 2

This is because the input field only accepts a single file. When you try to drag-and-drop multiple files into the input field, it is converted into a string with the format file1 file2 filen. There is slight overhead with this. Auto-search invokes once a valid input is detected in the input field, and it detected the first file, then ran.

SauceNao

I believe this is already implemented but I'm not entirely sure. If not, I'll add it.

Have you checked the other result columns (there are arrows in the table borders indicating hidden columns aren't shown) to see if the SauceNao result contains the other links? Use the directional arrow keys to navigate through the table.

Point 1 & 2
Point 2

Yea that's fine, I figured it was a library limitation.
When you use [Browse] yourself, is the resulting file explorer window ever lower resolution than your normal file explorer windows? I use a 4K display, and the resolution on the created file explorer looks a lot less:
From SmartImage:
image
Native:
image


SauceNao

I'll do some more research and see if I can find examples. I've actually never noticed hidden columns before, so that's good to know.

Thanks!

I'm pretty sure the reason the dialog is lower resolution is due to Windows resolution scaling. This affects most programs running on any high-DPI (≥2K resolution, Surface displays, etc.) device — it's more an issue with Windows handling high DPI. If it's really bothersome, I can see if I can make the process "DPI-aware" but testing it would be tricky.

I wouldn't worry about it, seems like it's something that should go further down the totem pole, when it's the last pressing thing left.

Everything else works pretty great though, this program is like a well-oiled machine. My only gripe is SauceNao's aggressive limit-rating, which your program partially circumvents by returning SauceNao's results either way, just without the raw link since it'd be under cooldown.

I imagine there's billions of API specific engine issues when you look at all the engines you allow users to use, beyond my personal use-cases lol.

I'm pleased to hear it's working efficiently!

Does the download feature work?

  • Select a link in the results table (column 3) then use the keystroke Ctrl+D. Make sure the cursor is in the link cell _
  • If the link is a direct link to an image (the payload is a binary image file), a ✓ will appear in the column to the left (column 2). Otherwise, a × will appear.
  • You can then double-click the corresponding result name (column 1) to open the folder in which the file downloaded (your user Pictures folder by default). The file will be highlighted as well.

I've been pressing Ctrl+D on my rows, using the following image:
FDHqpOYaIAAkTg_

I sometimes don't see the underscore, or when I do, and I do the keystroke, the ✓ or × only appears when I click on another row.

I got a check from a single url:
image

Clicking column 1 results in nothing, and my Pictures folder is empty as well.

The × means you can't download the URL because it's not a direct URL to an image, therefore it wasn't downloaded.

Example

URL returns an image file (direct URL): https://www.catbox.moe/file/image.png → ✓

URL returns an HTML page: https://www.iqdb.org → ×

A heuristic is whether or not the URL has a filename with an image extension. The reason every result URL isn't checked automatically is to limit API and server calls in addition to performance costs.

Yandex and RepostSleuth tend to have direct URLs but others sometimes have them as well.

I sometimes don't see the underscore, or when I do, and I do the keystroke, the ✓ or × only appears when I click on another row.

The download/scan process is asynchronous and the duration depends on the server response time and the payload returned.

I am also working on image scanning within result data for image URLs (#41). For instance, a danbooru result URL may have a download link to the full-size original image within the page HTML.

I think the program had a memory leak lol
image

It kept taking forever to search for an image, and cancelling and move the next image didn't change anything.

I think the program had a memory leak lol

It kept taking forever to search for an image, and cancelling and move the next image didn't change anything.

Yeah I've been ironing out memory leak issues for a while. Can you describe how you used the program (what actions, etc.) until you noticed the memory leak?

I just dumped about 40 images or so through Browse. Skipping or deleting, til one image was hanging up for a long while.

I just dumped about 40 images or so through Browse. Skipping or deleting, til one image was hanging up for a long while.

Can you try the updated v3.0.3 RC build? I think I may have resolved the memory leaks (partially). I just queued 72 images totaling 187 MB and the process ran fine. Can you describe or share the image which caused the program to hang?

75 images works for me as, with that new build.

Some things I just noticed:

  • The Google Images engine search just returns the Google Image homepage:
    image
    image

  • Here is an image, when searched on SauceNao, does not return the Danbooru/Gelbooru link.
    0f1988731d7e78923e678465493899c0
    image

  • I feel like [Run] should be disabled if no engines are selected, intuitively.

Try out the latest v3.0.3 RC.

The Google Images engine search just returns the Google Image homepage

Google Images replaced their image search feature with Google Lens. I updated the Google Images search URL to use Google Lens so it will work properly now.

Here is an image, when searched on SauceNao, does not return the Danbooru/Gelbooru link

Extraneous URLs (extra URLs) are stored in the Metadata field column. I added a feature to view extra metadata in the latest release: press Ctrl+M and a dialog will show:

SmartImage_2023-06-10_(13h34m13s)_FuJHiRWf7J

You can double click the URLs to open them in your browser.

Let me know if you have a more intuitive or preferential method of viewing extra metadata or URLs.

I feel like [Run] should be disabled if no engines are selected, intuitively.

Whenever no engines are selected, SmartImage reverts back to the default engine selection (All).

I also added hotkeys for efficiency:

Key Function
Ctrl+R Restart
Ctrl+B Browse
Ctrl+C Cancel
Ctrl+N Next

Hi friend, apologies for the delayed response. I have just tried out the latest build, here are my responses to your above response:

Extraneous URLs (extra URLs) are stored in the Metadata field column. I added a feature to view extra metadata in the latest release: press Ctrl+M and a dialog will show:
You can double click the URLs to open them in your browser.

Let me know if you have a more intuitive or preferential method of viewing extra metadata or URLs.

This is great, although I have a question. What constitutes as metadata? I assumed both Danbooru and Gelbooru would be metadata, not just Gelbooru.

Complex Solution: I think the most intuitive thing for those tiny buttons would be to "indent" them or group them under the result box they appear in. In reference to the image you and I used, SauceNao #2 and SauceNao #3 would be grouped under SauceNao #1, as SauceNao #1.1 and SauceNao #1.2 respectively.

image

Simple Solution: Another idea would be to just embed the metadata items as their own row/result. So the gelbooru and twitter links would be their own rows as SauceNao #4 and SauceNao #5 respectively.



Whenever no engines are selected, SmartImage reverts back to the default engine selection (All).

That's perfectly fine with me, but when I deselect all engines and try to search, the Uploading bar will hang up for a few seconds, and return nothing instead of everything:

image
image



Side Notes:

  • I think it would help to make the default window size wide enough to address the following two issues:
    • You can't see the loading bar and loading status in the current default size without having to extend the window.
      image
    • The menu text overflows into whitespace.
      image


Hope this helps, thanks!

Try out v3.0.3-RC2. I implemented the extraneous URL handling like you described.

Yea this is great. One suggestion I have is probably omitting the "lookup_type" urls:
image
Those are links to these buttons:
image
Which are inaccessible to most people since it requires a premium SauceNao account.
image


I noticed a new [Filter] button. Not sure what it does yet though haha.


Are you able to receive Ascii2d results for that above image Donguri Suzume image? I get the following:
image

Can you try the updated v3.0.3-RC2?

  • SauceNao lookup_type URLs are filtered.
  • Ascii2D timeout was increased to 10 seconds. The reason Ascii2D wasn't returning results for that image was because it was timing out.

[Filter] filters out low-quality results from the table. Each click increases the filter level (3 being the highest). Filter level 3 will only show direct image links.

Nice! I'd also suggest removing the artist links from SauceNao, given how often they'll repeat:
Screenshot_1

Screenshot_2

I'd also suggest removing the artist links from SauceNao, given how often they'll repeat:

I just released v3.0.3 with this change. Can you try it out? Here is how the results should look using the same image in your example:

VsDebugConsole_2023-07-04_(08h56m38s)_YxIaS2qRB5

I just tried out v3.0.3 RC 2 and noticed a few things with the following image:
43043883_p0

  • Users still shows up for that above image, intended?
  • The artist field wasn't grabbed for those various entries.
  • Program has trouble parsing non-latin characters I think. Not sure how much trouble it would be to support that unicode encoding.

image


As a side note, I've spent hours using your program to organize my images. It's really great. Was wondering it would be possible to add a queue counter of sorts. Like how many images are remaining in the queue or something. Anywhere would be fine, so as long as it updated.

Can you try the final v3.0.3 release, not RC 2? RC builds were release candidates for testing.

As for the non-Latin characters not rendering, that's caused by the console encoding mode and whether the console font supports such characters. You can try changing the default console font by configuring Command Prompt defaults.

I can definitely add a queue counter in. Feel free to request any other features you'd like as well.

And thank you for the support! I'm glad to hear the software is working so well.

@SakiSakiSakiSakiSaki Actually, could you try out v3.0.4?

Queue

I added the queue counter as you requested.

SauceNao

Results

As for the user results from SauceNao, the Twitter username is now parsed:

2023-07-08_(13h23m13s)_6f3Sgnx5Ew

I don't want to remove the user link entirely because other users may find it useful. Additionally it helps isolate an artist's official Twitter from other accounts which may just be reposting their artwork. I hope that's fine with you.

API

You can now use the official SauceNao API by entering an API key in the config dialog. This will be more reliable and faster.

Console encoding

SmartImage sets the console encoding to UTF-8 on startup so non-Latin characters should render properly, but it doesn't seem to work. Running SmartImage with Windows Terminal works, but the console buffer/window is janky. I've tried resolving this before for other projects but to no avail. I think the console font has something to do with it as well.

@SakiSakiSakiSakiSaki Actually, could you try out v3.0.4?

Seems like [ Config ] is inaccessible until SmartImage.dll.config generates. The program has been closed and reopened upon first instance.

Once I can get [ Config ] open, I can't change anything. I have additional files generate.
image

SauceNao

Results

As for the user results from SauceNao, the Twitter username is now parsed:

I don't want to remove the user link entirely because other users may find it useful. Additionally it helps isolate an artist's official Twitter from other accounts which may just be reposting their artwork. I hope that's fine with you.

Yea that's perfectly fine with me.

API

You can now use the official SauceNao API by entering an API key in the config dialog. This will be more reliable and faster.

This would be great if the API was generous lol. I'll just stick to guest and using VPN lol.

Seems like [ Config ] is inaccessible until SmartImage.dll.config generates. The program has been closed and reopened upon first instance.

Once I can get [ Config ] open, I can't change anything. I have additional files generate.

Thanks for the report. I updated v3.0.4 with a fix. Can you try it out?

Thanks for the report. I updated v3.0.4 with a fix. Can you try it out?

Works perfectly. Thanks!

Thanks for the report. I updated v3.0.4 with a fix. Can you try it out?

I seem to be getting this error after a while, after I configure all my stuff etc. Fixes itself by deleting my config file:

image
SmartImage.zip

I seem to be getting this error after a while, after I configure all my stuff etc. Fixes itself by deleting my config file:

Thanks for reporting this. It was a simple mistake on my part. I just pushed a fix v3.0,.4.

I also implemented image scanning. Use the keystroke Ctrl+S on a result and it will scan for image links within the page. I will update the wiki with more info later.

SmartImage_2023-07-09_(18h46m08s)_oFdiVWP5w4

I'm marking this task as complete and closing the issue. I think everything has been implemented fully.

In regard to the bug, I assume the latest v3.0.4 fix worked for you? If not, feel free to open a (new) issue.

As always, post any suggestions in this discussion thread

I'm marking this task as complete and closing the issue. I think everything has been implemented fully.

In regard to the bug, I assume the latest v3.0.4 fix worked for you? If not, feel free to open a (new) issue.

As always, post any suggestions in this discussion thread

Yep, everything's been smooth sailing. Thanks!