返回顶部
a

aspect-calc

Calculate aspect ratios from dimensions and find missing width or height. Use when the user asks to calculate an aspect ratio, find the height for a given width, simplify a ratio, or resize dimensions while preserving aspect ratio.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
97
下载量
0
收藏
概述
安装方式
版本历史

aspect-calc

# Aspect Ratio Calculator Calculate simplified aspect ratios from pixel dimensions, find missing dimensions from a known ratio, and report decimal and percentage equivalents using GCD simplification. ## Input - Two dimensions (width and height in pixels), OR - A known ratio (e.g., `16:9`) and one dimension (width or height), to calculate the missing value ## Output - Simplified ratio (e.g., `16:9`) - Decimal ratio (e.g., `1.7778`) - Percentage (width as % of height, e.g., `177.78%`) - If solving for missing dimension: the calculated value ## Instructions 1. Parse the user's input to determine the mode: - **Mode A**: two pixel dimensions given → calculate ratio and metadata - **Mode B**: ratio + one dimension given → calculate the missing dimension 2. **Mode A — Ratio from dimensions:** a. Compute `divisor = GCD(width, height)` using the Euclidean algorithm: `GCD(a, b) = b === 0 ? a : GCD(b, a % b)` b. Simplified ratio: `(width / divisor):(height / divisor)` c. Decimal: `(width / height).toFixed(4)` d. Percentage: `(width / height * 100).toFixed(2)%` 3. **Mode B — Dimension from ratio:** a. Parse the ratio as `rW:rH` b. If width is given: `height = round(width * rH / rW)` c. If height is given: `width = round(height * rW / rH)` 4. Identify if the ratio matches a known standard and name it: - `16:9` → HD Video / Widescreen - `4:3` → Classic TV / Standard - `1:1` → Square - `21:9` → Ultrawide - `9:16` → Mobile Video / Story - `3:4` → Portrait Classic - `3:2` → 35mm Film - `2:3` → Portrait Photo 5. Output all results clearly. ## Options - `width`: positive integer - `height`: positive integer - `ratio`: string in `W:H` format — for Mode B - `locked`: if true, preserve the current ratio when one dimension changes ## Examples **Input:** "What is the aspect ratio of 1920x1080?" **Output:** - Simplified ratio: **16:9** (HD Video / Widescreen) - Decimal: 1.7778 - Percentage: 177.78% (width is 177.78% of height) **Input:** "I have a 16:9 video, width is 1280px — what height do I need?" **Output:** - Width: 1280px, Ratio: 16:9 - Height: **720px** - (1280 × 9 / 16 = 720) **Input:** "Simplify 2560x1440" **Output:** - Simplified ratio: **16:9** (HD Video / Widescreen) - Decimal: 1.7778 - Percentage: 177.78% **Input:** "What is the aspect ratio of 800x600?" **Output:** - Simplified ratio: **4:3** (Classic TV / Standard) - Decimal: 1.3333 - Percentage: 133.33% **Input:** "Give me height for a 21:9 ultrawide at 2560px width" **Output:** - Width: 2560px, Ratio: 21:9 - Height: **1097px** - (2560 × 9 / 21 ≈ 1097) ## Error Handling - If either dimension is 0 or negative, return an error: "Dimensions must be positive integers greater than 0." - If a ratio is provided in an invalid format (not `W:H`), ask the user to use the `W:H` format (e.g., `16:9`). - If both dimensions result in the same ratio numerator and denominator equal to 1 (e.g., prime dimensions with no common factor), output the ratio as-is and note it cannot be simplified further.

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 aspect-calc-1776085994 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 aspect-calc-1776085994 技能

通过命令行安装

skillhub install aspect-calc-1776085994

下载 Zip 包

⬇ 下载 aspect-calc v1.0.0

文件大小: 1.98 KB | 发布时间: 2026-4-14 10:03

v1.0.0 最新 2026-4-14 10:03
- Initial release of aspect-calc skill.
- Calculates and simplifies aspect ratios from pixel dimensions or known ratio plus a dimension.
- Outputs include the simplified ratio, decimal and percentage equivalents, and identifies standard ratios by name where possible.
- Supports calculating missing width or height while preserving aspect ratio.
- Includes user guidance, clear outputs, and detailed error handling for invalid or nonsensical inputs.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部