Hi all
I have RGB images with around 25 alpha channels with names not starting with alph....... I want to load these channels one by one and convert the selected area into a new layer with layer names same as channel names.
Later I can convert this layered image to new smaller images using a script avialble with me. Is there any script available to do the first part or anybody can help me out
Rajan
load alpha channels convert selection to layer
load alpha channels convert selection to layer
first you will need to loop through the channels collection (array of all the channels).
then for each iteration:
- you will make a selection from that channel.
not sure of the method for this. but you could just record an action and call the action from your script.
- then copy the selection
app.activeDocument.selection.copy()
- then make a new layer and paste
app.activeDocument.paste()
- then name the current layer to the name of the current channel
then for each iteration:
- you will make a selection from that channel.
not sure of the method for this. but you could just record an action and call the action from your script.
- then copy the selection
app.activeDocument.selection.copy()
- then make a new layer and paste
app.activeDocument.paste()
- then name the current layer to the name of the current channel
load alpha channels convert selection to layer
This is close to rogerdodger's outline
Code: Select allvar doc = activeDocument;
var lyr = doc.activeLayer;
var cnt = doc.channels.length;
for(var i = 1 ;i < cnt;i++){
if(activeDocument.channels.kind != ChannelType.MASKEDAREA) {continue}
doc.selection.load(doc.channels);
executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );
doc.activeLayer.name = doc.channels.name;
doc.activeLayer = lyr;
}
Mike
Code: Select allvar doc = activeDocument;
var lyr = doc.activeLayer;
var cnt = doc.channels.length;
for(var i = 1 ;i < cnt;i++){
if(activeDocument.channels.kind != ChannelType.MASKEDAREA) {continue}
doc.selection.load(doc.channels);
executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );
doc.activeLayer.name = doc.channels.name;
doc.activeLayer = lyr;
}
Mike
load alpha channels convert selection to layer
Hi Mike
It is working fine, thanks for your support
Rajan
It is working fine, thanks for your support
Rajan
load alpha channels convert selection to layer
In a PM vbrajan asked how to delete the alpha channels after the new layer is created.
Code: Select allvar doc = activeDocument;
var lyr = doc.activeLayer;
var cnt = doc.channels.length - 1;
for(var i = cnt ;i > 1; i--){
if(activeDocument.channels.kind != ChannelType.MASKEDAREA) {continue}
doc.selection.load(doc.channels);
executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );
doc.activeLayer.name = doc.channels.name;
doc.channels.remove();
doc.activeLayer = lyr;
};
Code: Select allvar doc = activeDocument;
var lyr = doc.activeLayer;
var cnt = doc.channels.length - 1;
for(var i = cnt ;i > 1; i--){
if(activeDocument.channels.kind != ChannelType.MASKEDAREA) {continue}
doc.selection.load(doc.channels);
executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );
doc.activeLayer.name = doc.channels.name;
doc.channels.remove();
doc.activeLayer = lyr;
};
load alpha channels convert selection to layer
Hi all
Mike thanks once again.
I tried with following line in the code. This also working fine.
tifSaveOptions.alphaChannels = false;
Now I am trying to create channels for layers present in the image. Channel names should be layer names. Could you help me on this.
Rajan
Mike thanks once again.
I tried with following line in the code. This also working fine.
tifSaveOptions.alphaChannels = false;
Now I am trying to create channels for layers present in the image. Channel names should be layer names. Could you help me on this.
Rajan
load alpha channels convert selection to layer
vbrajan wrote:Now I am trying to create channels for layers present in the image. Channel names should be layer names. Could you help me on this.
I am not sure what you are asking. Wouldn't the channels created from layers be the same as the channels used to create the layers? Seems to me that the answer would be not to delete the channels.
Mike
I am not sure what you are asking. Wouldn't the channels created from layers be the same as the channels used to create the layers? Seems to me that the answer would be not to delete the channels.
Mike
load alpha channels convert selection to layer
Hi Mike
My new task has no connection with earlier ones.
In this case I have to join smaller image tiles to make a bigger one. Do color correction, then cut it into smaller ones & save with their original name.
For this I am using a script which creates an image with bigger canvas size.
Then opens smaller images, copy paste all of them into the bigger one with image names as layer name. I manually arrange them to their correct position.
Here I need to create channels for each layer, so that, later I can cut this flattend bigger image into smaller ones with correct names.
My new task has no connection with earlier ones.
In this case I have to join smaller image tiles to make a bigger one. Do color correction, then cut it into smaller ones & save with their original name.
For this I am using a script which creates an image with bigger canvas size.
Then opens smaller images, copy paste all of them into the bigger one with image names as layer name. I manually arrange them to their correct position.
Here I need to create channels for each layer, so that, later I can cut this flattend bigger image into smaller ones with correct names.
load alpha channels convert selection to layer
I think this should do it.
Paul.
Code: Select alldoc =activeDocument;
for (var a =0;a<doc.layers.length;a++){
doc.activeLayer = doc.layers[a];
if(!activeDocument.activeLayer.isBackgroundLayer){
var layerName = doc.layers[a].name;
LB = doc.activeLayer.bounds;
var selRegion = Array(
Array(LB[0], LB[1]),
Array(LB[2], LB[1]),
Array(LB[2], LB[3]),
Array(LB[0], LB[3]),
Array(LB[0], LB[1])
);
doc.selection.select(selRegion);
var contentsChannel = doc.channels.add();
contentsChannel.kind = ChannelType.SELECTEDAREA;
contentsChannel.name = layerName;
doc.selection.store(doc.channels[layerName], SelectionType.REPLACE);
selectRGBChannel();
contentsChannel.visible=false;
doc.selection.deselect();
}
}
function selectRGBChannel() {
function cTID(s) { return app.charIDToTypeID(s); };
var desc35 = new ActionDescriptor();
var ref41 = new ActionReference();
ref41.putEnumerated( cTID('Chnl'), cTID('Chnl'), cTID('RGB ') );
desc35.putReference( cTID('null'), ref41 );
executeAction( cTID('slct'), desc35, DialogModes.NO );
}
Paul.
Code: Select alldoc =activeDocument;
for (var a =0;a<doc.layers.length;a++){
doc.activeLayer = doc.layers[a];
if(!activeDocument.activeLayer.isBackgroundLayer){
var layerName = doc.layers[a].name;
LB = doc.activeLayer.bounds;
var selRegion = Array(
Array(LB[0], LB[1]),
Array(LB[2], LB[1]),
Array(LB[2], LB[3]),
Array(LB[0], LB[3]),
Array(LB[0], LB[1])
);
doc.selection.select(selRegion);
var contentsChannel = doc.channels.add();
contentsChannel.kind = ChannelType.SELECTEDAREA;
contentsChannel.name = layerName;
doc.selection.store(doc.channels[layerName], SelectionType.REPLACE);
selectRGBChannel();
contentsChannel.visible=false;
doc.selection.deselect();
}
}
function selectRGBChannel() {
function cTID(s) { return app.charIDToTypeID(s); };
var desc35 = new ActionDescriptor();
var ref41 = new ActionReference();
ref41.putEnumerated( cTID('Chnl'), cTID('Chnl'), cTID('RGB ') );
desc35.putReference( cTID('null'), ref41 );
executeAction( cTID('slct'), desc35, DialogModes.NO );
}