i tried to use this:
http://www.imagemagick.org/Usage/crop/#trim_oneside
so I use command lines such as:
>convert opcodes_tables06.png -gravity East -background white -splice 0x1 -background black -splice 0x1 -trim +repage -chop 0x1 opcodes_tables06E.png
but when I trim with a West or East gravity (which happens to be what I'd want), I get the same result as South (ie, the top is trimmed), while North (or South) is doing the expected result.
*updated* I want to automatically trim the right side of http://i.imgur.com/oEZ3N.png
auto-trimming on one side only works on top and bottom.
auto-trimming on one side only works on top and bottom.
Last edited by ange4771 on 2012-02-19T14:09:55-07:00, edited 2 times in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: trimming on one side only works on top and bottom.
What exactly do you want to do? Which sides do you want to trim and how much? Can you post a link to your input image?
-splice adds rows or columns and does not remove them. You need to use either -shave or -chop if you know exactly how much to trim. Otherwise, I would need to see your image to help you with -trim.
-splice adds rows or columns and does not remove them. You need to use either -shave or -chop if you know exactly how much to trim. Otherwise, I would need to see your image to help you with -trim.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: auto-trimming on one side only works on top and bottom.
Do you want to trim the transparency only on the right side of oEZ3N.png. Why not all around?
This works for me.
convert oEZ3N.png -gravity west \
-background white -splice 5x0 \
-background black -splice 5x0 \
-trim +repage \
-gravity west -chop 5x0 \
oEZ3N_trim_west.gif
This works for me.
convert oEZ3N.png -gravity west \
-background white -splice 5x0 \
-background black -splice 5x0 \
-trim +repage \
-gravity west -chop 5x0 \
oEZ3N_trim_west.gif
Re: auto-trimming on one side only works on top and bottom.
basically I want to merge the complete picture, ie merge oEZ3N.png with http://i.imgur.com/lIztt.png on its right.
but if I just -trim all sides of both pictures, then 'convert +append' them, they're not perfectly aligned - I guess it's because their vertical start (of non transparency) is different, so I wanted to remove the right of oEZ3N.png and the left of lIztt.png before +appending them, then auto-trimming the merge
but if I just -trim all sides of both pictures, then 'convert +append' them, they're not perfectly aligned - I guess it's because their vertical start (of non transparency) is different, so I wanted to remove the right of oEZ3N.png and the left of lIztt.png before +appending them, then auto-trimming the merge
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: auto-trimming on one side only works on top and bottom.
Try this
convert \( oEZ3N.png -gravity west \
-background white -splice 5x0 \
-background black -splice 5x0 \
-trim +repage \
-gravity west -chop 5x0 \) \
\( lIztt.png -gravity east \
-background white -splice 5x0 \
-background black -splice 5x0 \
-trim +repage \
-gravity east -chop 5x0 \) \
-background none -gravity north +append \
result.png
convert \( oEZ3N.png -gravity west \
-background white -splice 5x0 \
-background black -splice 5x0 \
-trim +repage \
-gravity west -chop 5x0 \) \
\( lIztt.png -gravity east \
-background white -splice 5x0 \
-background black -splice 5x0 \
-trim +repage \
-gravity east -chop 5x0 \) \
-background none -gravity north +append \
result.png
Re: auto-trimming on one side only works on top and bottom.
I see my mistake now - one of the splice was wrong. Thanks !
your command line gives almost a perfect result, except that there is a transparent line right in the middle - yet -trim should have removed that, right?
your command line gives almost a perfect result, except that there is a transparent line right in the middle - yet -trim should have removed that, right?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: auto-trimming on one side only works on top and bottom.
ange4771 wrote:I see my mistake now - one of the splice was wrong. Thanks !
your command line gives almost a perfect result, except that there is a transparent line right in the middle - yet -trim should have removed that, right?
Only if it was perfectly transparent. If not then no, unless you add -fuzz XX%. Apparently the transition between the image and transparent background is anti-aliased or there was some resizing that mixed image with transparency. This mixing can possibly come for example if this was generated with PS background transparency or with an anti-aliased alpha channel.
OK, -fuzz 50% does not seem to help for me. So you have to chop one column on each image.
try
convert \( 1oEZ3N.png -gravity west \
-background white -splice 5x0 \
-background black -splice 5x0 \
-trim +repage \
-gravity west -chop 5x0 -gravity east -chop 1x0 \) \
\( 1lIztt.png -gravity east \
-background white -splice 5x0 \
-background black -splice 5x0 \
-trim +repage \
-gravity east -chop 5x0 -gravity west -chop 1x0 \) \
-background none -gravity north +append \
1result.png