Skip to content

P4-6: Compress/optimize images #85

@jongalloway

Description

@jongalloway

Description

Downscale images that are larger than their display dimensions warrant. Allow target DPI selection (e.g., 150 DPI for screen, 300 DPI for print). Support format conversion (BMP/TIFF to PNG/JPEG for better compression). Return compression statistics before/after per image.

Technical Approach

  • Query all images in the presentation via P4-2 patterns
  • For each image part: extract pixel dimensions, current size
  • Query slide shapes to determine display size (EMU to pixels)
  • Calculate optimal resolution vs. display size (DPI-based)
  • Use image processing library (likely SkiaSharp or System.Drawing) to downscale/re-encode
  • Replace the image part in the package with optimized version
  • Validate with OpenXmlValidator
  • Return compression stats: before/after per image, total savings

Architectural Decision: Image Processing Library

Choose between:

  1. SkiaSharp (cross-platform, modern, no Windows-only dependencies)
  2. System.Drawing.Common (legacy, Windows-only on .NET, but pre-installed)
  3. ImageSharp (pure .NET, slower than SkiaSharp)

Recommendation: SkiaSharp. Pro: cross-platform, high quality. Con: new NuGet dependency. Document in README and NuGet dependency tracking.

Acceptance Criteria

  • Tool accepts file path, target DPI, optional format conversion flag
  • Scans all images in presentation
  • For each image: measures display vs. pixel dimensions
  • Downscales images that exceed target DPI relative to display size
  • Optionally converts BMP/TIFF to PNG/JPEG
  • Re-encodes images with appropriate compression (JPEG quality ~85%)
  • Updates image parts in the package
  • Validates with OpenXmlValidator
  • Returns: images processed, original size, compressed size, total savings
  • Unit tests: 3+ cases (no compression needed, significant downscaling, format conversion)
  • E2E test: compress a presentation with mixed image sizes, open in PowerPoint, verify visual quality and size reduction

Tier

Tier 2 — Write Operations (optimization)

Size Estimate

Large (6–8 hours, includes dependency research and E2E validation)

Dependencies

None direct; pairs well with P4-2 for media analysis

Risk Mitigation

  • Test round-trip: compressed images must display correctly in PowerPoint
  • Document JPEG quality trade-offs (85% is recommended starting point)
  • Log before/after metadata so users can validate compression is acceptable

Metadata

Metadata

Assignees

No one assigned

    Labels

    go:needs-researchNeeds investigationmediaMedia/image/video operationsoptimizationOptimization workphase-4Phase 4: Presentation OptimizationsquadSquad triage inbox — Lead will assign to a membersquad:copilotAssigned to @copilot (Coding Agent) for autonomous worksquad:shiherlisAssigned to Shiherlis (Tester)type:featureNew capability

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions