Skip to content

Instantly share code, notes, and snippets.

View kennytrytek-wf's full-sized avatar

Kenny Trytek kennytrytek-wf

  • Workiva
  • Ames, IA
View GitHub Profile
@kennytrytek-wf
kennytrytek-wf / Multi-Image Print Optimizer.md
Last active January 6, 2026 19:07
Scale one or more images to fit within a certain size, and add an outline of the desired thickness.

This Python script processes images by proportionally scaling them down to fit within a specified maximum dimension (default 2 inches) and adding a black border around them. It uses the Pillow library to handle image manipulation and preserves the aspect ratio of each image while converting dimensions from inches to pixels based on a configurable DPI setting (default 300).

To use the script, run it from the command line with two arguments: python image_outline_scaler.py <input_directory> <output_directory>. The script scans the input directory for supported image formats (JPG, PNG, BMP, GIF, TIFF, WebP), processes each image by scaling and adding borders, and saves the results to the output directory with the same filenames. It provides feedback on successful and failed conversions.

This tool is ideal for preparing images for inclusion in multi-image documents where file size optimization is critical, such as creating reports, presentations, or documentation compilations. The uniform scaling and border styl

@kennytrytek-wf
kennytrytek-wf / Image-Printer.md
Last active October 8, 2025 20:28
Split tall or wide images into files that can be printed. Good for infographics. AI-generated :D

Image Printer

A Python script that takes an image file and splits it into printable 8.5x11 inch pages.

Features

  • Automatic orientation detection: Uses landscape orientation for wide images, portrait for tall images
  • Smart scaling: Scales down large images to fit page dimensions while maintaining aspect ratio
  • Page splitting: Divides scaled images into page-sized pieces in collated reading order
  • High-quality output: Generates 300 DPI JPEG files suitable for printing
package crashreportprocessor
import (
"context"
"encoding/json"
"fmt"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/pdata/pcommon"