Tiff to sdds with alpha composting command line

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mambo4
Posts: 12
Joined: 2013-08-21T15:03:42-07:00
Authentication code: 6789

Tiff to sdds with alpha composting command line

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Tiff to sdds with alpha composting command line

Post 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.
Last edited by fmw42 on 2013-08-21T16:01:53-07:00, edited 2 times in total.
mambo4
Posts: 12
Joined: 2013-08-21T15:03:42-07:00
Authentication code: 6789

Re: Tiff to sdds with alpha composting command line

Post by mambo4 »

thanks for the response. I'm not unix but win7.
your answers seem enough to point me in the right direction.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Tiff to sdds with alpha composting command line

Post 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.
mambo4
Posts: 12
Joined: 2013-08-21T15:03:42-07:00
Authentication code: 6789

Re: Tiff to sdds with alpha composting command line

Post by mambo4 »

thanks again!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Tiff to sdds with alpha composting command line

Post 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
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Tiff to sdds with alpha composting command line

Post by fmw42 »

see new post about writing to DDS at viewtopic.php?f=1&t=23946#p102080
mambo4
Posts: 12
Joined: 2013-08-21T15:03:42-07:00
Authentication code: 6789

trouble flattening layered tiff

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Tiff to sdds with alpha composting command line

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Tiff to sdds with alpha composting command line

Post by dlemstra »

.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply