import fitz # PyMuPDF
import sys
input_path = sys.argv[1]
output_path = sys.argv[2]
TARGET_RATIO = 1488 / 2266 # ≈ 0.6569 (portrait iPad Mini 7)
doc = fitz.open(input_path)
for page in doc:
rect = page.rect
height = rect.height
target_width = height * TARGET_RATIO
crop_left = (rect.width - target_width) / 2
new_rect = fitz.Rect(crop_left, 0, crop_left + target_width, height)
page.set_cropbox(new_rect)
doc.save(output_path)