Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(covers): 批量重算优先保留居中正封

longmeidaof6c6335fc8ff
diff --git a/scripts/audit_cover_artwork.py b/scripts/audit_cover_artwork.py
index 2bacc610d..cf2cd0c68 100644
--- a/scripts/audit_cover_artwork.py
+++ b/scripts/audit_cover_artwork.py
@@ -55,9 +55,11 @@ def inspect(path, metadata, *, detector=None):
face_record = current_face(path, (width, height), title, detector)
face = face_record.get('face') if face_record.get('px') == [width, height] else None
full = crop.face_crosses_spine(width, height, face)
- layout = 'still' if full or crop.is_scene_cover(path.stem, title) or face_record.get('layout') == 'still' else ''
+ layout = 'still' if crop.is_scene_cover(path.stem, title) or face_record.get('layout') == 'still' else ''
proposed = saved if crop.is_manual(saved) and crop.is_current(saved, width, height) else crop.crop_record(
path.stem, width, height, crop.file_gradient(path), title=title, face=face, layout=layout)
+ if full and proposed['box']['method'] == crop.NONE:
+ layout = 'still'
if layout == 'still' and not crop.is_manual(proposed):
proposed['box'] = {'x0': 0, 'y0': 0, 'x1': width, 'y1': height, 'method': crop.NONE}
origin = origin_of(str(evidence.get('source_url') or ''))
diff --git a/tests/test_jav_poster_crop.py b/tests/test_jav_poster_crop.py
index b5ab996c3..63b8553d0 100644
--- a/tests/test_jav_poster_crop.py
+++ b/tests/test_jav_poster_crop.py
@@ -814,6 +814,21 @@ class BatchScriptTests(unittest.TestCase):
self.assertEqual((proposed['box']['method'], layout), (NONE, 'still'))
self.assertEqual(row['x0'], 0)
+ def test_offline_reframing_preserves_a_centered_front_with_padding(self):
+ from peach.cover_artwork import FACE_ALGORITHM_VERSION
+ target = self.root / 'HHL-018.jpg'
+ Image.new('RGB', (840, 563), 'gray').save(target)
+ target.with_suffix('.face.json').write_text(json.dumps({
+ 'version': FACE_ALGORITHM_VERSION, 'px': [840, 563],
+ 'face': {'cx': .487, 'cy': .231, 'w': .135, 'h': .242, 'score': .93},
+ }), encoding='utf-8')
+ profile = jav_poster_crop.ColumnProfile([.02] * 224 + [.2] * 394 + [.02] * 222, [0.] * 840)
+ profile.seams[224] = profile.seams[618] = .95
+ with patch.object(jav_poster_crop, 'file_gradient', return_value=profile):
+ row, proposed, _, layout = batch_script('audit_cover_artwork').inspect(target, self.root / 'metadata')
+ self.assertEqual((proposed['box']['method'], layout), (CENTER, ''))
+ self.assertEqual((row['x0'], proposed['box']['x1']), (225, 618))
+
def test_audit_refreshes_legacy_front_only_faces_before_classifying_the_cover(self):
from peach.face_detect import Face
from peach.cover_artwork import FACE_ALGORITHM_VERSION