make_image_square 1.0.0 copy "make_image_square: ^1.0.0" to clipboard
make_image_square: ^1.0.0 copied to clipboard

Compute square canvas size and letterbox padding so an image fits 1:1 without cropping.

make_image_square #

Tiny helper that turns any image size into a 1:1 layout plan: square canvas size plus left/right/top/bottom padding so you can fit without cropping.

Useful when you need the math for letterboxing / pillarboxing before you draw to a canvas, generate CSS object-fit-style boxes, or prep assets for Instagram and profile photos.

Install #

dart pub add make_image_square

Usage #

import 'package:make_image_square/make_image_square.dart';

// 1200×800 landscape → 1200×1200 with top/bottom pads
final layout = makeImageSquare(1200, 800);
// canvas 1200, padTop 200, padBottom 200

// Force a specific square edge (e.g. 1080 for feed posts)
final ig = makeImageSquare(1200, 800, canvasSize: 1080);

// Padding-only helper
final pads = squarePadding(800, 1200); // portrait → pad left/right

Modes #

Mode Behavior
fit (default) Entire image visible; empty bands become padding
fill Image covers the square; caller is expected to crop overflow

Notes #

  • This package only returns numbers. It does not decode or rewrite image files.
  • Prefer not to wire up dart:ui yourself? There is an in-browser padder for 1:1 posts that can letterbox, blur the frame, or crop without a Flutter project.

License #

MIT

0
likes
140
points
77
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Compute square canvas size and letterbox padding so an image fits 1:1 without cropping.

Homepage

Topics

#image #layout #square #padding

License

MIT (license)

More

Packages that depend on make_image_square