Trim transparency off bottom and right
Trim transparency off bottom and right
I am using IM to convert a large number of dds files to png, the x and y size of a dds file need to be a power of 2 but png files don't and to reduce the file sizes i want to crop/trim off any transparency off the bottom and right of the images. I need to leave the top and left as they are, otherwise i will screw up my UV co-ordinates of the sprites that are on the png. Is there any way of doing this with IM or will i have to write my own utility to do this?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Trim transparency off bottom and right
see trimming just one side. you can do it twice, once for each side.
http://www.imagemagick.org/Usage/crop/#trim_oneside
If on Linux/MacOSX or Windows with Cygwin, see my script trimmer at the link below. It allows you to do that for any number of sides.
http://www.imagemagick.org/Usage/crop/#trim_oneside
If on Linux/MacOSX or Windows with Cygwin, see my script trimmer at the link below. It allows you to do that for any number of sides.
Re: Trim transparency off bottom and right
Thanks for the info, for reference i used the following command line to get it working :-
convert.exe file.dds -gravity West -background white -splice 5x0 -background black -splice 5x0 -trim +repage -chop 5x0 -gravity north -background white -splice 0x1 -background black -splice 0x1 -trim +repage -chop 0x1 file.png
convert.exe file.dds -gravity West -background white -splice 5x0 -background black -splice 5x0 -trim +repage -chop 5x0 -gravity north -background white -splice 0x1 -background black -splice 0x1 -trim +repage -chop 0x1 file.png