Skip to content
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

Hotfix 2023-06-19: v0.2.1 #31

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ options:

Note: This program ignores any non-image file in the target directory
*: Smaller hash sizes are better for detecting visually similar images, while larger hash sizes are better for
identifying identical images; The smaller the hash size, the better the performance; sSmallest accepted hash size
identifying identical images; The smaller the hash size, the better the performance; Smallest accepted hash size
is 8
```

Expand Down Expand Up @@ -112,7 +112,7 @@ options:

Note: This program ignores any non-image file in the target directory
*: Smaller hash sizes are better for detecting visually similar images, while larger hash sizes are better for
identifying identical images; The smaller the hash size, the better the performance; sSmallest accepted hash size
identifying identical images; The smaller the hash size, the better the performance; Smallest accepted hash size
is 8
```

Expand Down Expand Up @@ -169,32 +169,27 @@ The user can also specify `-e/--exclude REGEX` flag when cleaning this way to fu

| File type | Extension | Note |
|----------------------------------|-------------------------------------------------------------------------|--------------------------------------------------------------------------|
| Blizzard Texture Format | `.blp` | |
| Blizzard Mipmap Format | `.blp` | |
| Bitmap | `.bmp`, `.dib` | |
| DirectDraw Surface | `.dds` | |
| Encapsulated PostScript | `.eps` | User needs to have installed [Ghostscript](https://www.ghostscript.com/) |
| Graphics Interchange Format | `.gif` | |
| Apple Icon Image | `.icns` | |
| Icon | `.ico` | |
| IM Magica | `.im` | |
| Icon | `.ico`, `.icns` | |
| Cursor | `.cur` | |
| LabEye Image Bitmap | `.im` | |
| Joint Photographic Experts Group | `.jpg`, `.jpeg`, `.jpe`, `.jfif`, `.jif` | |
| JPEG 2000 | `.jp2`, `.j2k`, `.jpf`, `.jpm`, `.jpg2`, `.j2c`, `.jpc`, `.jpx`, `.mj2` | |
| PiCture eXchange | `.pcx` | |
| Picture Exchange | `.pcx` | |
| Portable Network Graphics | `.png` | |
| Portable Bitmap | `.pbm` | |
| Portable Graymap | `.pgm` | |
| Portable Pixmap | `.ppm` | |
| Portable Anymap | `.pnm` | |
| Portable Bitmap | `.pbm`, `.pgm`, `.ppm`, `.pnm` | |
| Silicon Graphics Image | `.sgi` | |
| Seattle FilmWorks | `.spi` | |
| SPIDER image | `.spi` | |
| Truevision TGA | `.tga` | |
| Tagged Image File Format | `.tif`, `.tiff` | |
| Tag Image File Format | `.tif`, `.tiff` | |
| WebP | `.webp` | |
| X11 Bitmap | `.xbm` | |
| Cursor | `.cur` | |
| Flexible Image Transport System | `.fits`, `.fit`, `.fts` | |
| Multi-Picture Object | `.mpo` | |
| Pixar Image File Format | `.pxr` | |
| Adobe Photoshop Document | `.psd` | |
| Sun Raster | `.ras`, `.sun` | |
| X11 Pixmap | `.xpm` | |
| X Bitmap | `.xbm` | |
| X Pixmap | `.xpm` | |
4 changes: 2 additions & 2 deletions src/imdupes/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.2.0'
__version__ = '0.2.1'
__app_name__ = 'imdupes'

__prog_usage__ = f'{__app_name__} {{scan,clean}} ...'
Expand All @@ -17,7 +17,7 @@
__scan_epilog__ = \
'Note: This program ignores any non-image file in the target directory\n' \
'*: Smaller hash sizes are better for detecting visually similar images, while larger hash sizes are better for\n' \
' identifying identical images; The smaller the hash size, the better the performance; sSmallest accepted hash ' \
' identifying identical images; The smaller the hash size, the better the performance; Smallest accepted hash ' \
'size\n is 8' \

__clean_usage__ = f'{__app_name__} clean [options] input'
Expand Down
35 changes: 19 additions & 16 deletions src/imdupes/dupfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def load(
dups = []
exclude_pattern = None if exclude is None else re.compile(exclude)
excluded_count = 0
has_err = False

if verbose > 0:
print(f'Reading "{file}"...', end='', flush=True)
Expand All @@ -51,16 +52,20 @@ def load(
curr_dups = []
for file_path in duplication:
if not os.path.exists(file_path):
cprint(
f'Error reading file "{file}": '
f'Malformed entry: Incorrect path "{file_path}"\nProgram terminated.',
'red'
)
exit()
if not has_err:
has_err = True
if (verbose == 1) or (verbose > 1 and excluded_count == 0):
print()
if verbose > 0:
print(
f'"{file_path}" does not exist, entry skipped.',
flush=True
)
continue
if not os.path.isfile(file_path):
cprint(
f'Error reading file "{file}": '
f'Malformed entry: "{file_path}" is not a file\nProgram terminated.',
f'"{file_path}" is not a file\nProgram terminated.',
'red'
)
exit()
Expand All @@ -73,11 +78,11 @@ def load(
exit()

if exclude_pattern is not None and exclude_pattern.search(file_path) is not None:
if excluded_count == 0 and verbose > 1:
if not has_err and excluded_count == 0 and verbose > 1:
print()
excluded_count += 1
if verbose > 1:
print(f'Excluded file: "{file_path}"')
print(f'Excluded entry: "{file_path}"')
continue

im = None
Expand Down Expand Up @@ -108,9 +113,9 @@ def load(
im.close()
continue

# Skip all empty duplication groups, which can happen if all files within them are excluded, or are skipped
# because of error when loading the image file
if len(curr_dups) > 0:
# Skip all duplication groups with length < 2, which can happen if all files within them are excluded, or
# are skipped because of error when loading the image file
if len(curr_dups) > 1:
dups.append(curr_dups)

except (
Expand All @@ -131,13 +136,11 @@ def load(
)

if excluded_count == 0 and verbose > 1:
cprint(' No file(s) excluded. ', 'yellow', end='')
cprint(f'{"" if has_err else " "}No file(s) excluded. ', 'yellow', end='')

if verbose > 0:
if verbose > 1 and excluded_count > 0:
print()
print(
f'{"" if (verbose > 1) or (verbose > 1 and excluded_count > 0) else " "}'
f'{"" if (verbose > 1) or (verbose > 1 and excluded_count > 0) or (verbose > 0 and has_err) else " "}'
f'Loaded {colored(str(len(dups)), attrs=["bold"])} duplication(s) '
f'across {colored(str(sum(len(lst) for lst in dups)), attrs=["bold"])} file(s) '
f'{colored("[DONE]", color="green", attrs=["bold"])}',
Expand Down
1 change: 0 additions & 1 deletion src/imdupes/utils/globs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def format_path(p: str, path_format: PathFormat, curdir: str = None) -> str:
# Limited read-only extensions
'cur',
'fits', 'fit', 'fts',
'mpo',
'pxr',
'psd',
'ras', 'sun',
Expand Down
Binary file removed tests/data/images/DUPLICATE_pikachu.mpo
Binary file not shown.