通常、入稿の画像が全て300dpi以上であっても、拡大さらた場合、実際の解像度が足りなくなる可能性があります。ドキュメント内そのような画像がないか、確認が必要。
InDesignのリンクパネルには、画像の元のPPIと編集後(拡縮された後)PPIが表示される。上記の例だと、400ppi(元)/0.88(拡縮率)=455ppi(編集後)。
ところが、EPSは表示しない!(古いバージョンのInDeisgnでは一時期表示できたらしい?)。よく使う画像に対して、その情報を下記に纏めた(.space、.actualPpi、.effectivePpiは、graphicの属性。0は属性取れない;1は取れる):
| format | colorMode | .space | .actualPpi | .effectivePpi |
|---|---|---|---|---|
| eps | CMYK | 1 | 0 | 0 |
| Gray | ||||
| Mono | 0 | |||
| RGB | 1 | |||
| jpg | CMYK | 1 | 1 | 1 |
| Gray | ||||
| RGB | ||||
| png | Gray | 1 | 1 | 1 |
| Mono | ||||
| RGB | ||||
| psd/tiff | CMYK | 1 | 1 | 1 |
| Gray | ||||
| Mono | ||||
| RGB |
from appscript import *
from PIL import Image
import os
from pathlib import Path
#
DPI = 300 # 編集後のPPI
EXTS = (".jpg", ".jpeg", ".eps", ".png", ".tiff", ".tif", ".psd")
#
def get_eps_resolution(eps_file):
# TODO: is Illustrator eps
img = Image.open(eps_file)
if "Illustrator" in img.info["Creator"]:
print("----------Creator: ", img.info["Creator"], eps_file)
w, h = img.size # unit: pixel
tmp = img.info["HiResBoundingBox"].split(" ") # unit: point
tmp = [float(x) for x in tmp]
HiResWidth = tmp[2] - tmp[0]
HiResHeight = tmp[3] - tmp[1]
return round(w / HiResWidth * 72), round(h / HiResHeight * 72)
#
indd = app("Adobe InDesign 2022")
doc = indd.active_document
links = doc.links()
for link in links:
hfs_path = link.file_path() # HFS path
# change HFS path to POSIX path
# FIXME:外付けHD:例:'hd_name:aaa:bbb:ccc:ddd:Links:eee.eps'
file_path = hfs_path[hfs_path.index(":"):].replace(":", "/")
ext = Path(file_path).suffix.lower()
if ext not in EXTS:
continue
status = link.status()
if status == k.link_missing:
print("link missing: ", file_path)
continue
if status == k.out_of_date:
link.update()
# horizontal scale may not equal to vertical scale
scale = max(link.parent.horizontal_scale(), link.parent.vertical_scale())
# print(graphic())
if ext == ".eps":
resolution = get_eps_resolution(file_path)
# use width resolution: percentage
effective_ppi = resolution[0] / scale * 100
else:
graphic = link.parent
effective_ppi = min(graphic.effective_ppi())
#
if effective_ppi < DPI:
print(effective_ppi, file_path)
