olive-groves / butterfly_viewer

Side-by-side image viewer with synchronized zoom and sliding overlays. Drag and drop to instantly compare multiple images on your desktop. Very open source.
https://olive-groves.github.io/butterfly_viewer/
Other
31 stars 5 forks source link

Support command line arguments to immediately open into a comparison #74

Closed 0xKZ closed 1 month ago

0xKZ commented 1 month ago

Fixes #44

Proposed changes

I kept these changes as surgical/minimal as possible to avoid any structural changes to the program. Thankfully it was simple to do.

Originally I attempted directly calling loadFile() but that does not update the other widgets and only creates the split view. Doing it this way by loading via the widgets and then calling the callback as though you pushed the button seems to preserve all the right behaviors.

Testing

I am on a Windows 11 system using MSYS2+bash as the terminal.

(1) Running the program without any arguments

  $ python ./butterfly_viewer/butterfly_viewer.py

This opens the program as before, no images are loaded.

(2) Using one preloaded image

  $ python ./butterfly_viewer/butterfly_viewer.py --image_path_main_topleft butterfly_viewer/icons/icon.png

This opens the viewer with an image in the overlay corner and nothing else:

image

(3) Using two preloaded images

I have a pink square png in a nearby folder I used for this one:

python ./butterfly_viewer/butterfly_viewer.py --image_path_main_topleft butterfly_viewer/icons/icon.png --image_path_topright ../../../missing_asset_square.png 

This opens the image viewer and it's already in sliding overlay mode. No time wasted! :)

image

larsmaxfield commented 1 month ago

Great! Nice to see it was straightforward to implement.

Thanks to your code I expanded the args further with these changes: