Page 1 of 1

Tiff to sdds with alpha composting command line

Posted: 2013-08-21T15:22:26-07:00
by mambo4
I'm new to image magick, working on a game texture tool for my studio

I need a batch-able tool that can take 4 layered 1024 tiffs:
filename_diffuse.tif (24bit)
filename_emissive.tif (8bit grayscale)
filename_normal.tif (24bit)
filename_specular.tif (8bit grayscale)

and perform the following via command line options:

resize (to various dimensions) pref. using Lancozs filter and some sharpening
add filename_emissive.tif to the alpha channel of filename_diffuse.tif
add filename_specular.tif to filename_normal.tif as alpha channel
save as DDS / dxt5 , no mips, but some control over the other settings.

I'm wondering what command line(s) for these operations need to look like.

Re: Tiff to sdds with alpha composting command line

Posted: 2013-08-21T15:41:11-07:00
by fmw42
As a new user, please read the following for asking questions on the forum (esp identifying your IM version and platform, if you have already installed it) and the following tutorials.

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/script/comma ... ptions.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/


I will assume you are on unix for now and just give you syntax.


convert \( image1 -filter lanczos -resize WxH -unsharp 0xsigma \) image2 -alpha off -compose copy_opacity -composite result.

where the second image is your 8-bit grayscale image which gets put into the alpha channel of the processed first image (provided the second image is the size of the processed first image (i.e. the size of the newly resized image at WxH). If not then you need to combine the second image as the alpha channel to the first image and then process the combination.

See the following
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/script/comma ... p#geometry
http://www.imagemagick.org/Usage/resize/
http://www.imagemagick.org/script/comma ... hp#unsharp
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/compose/#copyopacity


If you are on windows, then see different syntax regarding parenthesis (without \ ) and % going to %%. http://www.imagemagick.org/Usage/windows/

I don't know if IM converts to DDS. It may only be a Windows format. See http://en.wikipedia.org/wiki/DirectDraw_Surface. The list of IM supported formats does not seem to include it. But I am not a windows user. Perhaps one of the Windows users knows more about IM support for it.

See
http://www.imagemagick.org/script/formats.php

So you may need to store in some more common image format such as png or tiff or bmp and then use some other tool to convert to DDS.

Re: Tiff to sdds with alpha composting command line

Posted: 2013-08-21T15:46:31-07:00
by mambo4
thanks for the response. I'm not unix but win7.
your answers seem enough to point me in the right direction.

Re: Tiff to sdds with alpha composting command line

Posted: 2013-08-21T15:47:57-07:00
by fmw42
See my updated post above. In Windows the above would be

convert ( image1 -filter lanczos -resize WxH -unsharp 0xsigma ) image2 -alpha off -compose copy_opacity -composite result

the parenthesis here may be optional, but I like to segment my commands by logical use of parenthesis for safety.

Re: Tiff to sdds with alpha composting command line

Posted: 2013-08-21T15:59:16-07:00
by mambo4
thanks again!

Re: Tiff to sdds with alpha composting command line

Posted: 2013-08-21T21:06:27-07:00
by snibgo
IM 6.8.6-0 on Windows 7 "convert -list format" says IM can read but not write DDS.

Another user uses PNG2DDS. See viewtopic.php?f=1&t=23946

Re: Tiff to sdds with alpha composting command line

Posted: 2013-08-21T22:28:09-07:00
by fmw42
see new post about writing to DDS at viewtopic.php?f=1&t=23946#p102080

trouble flattening layered tiff

Posted: 2013-08-27T09:30:35-07:00
by mambo4
So I've been converting layered tiffs (dozens of layers) using this command

Code: Select all

convert in_file.tif -alpha off -layers flatten  -filter lanczos -resize 256x256 -unsharp 1x0.5 out_file.tif
but the result is that only the bottom layer gets resized, the remaining layers get cropped.
if I set the format of out_file to .tga this issue is eliminated, so it's not a big deal.
but I am curious if there is proper way to flatten and resize while remaining .tif?

Re: Tiff to sdds with alpha composting command line

Posted: 2013-08-27T09:55:31-07:00
by snibgo
"-alpha off" switches off transparency. "-layers flatten" overlays the layers according to their transparency. But you have no transparency, so the result comes from only one layer.

Re: Tiff to sdds with alpha composting command line

Posted: 2013-09-07T12:40:11-07:00
by dlemstra