Agent skill
portrait-resizer
Convert videos to 9:16 portrait format (1080x1920) for TikTok, YouTube Shorts, Instagram Reels, and Facebook Reels. Supports smart cropping (focus on faces/subjects), center cropping, and letterboxing. Maintains aspect ratio and quality.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/portrait-resizer
Metadata
Additional technical details for this skill
- formats
- 9:16 portrait
- version
- 1.0
SKILL.md
Portrait Resizer
This skill converts horizontal videos to vertical 9:16 portrait format suitable for short-form content platforms.
When to Use
- User wants to create TikTok videos from horizontal content
- Converting YouTube videos to YouTube Shorts format
- Creating Instagram Reels from widescreen video
- Preparing content for Facebook Reels
- Converting any 16:9 video to 9:16 format
Supported Platforms
- TikTok: 1080x1920, 9:16, 15-60s
- YouTube Shorts: 1080x1920, 9:16, 15-60s
- Instagram Reels: 1080x1920, 9:16, 15-90s
- Facebook Reels: 1080x1920, 9:16, 15-90s
Available Scripts
scripts/resize_to_portrait.py
Convert video to 9:16 portrait format.
Usage:
python skills/portrait-resizer/scripts/resize_to_portrait.py <video_path> [options]
Options:
--width: Target width (default: 1080)--height: Target height (default: 1920)--mode: Resize mode (smart, center, letterbox) - default: smart--focus-x: Focus point X coordinate (0-1, smart mode)--focus-y: Focus point Y coordinate (0-1, smart mode)--output, -o: Output video path (default:<video_path>_portrait.mp4)--quality: Quality preset (fast, medium, slow) - default: fast
Examples:
Basic resize to portrait:
python skills/portrait-resizer/scripts/resize_to_portrait.py video.mp4
Resize with smart cropping:
python skills/portrait-resizer/scripts/resize_to_portrait.py video.mp4 --mode smart
Resize with specific focus point:
python skills/portrait-resizer/scripts/resize_to_portrait.py video.mp4 --mode smart --focus-x 0.7 --focus-y 0.5
Center crop:
python skills/portrait-resizer/scripts/resize_to_portrait.py video.mp4 --mode center
Letterbox (padding on top/bottom):
python skills/portrait-resizer/scripts/resize_to_portrait.py video.mp4 --mode letterbox
scripts/batch_resize.py
Resize multiple videos to portrait format.
Usage:
python skills/portrait-resizer/scripts/batch_resize.py --input-dir <dir> [options]
Options:
--input-dir: Directory with videos to resize--output-dir: Output directory (default:./portrait/)- All other options from
resize_to_portrait.py
Example:
python skills/portrait-resizer/scripts/batch_resize.py --input-dir ./clips/ --output-dir ./portrait_clips/
Resize Modes
Smart Crop (Default)
Intelligently crops to focus on subjects:
- Detects faces and main subjects
- Analyzes motion and activity
- Centers on the most important area
- Best for talking-head, interviews, tutorials
Center Crop
Simple center crop:
- Crops from the center of the video
- May cut off subjects on edges
- Fast and predictable
- Best when subject is always centered
Letterbox
Pillarbox/black bars:
- Maintains full width of video
- Adds padding on top and bottom
- No content loss
- Best for showing full context
Output Specifications
Default Output:
- Resolution: 1080x1920
- Aspect Ratio: 9:16
- Video Codec: H.264 (libx264)
- Audio Codec: AAC
- Container: MP4
Platform-Specific Presets:
presets = {
'tiktok': {
'width': 1080,
'height': 1920,
'bitrate': '4000k',
'fps': 30
},
'youtube_shorts': {
'width': 1080,
'height': 1920,
'bitrate': '4000k',
'fps': 30
},
'instagram_reels': {
'width': 1080,
'height': 1920,
'bitrate': '4000k',
'fps': 30
}
}
Output Format
{
"success": true,
"input_path": "video.mp4",
"output_path": "video_portrait.mp4",
"input_resolution": {
"width": 1920,
"height": 1080
},
"output_resolution": {
"width": 1080,
"height": 1920
},
"mode": "smart",
"focus_point": {
"x": 0.65,
"y": 0.50
},
"quality_settings": {
"preset": "fast",
"crf": 23
}
}
Smart Crop Algorithm
- Face Detection: Uses OpenCV Haar Cascades to detect faces
- Motion Analysis: Identifies areas with highest motion activity
- Center Weighting: Gives slight preference to center (0.5, 0.5)
- Subject Tracking: Maintains focus on moving subjects
- Fallback: Uses center crop if no faces/motion detected
Integration with Other Skills
After resizing, you can use these skills:
subtitle-overlay: Add captions to portrait videoautocut-shorts: Full workflow with all steps
Common Workflow
- User provides video file
- Find highlights using
highlight-scanner - Trim segments using
video-trimmer - Resize to portrait using this skill
- Add subtitles using
subtitle-overlay - Export final clips
Tips
- Resize AFTER trimming (more efficient)
- Use smart crop for talking-head content
- Use center crop for action/sports content
- Use letterbox for cinematic/wide shots
- Test different focus points for best results
- Face detection works best with clear frontal faces
Performance
- Simple crop/resize: ~2-5 seconds per minute
- Smart crop with face detection: ~5-10 seconds per minute
- Batch processing: Parallel processing available
Error Handling
- Small videos: Minimum resolution checks
- Already portrait: Returns as-is or error
- Face detection failure: Falls back to center crop
- Codec issues: Re-encodes with standard codecs
References
- FFmpeg crop filter: https://ffmpeg.org/ffmpeg-filters.html#crop
- FFmpeg scale filter: https://ffmpeg.org/ffmpeg-filters.html#scale
- OpenCV face detection: https://docs.opencv.org/
Didn't find tool you were looking for?