Page 1 of 1
Trim transparency off bottom and right
Posted: 2014-10-09T04:30:18-07:00
by MrT
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?
Re: Trim transparency off bottom and right
Posted: 2014-10-09T09:40:43-07:00
by fmw42
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.
Re: Trim transparency off bottom and right
Posted: 2014-10-15T07:27:59-07:00
by MrT
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