Skip to content

Commit

Permalink
Reduce repository size by only comparing the hash of the image in hei…
Browse files Browse the repository at this point in the history
…f-convert test
  • Loading branch information
NeverMendel committed Nov 1, 2023
1 parent 1d7874c commit 4fcd98e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
Binary file removed tests/image.jpg
Binary file not shown.
Binary file removed tests/image.png
Binary file not shown.
18 changes: 12 additions & 6 deletions tests/test-docker-image.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#!/bin/bash

docker run -v "$(pwd)":/usr/app/out --rm nevermendel/heif-convert image.heic -f jpg -q 90 -o result
docker run -v "$(pwd)":/usr/app/out --rm nevermendel/heif-convert image.heic -f png -o result
docker run -v "$(pwd)":/usr/app/out --rm nevermendel/heif-convert image.heic -f jpg -q 90
docker run -v "$(pwd)":/usr/app/out --rm nevermendel/heif-convert image.heic -f png

status_code=0

if ! cmp -s image.jpg result.jpg; then
echo "jpg image is different"
expected_jpg_hash="3fb5fff1c6bb5f0f5d76d9839f82564d857e81f71e748da1ec480affde10fa8e"
actual_jpg_hash=$(sha256sum image.jpg | awk '{print $1}')

if [ "$expected_jpg_hash" != "$actual_jpg_hash" ]; then
echo "JPG image hash differs from expected. Expected: ${expected_jpg_hash}, Actual: ${actual_jpg_hash}"
status_code=1
fi

if ! cmp -s image.png result.png; then
echo "png image is different"
expected_png_hash="f6e29566f59bcce7d0486c9745602354cd903da0dbfce3facb8bba476abeee54"
actual_png_hash=$(sha256sum image.png | awk '{print $1}')

if [ "$expected_png_hash" != "$actual_png_hash" ]; then
echo "PNG image hash differs from expected. Expected: ${expected_png_hash}, Actual: ${actual_png_hash}"
status_code=1
fi

Expand Down
18 changes: 12 additions & 6 deletions tests/test-script.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#!/bin/bash

heif-convert image.heic -f jpg -q 90 -o result
heif-convert image.heic -f png -o result
heif-convert image.heic -f jpg -q 90
heif-convert image.heic -f png

status_code=0

if ! cmp -s image.jpg result.jpg; then
echo "jpg image is different"
expected_jpg_hash="3fb5fff1c6bb5f0f5d76d9839f82564d857e81f71e748da1ec480affde10fa8e"
actual_jpg_hash=$(sha256sum image.jpg | awk '{print $1}')

if [ "$expected_jpg_hash" != "$actual_jpg_hash" ]; then
echo "JPG image hash differs from expected. Expected: ${expected_jpg_hash}, Actual: ${actual_jpg_hash}"
status_code=1
fi

if ! cmp -s image.png result.png; then
echo "png image is different"
expected_png_hash="f6e29566f59bcce7d0486c9745602354cd903da0dbfce3facb8bba476abeee54"
actual_png_hash=$(sha256sum image.png | awk '{print $1}')

if [ "$expected_png_hash" != "$actual_png_hash" ]; then
echo "PNG image hash differs from expected. Expected: ${expected_png_hash}, Actual: ${actual_png_hash}"
status_code=1
fi

Expand Down

0 comments on commit 4fcd98e

Please sign in to comment.