This is a cv but it looks blurry bcz i took screenshots of the pages. I want you convert this into hd so it looks good. It feels bad quality. Make whole cv hd quality. Don't change anything else
mkdir -p /tmp/workspace/cv-hd && cd /tmp/workspace/cv-hd && cp /tmp/workspace/attachments/1743c8c5-846c-4dca-9db8-f455711c24f5/1000538129.pdf . && python3 -c " import pypdf r = pypdf.PdfReader('1000538129.pdf') print('pages', len(r.pages)) for i,p in enumerate(r.pages): print(i, p.mediabox, len(p.images) if hasattr(p,'images') else 'n/a') "
cd /tmp/workspace/cv-hd && python3 -c " import pypdf r = pypdf.PdfReader('1000538129.pdf') for i,p in enumerate(r.pages): for j,img in enumerate(p.images): print(i,j,img.name, img.image.size, img.image.mode) img.image.save(f'page{i}_img{j}.png') " ls -la python3 -c "import cv2; print(cv2.__version__)" 2>&1 pip show realesrgan 2>&1 | head -5
cd /tmp/workspace/cv-hd && curl -s -o /dev/null -w "%{http_code}\n" https://github.com --max-time 10; python3 -c "import cv2; print(hasattr(cv2,'dnn_superres'))"
cd /tmp/workspace/cv-hd && pip install --user --quiet opencv-contrib-python-headless 2>&1 | tail -20
cd /tmp/workspace/cv-hd && python3 -m venv venv --system-site-packages 2>&1 | tail -5 && ./venv/bin/pip install --quiet opencv-contrib-python-headless 2>&1 | tail -20
cd /tmp/workspace/cv-hd && ./venv/bin/python3 -c "import cv2; print(cv2.__version__); sr=cv2.dnn_superres.DnnSuperResImpl_create(); print('ok')" mkdir -p models curl -sL -o models/FSRCNN_x4.pb "https://github.com/Saafke/FSRCNN_Tensorflow/raw/master/models/FSRCNN_x4.pb" --max-time 30 ls -la models/
cd /tmp/workspace/cv-hd && ./venv/bin/python3 -c " import cv2, numpy as np from PIL import Image sr = cv2.dnn_superres.DnnSuperResImpl_create() sr.readModel('models/FSRCNN_x4.pb') sr.setModel('fsrcnn', 4) for i in range(3): fn = f'page{i}_img0.png' img = cv2.imread(fn) print(i, 'input', img.shape) up = sr.upsample(img) print(i, 'output', up.shape) cv2.imwrite(f'page{i}_hd.png', up, [cv2.IMWRITE_PNG_COMPRESSION, 3]) " ls -la *.png
cd /tmp/workspace/cv-hd && ./venv/bin/python3 -c " import cv2, numpy as np, time sr = cv2.dnn_superres.DnnSuperResImpl_create() sr.readModel('models/FSRCNN_x4.pb') sr.setModel('fsrcnn', 4) for i in range(3): fn = f'page{i}_img0.png' img = cv2.imread(fn) print(i, 'input', img.shape) t0=time.time() up = sr.upsample(img) print(i, 'output', up.shape, 'took', time.time()-t0) cv2.imwrite(f'page{i}_hd.png', up, [cv2.IMWRITE_PNG_COMPRESSION, 3]) " ls -la *hd.png
cd /tmp/workspace/cv-hd && ./venv/bin/pip install --quiet pillow 2>&1 | tail -5 ./venv/bin/python3 -c " from PIL import Image, ImageFilter, ImageEnhance import numpy as np for i in range(3): im = Image.open(f'page{i}_hd.png').convert('RGB') # mild unsharp mask for crisper text edges im = im.filter(ImageFilter.UnsharpMask(radius=2, percent=90, threshold=2)) # slight contrast boost im = ImageEnhance.Contrast(im).enhance(1.05) im.save(f'page{i}_final.png', optimize=True) print(i, im.size) " ls -la *final.png