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

Enhanced the test cases for xcf files #290

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9a87fb5
modify image__wand builder so that it is like common thumbnail genera…
a523 Oct 19, 2021
2c8c8e6
enable wand builder and disable others
a523 Oct 19, 2021
24463a1
reintroduce white background for file with transparency
a523 Oct 22, 2021
1af97cc
test case for transparent img
a523 Oct 22, 2021
7572911
deprecate Pillow and ImageMagick (command line) builder
a523 Oct 22, 2021
6dbd8d3
support progressive JPEG
a523 Oct 22, 2021
15aeab2
rename
a523 Oct 22, 2021
4720aa4
add doc about how to enable eps format support
a523 Oct 30, 2021
8c08a72
refactor wand build
a523 Oct 31, 2021
bfeb419
format
a523 Oct 31, 2021
a4ccee1
update supported mimetypes
a523 Oct 31, 2021
3aa7c7a
fix supported mimetype table and weight
inkhey Nov 3, 2021
4e4ba63
Merge branch 'develop' of github.com:algoo/preview-generator into wand
inkhey Nov 3, 2021
2a73bd8
reintroduce raw/xcf support
inkhey Nov 3, 2021
5409818
add test for raw file without extension
inkhey Nov 3, 2021
6198027
support file that without extension
a523 Nov 13, 2021
946e66c
fix: merge layers
a523 Nov 13, 2021
e6091f0
make sure transparency turns white
a523 Nov 15, 2021
32ec567
fix test case of heic
a523 Nov 15, 2021
33126d5
misc: add concourse ci
inkhey Nov 15, 2021
445bf66
fix(backend): enforce office mimetype and add better exception
inkhey Nov 16, 2021
40a1450
v0.26
inkhey Nov 16, 2021
a6b1139
fix readme
inkhey Nov 16, 2021
33962c6
fix: Repair loading builders without pytest and make code more explic…
inkhey Nov 16, 2021
edcf565
Merge remote-tracking branch 'algoo/develop' into wand
a523 Nov 18, 2021
2c2fdc7
Merge remote-tracking branch 'algoo/develop' into wand
a523 Nov 19, 2021
95d99bf
Merge remote-tracking branch 'algoo/develop' into develop
a523 Dec 19, 2021
7c310c8
add test case for xcf
a523 Dec 26, 2021
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
12 changes: 12 additions & 0 deletions tests/input/xcf/test_xcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import typing

from PIL import Image
import imagehash
import pytest

from preview_generator.exception import UnavailablePreviewType
Expand All @@ -15,6 +16,7 @@
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
CACHE_DIR = "/tmp/preview-generator-tests/cache"
IMAGE_FILE_PATH = os.path.join(CURRENT_DIR, "the_xcf.xcf")
EXPECTED_IMAGE_PATH = os.path.join(CURRENT_DIR, "the_xcf_expected.jpeg")
FILE_HASH = hashlib.md5(IMAGE_FILE_PATH.encode("utf-8")).hexdigest()


Expand All @@ -35,6 +37,8 @@ def test_to_jpeg() -> None:
with Image.open(path_to_file) as jpeg:
assert jpeg.height in range(182, 184)
assert jpeg.width == 512
with Image.open(EXPECTED_IMAGE_PATH) as expected_jpeg:
assert check_images_almost_same(jpeg, expected_jpeg)


def test_get_nb_page() -> None:
Expand Down Expand Up @@ -104,3 +108,11 @@ def test_to_text() -> None:
assert manager.has_text_preview(file_path=IMAGE_FILE_PATH) is False
with pytest.raises(UnavailablePreviewType):
manager.get_text_preview(file_path=IMAGE_FILE_PATH, force=True)


def check_images_almost_same(image, another_image):
hash_size = 256 # control accuracy

image_hash = imagehash.average_hash(image, hash_size=hash_size)
another_image_hash = imagehash.average_hash(another_image, hash_size=hash_size)
return another_image_hash == image_hash
Binary file added tests/input/xcf/the_xcf_expected.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.