Skip to main content
Participating Frequently
April 6, 2011
Question

merge 2 files for masking with alpha channels

  • April 6, 2011
  • 1 reply
  • 1550 views

Dear all,

I have like hundreds of files. Each file has it's own "sister black&white file" which is ment to be used as a mask.

I was wondering if it is possible to automaticly merge those 2 files so we would end up with a masked image..png or whatever....

It would be a monster job to do it all by hand...

Maybe a a script or badge???

kind regards,

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
April 6, 2011

What are the naming-rules and the files’ locations (side by side?) and is the Alpha a grayscale image or RGB, too?

Edit: Could you post a pair of files for testing?

Participating Frequently
April 6, 2011

the alpha image will be rgb.

The filenaming is not problem - that we can take care of...

in other words - you can call it whatever you want...

thanx

Participant
June 30, 2011

You could change the save options to something like:

tifOpts = new TiffSaveOptions() ;      

tifOpts.embedColorProfile = true;      

tifOpts.imageCompression = TIFFEncoding.TIFFLZW;

tifOpts.alphaChannels = false;      

tifOpts.byteOrder = ByteOrder.MACOS;

tifOpts.layers = true;

And the export-line to

var docName = doc.name;

var basename = docName.match(/(.*)\.[^\.]+$/)[1];

doc.saveAs((new File(ofolder + '/' + basename + '.tif')),tifOpts,true)

doc.close(SaveOptions.DONOTSAVECHANGES);

And if you think it would be easier if I just amended the Script, that might be so, but you may pick up more this way, I guess.


Hey, this thread is really helpful to me... thank you! I was wondering if it would be possible to modify this script to work in my situation. Instead of having 100 jpgs and 100 mask png files... I have 100 jpgs and then just 1 mask png that I want to apply to all 100 jpgs and then have the resulting 100 images be saved as png files with alpha transparency. If someone could help me with this it would be very much appreciated. Thanks!