Добавьте воспроизводимые эксперименты по памяти и согласованности
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""Generate optional 40 MP regression images; requires Pillow==11.1.0."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
sys.dont_write_bytecode = True
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--output-dir', type=Path, default=Path('bin/decoder-fixtures'))
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
parser.error('install optional fixture dependency: pip install Pillow==11.1.0')
|
||||
spec = importlib.util.spec_from_file_location('decoder_memory',
|
||||
Path(__file__).with_name('decoder-memory.py'))
|
||||
decoder = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(decoder)
|
||||
args.output_dir.mkdir(parents=True, exist_ok=True)
|
||||
manifest = {'pillow_version': Image.__version__, 'fixtures': []}
|
||||
for mode, color in [('RGB', (25, 90, 160)), ('CMYK', (20, 40, 60, 10))]:
|
||||
path = args.output_dir / ('progressive-' + mode.lower() + '-444-40mp.jpg')
|
||||
with Image.new(mode, (8000, 5000), color) as image:
|
||||
image.save(path, format='JPEG', progressive=True, subsampling=0, quality=85)
|
||||
content, info = decoder.read_fixture(path, 'image/jpeg')
|
||||
if not info['progressive'] or any(value != 0x11 for value in info['sampling']):
|
||||
raise ValueError('encoder did not produce progressive 4:4:4')
|
||||
manifest['fixtures'].append({'name': path.name, 'mime': 'image/jpeg', **info,
|
||||
'bytes': len(content), 'sha256': hashlib.sha256(content).hexdigest()})
|
||||
wide = args.output_dir / 'wide-rgba64-40mp.png'
|
||||
decoder.write_rgba64_png(wide)
|
||||
content, info = decoder.read_fixture(wide, 'image/png')
|
||||
manifest['fixtures'].append({'name': wide.name, 'mime': 'image/png', **info,
|
||||
'bytes': len(content), 'sha256': hashlib.sha256(content).hexdigest()})
|
||||
(args.output_dir / 'manifest.json').write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8')
|
||||
print(json.dumps(manifest, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user