Skip to content

Commit

Permalink
add image fingerprint (#8)
Browse files Browse the repository at this point in the history
* update icons

* fixbug: msg show window icon

* support fingerprint

* update README
  • Loading branch information
xinntao authored Mar 15, 2021
1 parent ed1b87c commit b3879b6
Show file tree
Hide file tree
Showing 26 changed files with 115 additions and 45 deletions.
2 changes: 1 addition & 1 deletion HandyView.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Name=HandyView
Exec=/mnt/Xintao/Projects/HandyView/handyview/handyviewer.py %f
Type=Application
Terminal=false
Icon=/mnt/Xintao/Projects/HandyView/handyview/icon.png
Icon=/mnt/Xintao/Projects/HandyView/icon.png
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ![icon](handyview/icon.png) HandyView
# ![icon](icon.png) HandyView

[English](README.md) **|** [简体中文](README_CN.md)   [GitHub](https://github.com/xinntao/HandyView) **|** [Gitee码云](https://gitee.com/xinntao/HandyView)

```Handy``` *Series*:

<img src="https://github.com/xinntao/HandyView/blob/master/handyview/icon.png" alt="HandyView Icon" width="36" height="36"> [HandyView](https://github.com/xinntao/HandyView) &emsp; <img src="https://github.com/xinntao/HandyFigure/blob/master/icon.png" alt="HandyFigure Icon" width="36" height="36"> [HandyFigure](https://github.com/xinntao/HandyFigure) &emsp; <img src="https://github.com/xinntao/HandyCrawler/blob/master/icon.png" alt="HandyCrawler Icon" width="36" height="36"> [HandyCrawler](https://github.com/xinntao/HandyCrawler)
<img src="https://github.com/xinntao/HandyView/blob/master/icon.png" alt="HandyView Icon" width="36" height="36"> [HandyView](https://github.com/xinntao/HandyView) &emsp; <img src="https://github.com/xinntao/HandyFigure/blob/master/icon.png" alt="HandyFigure Icon" width="36" height="36"> [HandyFigure](https://github.com/xinntao/HandyFigure) &emsp; <img src="https://github.com/xinntao/HandyCrawler/blob/master/icon.png" alt="HandyCrawler Icon" width="36" height="36"> [HandyCrawler](https://github.com/xinntao/HandyCrawler)
&emsp; <img src="https://github.com/xinntao/HandyWriting/blob/master/icon.png" alt="HandyWriting Icon" width="36" height="36"> [HandyWriting](https://github.com/xinntao/HandyWriting)

---
Expand Down Expand Up @@ -92,8 +92,8 @@ Use `pyinstaller` to compile to executable program, so that you can **double-cli
1. > pyinstaller -D handyview/handyview.py -i icon.ico --windowed
1. You will see a `dist` folder containing the outputs (dll, exe, etc)
1. Copy necessary files to the `dist` folder
> cp -r handyview/icons dist/handyviewer/ <br>
> cp handyview/icon.png dist/handyviewer/ <br>
> cp -r icons dist/handyviewer/ <br>
> cp icon.png dist/handyviewer/ <br>
> cp icon.ico dist/handyviewer/ <br>
1. Choose the `dist/handyview/handyviewer.exe` as the default image viewer.

Expand All @@ -119,6 +119,7 @@ The basic operation (such as shortcut keys) could be found in the *Help* button
- [ ] preview mode
- [ ] show zoom info for each folder (store in database)
- [ ] drag together in the multi-view comparison mode

### Editing operation

- [ ] Simple image edit: crop, resize, color conversion, etc
Expand All @@ -141,10 +142,12 @@ I have used the icons from [flaticon](www.flaticon.com). The following are the s

| Icon | Link | Icon | Link | Icon |Link|
| :--- | :---: | :--- | :---: | :--- | :---: |
| <img src="handyview/icons/open.png" height="32" alt="Open"> | [Open](https://www.flaticon.com/free-icon/open_3143203?term=file%20open&page=1&position=1) | <img src="handyview/icons/history.png" height="32" alt="History">|[History](https://www.flaticon.com/free-icon/timer_2921268) | <img src="handyview/icons/refresh.png" height="32" alt="Refresh"> |[Refresh](https://www.flaticon.com/free-icon/reuse_3299869?term=refresh&page=1&position=16) |
| <img src="handyview/icons/index.png" height="32" alt="Index"> | [Index](https://www.flaticon.com/free-icon/index_2807595?term=index&page=1&position=8) | <img src="handyview/icons/include.png" height="32" alt="Include"> |[Include](https://www.flaticon.com/free-icon/add_2921226) | <img src="handyview/icons/exclude.png" height="32" alt="Exclude">|[Exclude](https://www.flaticon.com/free-icon/remove_2921203) |
| <img src="handyview/icons/compare.png" height="32" alt="Compare"> | [Compare](https://www.flaticon.com/free-icon/file_748614?term=compare&page=1&position=17) | <img src="handyview/icons/clear_comparison.png" height="32" alt="Clear comparison"> |[Clear comparison](https://www.flaticon.com/free-icon/eraser_3277337?term=clear&page=1&position=5) |<img src="handyview/icons/instructions.png" height="32" alt="Help"> |[Help](https://www.flaticon.com/free-icon/information-point_4231321?term=help&page=1&position=87&page=1&position=87)|
| <img src="handyview/icons/main_canvas.png" height="32" alt="Main canvas"> | [Main canvas](https://www.flaticon.com/free-icon/image_3603103) | <img src="handyview/icons/compare_canvas.png" height="32" alt="Compare canvas"> |[Compare canvas](https://www.flaticon.com/free-icon/portraits_3603402) | <img src="handyview/icons/preview_canvas.png" height="32" alt="Preview canvas"> |[Preview canvas](https://www.flaticon.com/free-icon/pieces_3603403)|
| <img src="icons/open.png" height="32" alt="Open"> | [Open](https://www.flaticon.com/free-icon/open_3143203?term=file%20open&page=1&position=1) | <img src="icons/history.png" height="32" alt="History">|[History](https://www.flaticon.com/free-icon/timer_2921268) | <img src="icons/refresh.png" height="32" alt="Refresh"> |[Refresh](https://www.flaticon.com/free-icon/reuse_3299869?term=refresh&page=1&position=16) |
| <img src="icons/index.png" height="32" alt="Index"> | [Index](https://www.flaticon.com/free-icon/index_2807595?term=index&page=1&position=8) | <img src="icons/include.png" height="32" alt="Include"> |[Include](https://www.flaticon.com/free-icon/add_2921226) | <img src="icons/exclude.png" height="32" alt="Exclude">|[Exclude](https://www.flaticon.com/free-icon/remove_2921203) |
| <img src="icons/compare.png" height="32" alt="Compare"> | [Compare](https://www.flaticon.com/free-icon/file_748614?term=compare&page=1&position=17) | <img src="icons/clear_comparison.png" height="32" alt="Clear comparison"> |[Clear comparison](https://www.flaticon.com/free-icon/eraser_3277337?term=clear&page=1&position=5) |<img src="icons/instructions.png" height="32" alt="Help"> |[Help](https://www.flaticon.com/free-icon/information-point_4231321?term=help&page=1&position=87&page=1&position=87)|
| <img src="icons/main_canvas.png" height="32" alt="Main canvas"> | [Main canvas](https://www.flaticon.com/free-icon/image_3603103) | <img src="icons/compare_canvas.png" height="32" alt="Compare canvas"> |[Compare canvas](https://www.flaticon.com/free-icon/portraits_3603402) | <img src="icons/preview_canvas.png" height="32" alt="Preview canvas"> |[Preview canvas](https://www.flaticon.com/free-icon/pieces_3603403)|
| <img src="icons/fingerprint.png" height="32" alt="Fingerprint"> | [Fingerprint](https://www.flaticon.com/free-icon/fingerprint_2313448?term=fingerprint&page=1&position=7) | | | | |


## :e-mail: Contact

Expand Down
17 changes: 9 additions & 8 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ![icon](handyview/icon.png) HandyView
# ![icon](icon.png) HandyView

[English](README.md) **|** [简体中文](README_CN.md) &emsp; [GitHub](https://github.com/xinntao/HandyView) **|** [Gitee码云](https://gitee.com/xinntao/HandyView)

```Handy``` *Series*:

<img src="https://gitee.com/xinntao/HandyView/raw/master/handyview/icon.png" alt="HandyView Icon" width="36" height="36"> [HandyView](https://gitee.com/xinntao/HandyView) &emsp; <img src="https://gitee.com/xinntao/HandyFigure/raw/master/icon.png" alt="HandyFigure Icon" width="36" height="36"> [HandyFigure](https://gitee.com/xinntao/HandyFigure) &emsp; <img src="https://gitee.com/xinntao/HandyCrawler/raw/master/icon.png" alt="HandyCrawler Icon" width="36" height="36"> [HandyCrawler](https://gitee.com/xinntao/HandyCrawler)
<img src="https://gitee.com/xinntao/HandyView/raw/master/icon.png" alt="HandyView Icon" width="36" height="36"> [HandyView](https://gitee.com/xinntao/HandyView) &emsp; <img src="https://gitee.com/xinntao/HandyFigure/raw/master/icon.png" alt="HandyFigure Icon" width="36" height="36"> [HandyFigure](https://gitee.com/xinntao/HandyFigure) &emsp; <img src="https://gitee.com/xinntao/HandyCrawler/raw/master/icon.png" alt="HandyCrawler Icon" width="36" height="36"> [HandyCrawler](https://gitee.com/xinntao/HandyCrawler)
&emsp; <img src="https://gitee.com/xinntao/HandyWriting/raw/master/icon.png" alt="HandyWriting Icon" width="36" height="36"> [HandyWriting](https://gitee.com/xinntao/HandyWriting)

---
Expand Down Expand Up @@ -94,8 +94,8 @@ Use `pyinstaller` to compile to executable program, so that you can **double-cli
1. > pyinstaller -D handyview/handyview.py -i icon.ico --windowed
1. You will see a `dist` folder containing the outputs (dll, exe, etc)
1. Copy necessary files to the `dist` folder
> cp -r handyview/icons dist/handyviewer/ <br>
> cp handyview/icon.png dist/handyviewer/ <br>
> cp -r icons dist/handyviewer/ <br>
> cp icon.png dist/handyviewer/ <br>
> cp icon.ico dist/handyviewer/ <br>
1. Choose the `dist/handyview/handyviewer.exe` as the default image viewer.

Expand Down Expand Up @@ -143,10 +143,11 @@ I have used the icons from [flaticon](www.flaticon.com). The following are the s

| Icon | Link | Icon | Link | Icon |Link|
| :--- | :---: | :--- | :---: | :--- | :---: |
| <img src="handyview/icons/open.png" height="32" alt="Open"> | [Open](https://www.flaticon.com/free-icon/open_3143203?term=file%20open&page=1&position=1) | <img src="handyview/icons/history.png" height="32" alt="History">|[History](https://www.flaticon.com/free-icon/timer_2921268) | <img src="handyview/icons/refresh.png" height="32" alt="Refresh"> |[Refresh](https://www.flaticon.com/free-icon/reuse_3299869?term=refresh&page=1&position=16) |
| <img src="handyview/icons/index.png" height="32" alt="Index"> | [Index](https://www.flaticon.com/free-icon/index_2807595?term=index&page=1&position=8) | <img src="handyview/icons/include.png" height="32" alt="Include"> |[Include](https://www.flaticon.com/free-icon/add_2921226) | <img src="handyview/icons/exclude.png" height="32" alt="Exclude">|[Exclude](https://www.flaticon.com/free-icon/remove_2921203) |
| <img src="handyview/icons/compare.png" height="32" alt="Compare"> | [Compare](https://www.flaticon.com/free-icon/file_748614?term=compare&page=1&position=17) | <img src="handyview/icons/clear_comparison.png" height="32" alt="Clear comparison"> |[Clear comparison](https://www.flaticon.com/free-icon/eraser_3277337?term=clear&page=1&position=5) |<img src="handyview/icons/instructions.png" height="32" alt="Help"> |[Help](https://www.flaticon.com/free-icon/information-point_4231321?term=help&page=1&position=87&page=1&position=87)|
| <img src="handyview/icons/main_canvas.png" height="32" alt="Main canvas"> | [Main canvas](https://www.flaticon.com/free-icon/image_3603103) | <img src="handyview/icons/compare_canvas.png" height="32" alt="Compare canvas"> |[Compare canvas](https://www.flaticon.com/free-icon/portraits_3603402) | <img src="handyview/icons/preview_canvas.png" height="32" alt="Preview canvas"> |[Preview canvas](https://www.flaticon.com/free-icon/pieces_3603403)|
| <img src="icons/open.png" height="32" alt="Open"> | [Open](https://www.flaticon.com/free-icon/open_3143203?term=file%20open&page=1&position=1) | <img src="icons/history.png" height="32" alt="History">|[History](https://www.flaticon.com/free-icon/timer_2921268) | <img src="icons/refresh.png" height="32" alt="Refresh"> |[Refresh](https://www.flaticon.com/free-icon/reuse_3299869?term=refresh&page=1&position=16) |
| <img src="icons/index.png" height="32" alt="Index"> | [Index](https://www.flaticon.com/free-icon/index_2807595?term=index&page=1&position=8) | <img src="icons/include.png" height="32" alt="Include"> |[Include](https://www.flaticon.com/free-icon/add_2921226) | <img src="icons/exclude.png" height="32" alt="Exclude">|[Exclude](https://www.flaticon.com/free-icon/remove_2921203) |
| <img src="icons/compare.png" height="32" alt="Compare"> | [Compare](https://www.flaticon.com/free-icon/file_748614?term=compare&page=1&position=17) | <img src="icons/clear_comparison.png" height="32" alt="Clear comparison"> |[Clear comparison](https://www.flaticon.com/free-icon/eraser_3277337?term=clear&page=1&position=5) |<img src="icons/instructions.png" height="32" alt="Help"> |[Help](https://www.flaticon.com/free-icon/information-point_4231321?term=help&page=1&position=87&page=1&position=87)|
| <img src="icons/main_canvas.png" height="32" alt="Main canvas"> | [Main canvas](https://www.flaticon.com/free-icon/image_3603103) | <img src="icons/compare_canvas.png" height="32" alt="Compare canvas"> |[Compare canvas](https://www.flaticon.com/free-icon/portraits_3603402) | <img src="icons/preview_canvas.png" height="32" alt="Preview canvas"> |[Preview canvas](https://www.flaticon.com/free-icon/pieces_3603403)|
| <img src="icons/fingerprint.png" height="32" alt="Fingerprint"> | [Fingerprint](https://www.flaticon.com/free-icon/fingerprint_2313448?term=fingerprint&page=1&position=7) | | | | |

## :e-mail: 联系

Expand Down
8 changes: 8 additions & 0 deletions handyview/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,11 @@ def switch_preview_canvas(parent):
def show_instruction_msg(parent):
return new_action(
parent, 'Help', icon_name='help.png', slot=parent.show_instruction_msg)


def set_fingerprint(parent):
return new_action(
parent,
'Fingerprint',
icon_name='fingerprint.png',
slot=parent.set_fingerprint)
18 changes: 18 additions & 0 deletions handyview/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, parent, db, num_view=1):
# initialize widgets and layout
self.init_widgets_layout()
self.qview_bg_color = 'white'
self.show_fingerprint = False
self.show_image(init=True)

# set bg color to light_gray when num_view > 1
Expand Down Expand Up @@ -202,12 +203,18 @@ def show_image(self, init=False):
width, height = self.db.get_shape(pidx=pidx)
file_size = self.db.get_file_size(pidx=pidx)
color_type = self.db.get_color_type(pidx=pidx)
if self.show_fingerprint:
md5, phash = self.db.get_fingerprint(pidx=pidx)
md5_0, phash_0 = self.db.get_fingerprint(pidx=self.db.pidx)
else:
fidx = self.db.fidx + idx
img_path = self.db.get_path(fidx=fidx)[0]
width, height = self.db.get_shape(fidx=fidx)
file_size = self.db.get_file_size(fidx=fidx)
color_type = self.db.get_color_type(fidx=fidx)
if self.show_fingerprint:
md5, phash = self.db.get_fingerprint(fidx=fidx)
md5_0, phash_0 = self.db.get_fingerprint(fidx=self.db.fidx)

qimg = QImage(img_path)
if idx == 0:
Expand All @@ -223,11 +230,22 @@ def show_image(self, init=False):
shown_idx = self.db.pidx + 1 + idx
else:
shown_idx = self.db.pidx + 1

# TODO: add zoom ratio
shown_text = [
f'[{shown_idx:d} / {self.db.get_path_len():d}] {basename}',
f'{height:d} x {width:d}, {file_size}', f'{color_type}'
]
# show fingerprint
if self.show_fingerprint:
if idx > 0:
md5_diff = (md5 == md5_0)
phash_diff = phash - phash_0
shown_text.append(f'md5: {md5_diff} - {md5}')
shown_text.append(f'phash: {phash_diff} - {phash}')
else:
shown_text.append(f'md5: {md5}')
shown_text.append(f'phash: {phash}')

self.qviews[idx].set_shown_text(shown_text)
# self.qviews[idx].viewport().update()
Expand Down
Loading

0 comments on commit b3879b6

Please sign in to comment.