Compare both
~/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12
mkdir -p "/tmp/workspace/compare-bills" && python -c "from PIL import Image; p='/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/IMG_3777.heic'; im=Image.open(p); im.save('/tmp/workspace/compare-bills/IMG_3777.jpg')"
| Item | Listed rate | Charged amount |
|---|---|---|
| Surgery Das, 2 volumes | ₹1,595 | ₹2,100 |
| Ophthalmology | ₹1,625 | ₹1,140 |
| Mudaliar | ₹1,495 | ₹1,090 |
| O.P. Khurana, 2 volumes | ₹1,595 | ₹2,140 |
| Hepatology? | ₹1,195 | ₹1,540 |
| Anatomy | ₹1,629 | ₹1,100 |
| Maheshwari, 2 volumes | ₹795 | ₹1,160 |
| Agappe? | ₹1,695 | ₹1,185 |
~/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12
file "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/IMG_3777 (1).heic" "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/e516774a-8a7a-4392-9b9a-e359c9f2a78a (1).jpg" && ls -lh "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12"
which heif-convert || which convert || which magick || true
mkdir -p "/tmp/workspace/compare-bills" && convert "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/IMG_3777 (1).heic[0]" "/tmp/workspace/compare-bills/IMG_3777_converted.jpg" && file "/tmp/workspace/compare-bills/IMG_3777_converted.jpg"
which tesseract && tesseract "/tmp/workspace/compare-bills/IMG_3777_converted.jpg" stdout 2>/dev/null
python -m http.server 8765 --directory "/tmp/workspace/compare-bills" >/tmp/workspace/compare-bills/http.log 2>&1 &
python -c "import importlib.util; print('easyocr', bool(importlib.util.find_spec('easyocr'))); print('paddleocr', bool(importlib.util.find_spec('paddleocr'))); print('keras_ocr', bool(importlib.util.find_spec('keras_ocr'))); print('cv2', bool(importlib.util.find_spec('cv2')))"
pip install --user easyocr -q
mkdir -p "/tmp/workspace/compare-bills/python" && pip install --target "/tmp/workspace/compare-bills/python" easyocr -q
python - <<'PY' from PIL import Image import imagehash p1='/tmp/workspace/compare-bills/IMG_3777_converted.jpg' p2='/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/e516774a-8a7a-4392-9b9a-e359c9f2a78a (1).jpg' a=Image.open(p1).convert('RGB'); b=Image.open(p2).convert('RGB') print('HEIC', a.size, 'JPG', b.size) for f in [imagehash.phash,imagehash.dhash,imagehash.average_hash]: print(f.__name__,f(a),f(b),'distance',f(a)-f(b)) # ImageMagick similarity after resizing PY compare -metric RMSE "/tmp/workspace/compare-bills/IMG_3777_converted.jpg" "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/e516774a-8a7a-4392-9b9a-e359c9f2a78a (1).jpg" null: 2>&1 || true
python -c "import importlib.util; print([(x, bool(importlib.util.find_spec(x))) for x in ['pytesseract','transformers','torch','keras','rapidocr_onnxruntime','doctr','surya']])" && du -sh "/tmp/workspace/compare-bills"
python - <<'PY' import cv2, numpy as np paths=['/tmp/workspace/compare-bills/IMG_3777_converted.jpg','/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/e516774a-8a7a-4392-9b9a-e359c9f2a78a (1).jpg'] for p in paths: x=cv2.imread(p,0); x=cv2.resize(x,(32,32)); d=cv2.dct(np.float32(x)); h=d[:8,:8]; bits=h>np.median(h); print(p, bits.astype(int).ravel().tolist(), 'mean',x.mean()) a=[] for p in paths: x=cv2.imread(p,0); x=cv2.resize(x,(32,32)); d=cv2.dct(np.float32(x)); h=d[:8,:8]; a.append(h>np.median(h)) print('hamming',np.count_nonzero(a[0]!=a[1]),'/64') PY
sha256sum "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/e516774a-8a7a-4392-9b9a-e359c9f2a78a.jpg" "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/e516774a-8a7a-4392-9b9a-e359c9f2a78a (1).jpg" "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/IMG_3777.heic" "/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/IMG_3777 (1).heic" && python - <<'PY' from PIL import Image for p in ['/tmp/workspace/compare-bills/IMG_3777_converted.jpg','/tmp/workspace/attachments/dd2d38d0-696e-4f7b-be26-f861f197ce12/e516774a-8a7a-4392-9b9a-e359c9f2a78a (1).jpg']: im=Image.open(p); print(p, im.size) PY
IMG 3777 converted
Image · JPG