Fix PDF report: lire WebP via PIL au lieu de matplotlib.imread
matplotlib ne supporte pas WebP. Remplace plt.imread() par
PILImage.open().convert('RGB') dans generate_pdf_report.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -12,6 +12,7 @@ from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import rasterio
|
||||
from PIL import Image as PILImage
|
||||
|
||||
try:
|
||||
from rasterio.warp import transform as warp_transform
|
||||
@ -458,7 +459,6 @@ def tif_to_png(tif_file, vis_dir, resolution):
|
||||
facecolor='white', format='png')
|
||||
plt.close()
|
||||
|
||||
from PIL import Image as PILImage
|
||||
img = PILImage.open(str(png_temp))
|
||||
img.save(str(webp_file), format='WEBP', lossless=True)
|
||||
png_temp.unlink()
|
||||
@ -552,7 +552,7 @@ def generate_pdf_report(basename, vis_dir, pdf_dir, resolution):
|
||||
|
||||
for i, f in enumerate(situ_files):
|
||||
ax = fig.add_subplot(gs[0, i])
|
||||
img = plt.imread(str(f))
|
||||
img = np.array(PILImage.open(str(f)).convert('RGB'))
|
||||
ax.imshow(img)
|
||||
ax.axis('off')
|
||||
title = f.stem.replace(basename + '_', '').replace('_', ' ').title()
|
||||
@ -576,7 +576,7 @@ def generate_pdf_report(basename, vis_dir, pdf_dir, resolution):
|
||||
|
||||
for i, f in enumerate(page_files):
|
||||
ax = fig.add_subplot(gs[0, i])
|
||||
img = plt.imread(str(f))
|
||||
img = np.array(PILImage.open(str(f)).convert('RGB'))
|
||||
ax.imshow(img)
|
||||
ax.axis('off')
|
||||
title = f.stem.replace(basename + '_', '').replace('_', ' ').title()
|
||||
|
||||
Reference in New Issue
Block a user