Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

feat(image-orientation): add UI-free contact sheet review

hugohe39ebc4876eef9
diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.md
index e8e683e1..aa5ef427 100644
--- a/skills/ppt-master/scripts/docs/conversion.md
+++ b/skills/ppt-master/scripts/docs/conversion.md
@@ -550,14 +550,40 @@ Markdown output.
when the converter derives a title-based filename.
-## `rotate_images.py`
+## Image Orientation Review
-Fix image EXIF orientation in downloaded or imported assets.
+Run this review when the user requests orientation correction, converted text
+asks the reader to rotate the device, or a downloaded asset is visibly
+sideways. EXIF and dimensions may trigger review, but they cannot determine the
+semantic direction of pixels that are already stored sideways.
+
+Generate a labeled static contact sheet. This command previews the first frame
+after EXIF normalization and does not modify source images:
+
+```bash
+python3 scripts/rotate_images.py sheet <images_directory>
+```
+
+The default output is
+`<images_directory>/../analysis/<directory>_orientation_contact_sheet.jpg`.
+Inspect it with the current multimodal agent, identify only visually confirmed
+rotations, and write a temporary JSON list. `rotation` is clockwise degrees and
+must be `90`, `180`, or `270`:
+
+```json
+[
+ {"path": "/absolute/path/to/sideways.jpg", "rotation": 270}
+]
+```
+
+Apply the confirmed fixes and regenerate image facts:
```bash
-python3 scripts/rotate_images.py auto projects/xxx_files
-python3 scripts/rotate_images.py gen projects/xxx_files
-python3 scripts/rotate_images.py fix fixes.json
+python3 scripts/rotate_images.py fix /tmp/orientation_fixes.json
+python3 scripts/analyze_images.py <images_directory>
```
-Use this when extracted photos appear sideways after conversion or import.
+Do not infer a rotation from prose, EXIF, or aspect ratio alone, and do not
+launch the HTML `gen` command in source intake. `auto` remains an in-place EXIF
+normalizer. `gen` is a compatibility UI that runs the same normalization before
+writing HTML; neither belongs to source intake.
diff --git a/skills/ppt-master/scripts/rotate_images.py b/skills/ppt-master/scripts/rotate_images.py
index 3c784ed9..f1e30aab 100644
--- a/skills/ppt-master/scripts/rotate_images.py
+++ b/skills/ppt-master/scripts/rotate_images.py
@@ -6,6 +6,7 @@ Provides visual image orientation filtering, fix code generation,
and batch image rotation functionality.
Usage:
+ python3 scripts/rotate_images.py sheet <images_directory>
python3 scripts/rotate_images.py gen <images_directory>
python3 scripts/rotate_images.py fix <fixes.json>
python3 scripts/rotate_images.py auto <images_directory>
@@ -23,7 +24,13 @@ from console_encoding import configure_utf8_stdio
configure_utf8_stdio()
-from PIL import Image, ExifTags
+from PIL import (
+ ExifTags,
+ Image,
+ ImageDraw,
+ ImageFont,
+ ImageOps,
+)
ORIENTATION_TAG_ID = 274 # 0x0112
@@ -123,6 +130,153 @@ class ImageRotator:
return fixed_count
+ def generate_contact_sheet(
+ self,
+ target_dir: Union[str, Path],
+ output_path: Optional[Union[str, Path]] = None,
+ ) -> str:
+ """Generate a labeled, read-only contact sheet for visual review."""
+ target_path = Path(target_dir).resolve()
+ if not target_path.is_dir():
+ raise FileNotFoundError(f"Directory not found: {target_path}")
+
+ valid_exts = {
+ '.bmp', '.gif', '.jpeg', '.jpg', '.png', '.tif', '.tiff', '.webp'
+ }
+ files = sorted(
+ (
+ path for path in target_path.iterdir()
+ if path.is_file() and path.suffix.lower() in valid_exts
+ ),
+ key=lambda path: self._natural_sort_key(path.name),
+ )
+ if not files:
+ raise ValueError("No image files found")
+
+ columns = 6
+ thumbnail_width = 180
+ thumbnail_height = 180
+ label_height = 34
+ padding = 12
+ cell_width = thumbnail_width + padding * 2
+ cell_height = thumbnail_height + label_height + padding * 2
+ rows = (len(files) + columns - 1) // columns
+
+ sheet = Image.new(
+ 'RGB',
+ (columns * cell_width, rows * cell_height),
+ 'white',
+ )
+ draw = ImageDraw.Draw(sheet)
+ try:
+ font = ImageFont.truetype('DejaVuSans.ttf', 13)
+ except OSError:
+ font = ImageFont.load_default()
+ resampling = getattr(Image, 'Resampling', Image)
+
+ for index, file_path in enumerate(files):
+ column = index % columns
+ row = index // columns
+ cell_x = column * cell_width
+ cell_y = row * cell_height
+ draw.rectangle(
+ (
+ cell_x,
+ cell_y,
+ cell_x + cell_width - 1,
+ cell_y + cell_height - 1,
+ ),
+ outline='#D0D7DE',
+ )
+
+ details = 'unreadable'
+ try:
+ with Image.open(file_path) as img:
+ if getattr(img, 'is_animated', False):
+ img.seek(0)
+ prepared = ImageOps.exif_transpose(img)
+ try:
+ source_width, source_height = prepared.size
+ preview = prepared.convert('RGBA')
+ finally:
+ if prepared is not img:
+ prepared.close()
+
+ preview.thumbnail(
+ (thumbnail_width, thumbnail_height),
+ resampling.LANCZOS,
+ )
+ preview_x = cell_x + padding + (thumbnail_width - preview.width) // 2
+ preview_y = cell_y + padding + (thumbnail_height - preview.height) // 2
+ sheet.paste(preview, (preview_x, preview_y), preview)
+ preview.close()
+ details = f'{source_width}x{source_height}'
+ except (
+ EOFError,
+ OSError,
+ SyntaxError,
+ ValueError,
+ Image.DecompressionBombError,
+ ):
+ draw.line(
+ (
+ cell_x + padding,
+ cell_y + padding,
+ cell_x + cell_width - padding,
+ cell_y + thumbnail_height,
+ ),
+ fill='#CF222E',
+ width=2,
+ )
+ draw.line(
+ (
+ cell_x + cell_width - padding,
+ cell_y + padding,
+ cell_x + padding,
+ cell_y + thumbnail_height,
+ ),
+ fill='#CF222E',
+ width=2,
+ )
+
+ label = file_path.name
+ if len(label) > 30:
+ label = f'{label[:13]}...{label[-14:]}'
+ label_y = cell_y + padding + thumbnail_height + 2
+ for line_index, text in enumerate((label, details)):
+ text_bbox = draw.textbbox((0, 0), text, font=font)
+ text_width = text_bbox[2] - text_bbox[0]
+ draw.text(
+ (
+ cell_x + (cell_width - text_width) / 2,
+ label_y + line_index * 15,
+ ),
+ text,
+ fill='#24292F',
+ font=font,
+ )
+
+ if output_path is None:
+ resolved_output = (
+ target_path.parent
+ / 'analysis'
+ / f'{target_path.name}_orientation_contact_sheet.jpg'
+ )
+ else:
+ resolved_output = Path(output_path).expanduser().resolve()
+
+ suffix = resolved_output.suffix.lower()
+ if suffix not in {'.jpg', '.jpeg', '.png'}:
+ sheet.close()
+ raise ValueError("Contact sheet output must use .jpg, .jpeg, or .png")
+ resolved_output.parent.mkdir(parents=True, exist_ok=True)
+ if suffix == '.png':
+ sheet.save(resolved_output, format='PNG', optimize=True)
+ else:
+ sheet.save(resolved_output, format='JPEG', quality=90, optimize=True)
+ sheet.close()
+ return str(resolved_output)
+
def generate_html_tool(self, target_dir: str, output_filename: str = "image_orientation_tool.html") -> str:
"""Generate the image filtering HTML tool
@@ -532,6 +686,7 @@ def build_parser() -> argparse.ArgumentParser:
description="Manage image orientation and manual rotation fixes.",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""Examples:
+ python3 scripts/rotate_images.py sheet projects/demo/images
python3 scripts/rotate_images.py gen projects/demo/images
python3 scripts/rotate_images.py fix fixes.json
python3 scripts/rotate_images.py auto projects/demo/images
@@ -539,6 +694,17 @@ def build_parser() -> argparse.ArgumentParser:
)
subparsers = parser.add_subparsers(dest="command", required=True)
+ sheet = subparsers.add_parser(
+ "sheet",
+ help="Generate a static contact sheet without modifying images",
+ )
+ sheet.add_argument("images_directory", help="Images directory")
+ sheet.add_argument(
+ "-o",
+ "--output",
+ help="Output .jpg or .png path (default: sibling analysis directory)",
+ )
+
gen = subparsers.add_parser("gen", help="Generate the visual rotation HTML tool")
gen.add_argument("images_directory", help="Images directory")
@@ -556,6 +722,18 @@ def main(argv: list[str] | None = None) -> int:
args = parser.parse_args(argv)
rotator = ImageRotator()
+ if args.command == 'sheet':
+ try:
+ output_path = rotator.generate_contact_sheet(
+ args.images_directory,
+ args.output,
+ )
+ print(f"[REPORT] Image orientation contact sheet: {output_path}")
+ except (OSError, ValueError) as e:
+ print(f"[ERROR] Contact sheet generation failed: {e}")
+ return 1
+ return 0
+
if args.command == 'gen':
target_dir = args.images_directory
try:
diff --git a/skills/ppt-master/workflows/generate-pptx.md b/skills/ppt-master/workflows/generate-pptx.md
index 2ea01748..cc412d82 100644
--- a/skills/ppt-master/workflows/generate-pptx.md
+++ b/skills/ppt-master/workflows/generate-pptx.md
@@ -70,6 +70,11 @@ Use `-o` only when a specific output file/directory is required; with multiple
inputs or directory inputs, `-o` is an output directory. Backend converter details are documented in
[`scripts/docs/conversion.md`](../scripts/docs/conversion.md).
+**Source-image orientation trigger**: Before Step 2, follow
+[`conversion.md`](../scripts/docs/conversion.md) § Image Orientation Review when
+the user requests correction, converted text asks for rotated viewing, or a
+downloaded asset is visibly sideways. Do not launch its legacy HTML tool.
+
After reading direct and converted content, assess factual sufficiency:
| Material state | Action |
diff --git a/skills/ppt-master/workflows/profiles/quick-generate.md b/skills/ppt-master/workflows/profiles/quick-generate.md
index 43b603ef..b12996bd 100644
--- a/skills/ppt-master/workflows/profiles/quick-generate.md
+++ b/skills/ppt-master/workflows/profiles/quick-generate.md
@@ -88,6 +88,11 @@ ambiguous and `-o` only for a required output path; with several or directory
inputs, `-o` names an output directory. A PPTX is converted to Markdown here and
receives its project analysis during the import step below.
+**Source-image orientation trigger**: Before import and initialization, follow
+[`conversion.md`](../../scripts/docs/conversion.md) § Image Orientation Review
+when correction is requested, converted text asks for rotated viewing, or a
+downloaded asset is visibly sideways. Skip the legacy HTML tool.
+
After reading every direct and converted source, assess factual sufficiency:
| Material state | Action |