Overview
Introduction
This tool expands a JPG's canvas by independent margin amounts on each of the four sides, entirely client-side.
It's the asymmetric sibling of JPG Border Adder: use it whenever you need different spacing on different sides rather than a uniform frame.
What Is JPG Margin Adder?
A client-side per-side canvas-expansion tool: you specify a top, right, bottom, and left margin (any of which can be 0 or a different value from the others), pick a fill color, and the tool builds a larger canvas with the original photo placed at the correct offset.
It's conceptually the same idea as a CSS `margin` shorthand, but it physically grows the image file rather than just shifting layout.
How JPG Margin Adder Works
The tool computes the new canvas width as the original width plus the left and right margins, and the new height as the original height plus the top and bottom margins, fills the entire new canvas with the chosen color, then copies the original photo's pixels in at an offset of (left, top).
Each margin value is validated independently as a non-negative whole number before any drawing happens.
When To Use JPG Margin Adder
Use it to add extra space above and below a photo for a caption area, extra space to one side for a sidebar layout, or to match an asymmetric spacing spec from a design system.
If you just need the same spacing on all four sides, JPG Border Adder or JPG Padding Adder are simpler options.
Often used alongside JPG Margin Remover, JPG Border Adder and PNG Space Adder.
Features
Advantages
- Runs entirely client-side.
- Full independent control over all four sides in one pass.
- Same underlying canvas-expand-and-fill approach as the border/padding tools, just generalized to per-side amounts.
Limitations
- Requires four separate inputs instead of one uniform value, which is more setup for the common symmetric case.
- Very large asymmetric margins on an already-large photo can hit the site's 4096px maximum dimension.
Examples
Best Practices & Notes
Best Practices
- Use 0 for any side you don't want to change rather than guessing a small nonzero value.
- Pick a fill color that matches your intended layout background so the seam between photo and margin isn't visually jarring.
Developer Notes
addJpgMargin validates all four margin values independently, computes the expanded canvas size from (left+right) and (top+bottom), fills it with the chosen opaque color, then copies the source pixels in at the (left, top) offset; distinct math from addJpgBorder's single-thickness expansion, since each side can differ.
JPG Margin Adder Use Cases
- Adding caption space above/below a photo
- Creating asymmetric spacing for a sidebar-style layout
- Matching a design system's non-uniform spacing spec
Common Mistakes
- Leaving all four margins at 0, which the tool rejects since nothing would change.
- Expecting per-side control from JPG Border Adder; that tool is uniform-only by design.
Tips
- For the common case of equal spacing on all sides, JPG Border Adder or JPG Padding Adder require only one input instead of four.
- Use JPG Margin Remover afterward with the same values to undo the change exactly.