Skip to content

Add configurable image padding to core API and CLI#3

Merged
albertwoo merged 2 commits into
mainfrom
copilot/add-padding-option-support
Apr 24, 2026
Merged

Add configurable image padding to core API and CLI#3
albertwoo merged 2 commits into
mainfrom
copilot/add-padding-option-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

This adds explicit padding control to image exports so renders can reserve whitespace around the drawing. The CLI now accepts a single padding value, x/y padding, or per-side padding.

  • Core configuration

    • Adds per-side padding to ImageConfiguration:
      • PaddingLeft
      • PaddingTop
      • PaddingRight
      • PaddingBottom
    • Adds SetPadding(...) overloads for:
      • uniform padding
      • horizontal/vertical padding
      • per-side padding
  • Rendering behavior

    • Applies padding inside the configured output dimensions rather than increasing the final canvas size
    • Computes scale and offsets from the remaining drawable area
    • Rejects padding values that fully consume the drawable width or height
  • CLI support

    • Adds --padding / -p
    • Supports these forms:
      • --padding 10
      • --padding 10,20
      • --padding 10,20,30,40
    • Maps values as:
      • 10 → all sides
      • 10,20left/right=10, top/bottom=20
      • 10,20,30,40left,top,right,bottom
  • Docs and examples

    • Updates CLI help text and README usage examples to document the new option and value formats
  • Targeted coverage

    • Adds focused tests for default padding state, page-context padding math, and invalid padding that leaves no drawable area

Example:

cad-to-image drawing.dxf --width 1600 --height 900 --padding 24
cad-to-image drawing.dxf --width 1600 --height 900 --padding 24,12
cad-to-image drawing.dxf --width 1600 --height 900 --padding 24,12,40,20
var exporter = new ImageExporter();
exporter.Configuration.Width = 1600;
exporter.Configuration.Height = 900;
exporter.Configuration.SetPadding(24, 12, 40, 20);

Copilot AI linked an issue Apr 24, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/slaveOftime/ACadSharp.Image/sessions/5fa478be-5610-402f-8b14-6df8986b3770

Co-authored-by: albertwoo <8017681+albertwoo@users.noreply.github.com>
Copilot AI changed the title [WIP] Add padding options for core package and cli Add configurable image padding to core API and CLI Apr 24, 2026
Copilot AI requested a review from albertwoo April 24, 2026 08:52
@albertwoo albertwoo marked this pull request as ready for review April 24, 2026 13:15
@albertwoo albertwoo merged commit d0d131b into main Apr 24, 2026
1 check passed
@albertwoo albertwoo deleted the copilot/add-padding-option-support branch April 24, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support padding

2 participants