I can think of two possible extension options:
- trim from selected frames only (top, bottom, left, right)
- trim when pattern changes (rather than detecting first if pixels adjacent to the frame have the same color and then detecting how wide the same area towards the centre is - this would be detecting just the break in the pattern so therefore could support multiple different colors initially adjacent to the frame. For instance, image:
Code: Select all
RRRRRGGGRRRRRRRR
RRRRRGGGRRRRRRRR
RRRRRGGGRRRRRRRR
RRRRBGGRRRRRRRRR
RRRRBGGRRRRRRRRR
RRRBBBGGRRRRRRRR
RRBBBGGGGRGRRRRR
RBBBBBBRRRRRRRRRCode: Select all
RRRRBGGRRRRRRRRR
RRRRBGGRRRRRRRRR
RRRBBBGGRRRRRRRR
RRBBBGGGGRGRRRRR
RBBBBBBRRRRRRRRRand in:
Code: Select all
 RRBBBGGRRR
 RBBBGGGGRG
 BBBBBBRRRRwhereas default trim (like in IrfanView) would result in:
Code: Select all
 RRRRGGGRRR
 RRRRGGGRRR
 RRRRGGGRRR
 RRRBGGRRRR
 RRRBGGRRRR
 RRBBBGGRRR
 RBBBGGGGRG
 BBBBBBRRRR