我需要向 tiff 图像添加一个附加通道(使用自定义名称,而不是 alpha)。 我很惊讶这有多困难,因为 tiff-secification 说可以添加自定义通道,并且 PhotoShop 能够做到这一点。 现在我正在寻找一种自动化的方法......
有谁知道现在是否可以使用任何代码或任何框架?
在 Photoshop 中像这样:https://i.sstatic.net/xtOzb.png
我在网上找到了一些 Photoshop JSX 代码并将其拼凑在一起。我不是编码员,但它对我有用。从 PS 内部作为脚本运行。它将选择所有像素并使选区中的专色通道变为白色。
// Define the necessary Photoshop Action IDs
var idSetDescriptor = charIDToTypeID("setd");
var desc = new ActionDescriptor();
var idNull = charIDToTypeID("null");
var refNull = new ActionReference();
var idChannel = charIDToTypeID("Chnl");
var idFront = charIDToTypeID("fsel");
refNull.putProperty(idChannel, idFront);
desc.putReference(idNull, refNull);
var idTarget = charIDToTypeID("T ");
var refTarget = new ActionReference();
var idChannel = charIDToTypeID("Chnl");
var idChannel = charIDToTypeID("Chnl");
var idTransparency = charIDToTypeID("Trsp");
refTarget.putEnumerated(idChannel, idChannel, idTransparency);
desc.putReference(idTarget, refTarget);
// Execute the action
executeAction(idSetDescriptor, desc, DialogModes.NO);
// Ensure there's an active selection
if (app.activeDocument.selection.bounds) {
// Create a new spot channel based on the current selection
var idMk = charIDToTypeID("Mk ");
var desc = new ActionDescriptor();
var idNw = charIDToTypeID("Nw ");
var spotChannelDesc = new ActionDescriptor();
// Set the name of the Spot Channel
var idNm = charIDToTypeID("Nm ");
spotChannelDesc.putString(idNm, "white");
// Define the color for the Spot Channel (White in this case)
var idClr = charIDToTypeID("Clr ");
var colorDesc = new ActionDescriptor();
var idH = charIDToTypeID("H ");
var idAng = charIDToTypeID("#Ang");
colorDesc.putUnitDouble(idH, idAng, 0); // Hue (not needed for white)
var idStrt = charIDToTypeID("Strt");
colorDesc.putDouble(idStrt, 0); // Saturation
var idBrgh = charIDToTypeID("Brgh");
colorDesc.putDouble(idBrgh, 100); // Brightness
var idHSBC = charIDToTypeID("HSBC");
spotChannelDesc.putObject(idClr, idHSBC, colorDesc);
// Set opacity to 100%
var idOpct = charIDToTypeID("Opct");
spotChannelDesc.putInteger(idOpct, 100);
// Create the Spot Channel
var idSCch = charIDToTypeID("SCch");
desc.putObject(idNw, idSCch, spotChannelDesc);
// Execute the action
executeAction(idMk, desc, DialogModes.NO);
// Fill the selection with the spot color
var idFill = charIDToTypeID("Fl ");
var fillDesc = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref = new ActionReference();
ref.putName(charIDToTypeID("Chnl"), "Spot Channel");
fillDesc.putReference(idnull, ref);
var idT = charIDToTypeID("T ");
var fillColor = new ActionDescriptor();
var idClr = charIDToTypeID("Clr ");
var colorDesc = new ActionDescriptor();
colorDesc.putDouble(charIDToTypeID("Rd "), 255); // Red
colorDesc.putDouble(charIDToTypeID("Grn "), 255); // Green
colorDesc.putDouble(charIDToTypeID("Bl "), 255); // Blue
fillColor.putObject(idClr, charIDToTypeID("RGBC"), colorDesc);
fillDesc.putObject(idT, charIDToTypeID("Clr "), fillColor);
} else {
alert("No selection found. Please make a selection first.");
}