select the channel by index and convert the mode

Explorer ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

hi every one

I need  help to make ascript that select my spot channel by index then converting its mode to bitmab then copy it and past the new one in the same channel then check the next one and do the same action tell it finshed 

i bost a screentshot for the steps thanks

waelmohammedt42523860_0-1658174240467.png

 

 

waelmohammedt42523860_2-1658174316992.pngwaelmohammedt42523860_4-1658174370691.pngwaelmohammedt42523860_5-1658174393915.png

 

waelmohammedt42523860_7-1658174508258.png

thanks

 

TOPICS
Actions and scripting , Windows

Views

165

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Apart from what has been stated, 300ppi is low for a bitmap halftone.

 

What halftone settings would be required?

 

Each channel will require a different angle, historically shifted 15° 30° in offset/litho printing to avoid moiré.

 

Can you provide the sample file?

 

Can I presume that this will be required for images with the same number of spot channels but different names and or different numbers of channels?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Hello

  • This for with the same names but not  same number of channels  every design has it is won number of colors  for the angel it will be 22.5 for all channels and the number of  ppi will be change  beside the frequency thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied


Each channel will require a different angle, historically shifted 15° in offset/litho printing to avoid moiré.


Good point. 

In some cases this could even lead to a light color »disappearing« behind a darker one. 

 

@wael mohammedt42523860 , you have been asked to provide a sample file, please do so. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

That’s not what was asked for. 

 

Anyway … you can give this a try. 

But as the Channels are grayscale I wonder if the ultimate file fits the output needs. 

// 2022, use it at your own risk;
if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    var theRes = myDocument.resolution;
    var theChannels = myDocument.channels;
    for (var m = 3; m < theChannels.length; m++) {
        var thisChannel = theChannels[m];
        if (thisChannel.kind == "ChannelType.SPOTCOLOR") {
            thisChannel.visible = true;
            myDocument.activeChannels = [thisChannel];
            someStuff(myDocument.name, thisChannel.name, theRes);
            }
        }
    };
////// do stuff //////
function someStuff (docName, theChannelName, theRes) {
var idchannel = stringIDToTypeID( "channel" );
var idselection = stringIDToTypeID( "selection" );
var iddocument = stringIDToTypeID( "document" );
var idto = stringIDToTypeID( "to" );
var idset = stringIDToTypeID( "set" );
var idnull = stringIDToTypeID( "null" );
var idshape = stringIDToTypeID( "shape" );
var idmethod = stringIDToTypeID( "method" );
// =======================================================
    var desc33 = new ActionDescriptor();
        var ref9 = new ActionReference();
        ref9.putProperty( idchannel, idselection );
    desc33.putReference( idnull, ref9 );
        var ref10 = new ActionReference();
        ref10.putEnumerated( idchannel, stringIDToTypeID( "ordinal") , stringIDToTypeID( "targetEnum" ) );
    desc33.putReference( idto, ref10 );
executeAction( idset, desc33, DialogModes.NO );
// =======================================================
    var desc26 = new ActionDescriptor();
    desc26.putClass( stringIDToTypeID( "new" ), iddocument );
        var ref8 = new ActionReference();
        ref8.putProperty( idchannel, idselection );
    desc26.putReference( stringIDToTypeID( "using" ), ref8 );
executeAction( stringIDToTypeID( "make" ), desc26, DialogModes.NO );
// =======================================================
executeAction( stringIDToTypeID( "invert" ), undefined, DialogModes.NO );
// =======================================================
    var desc5 = new ActionDescriptor();
        var desc6 = new ActionDescriptor();
        desc6.putUnitDouble( stringIDToTypeID( "resolution" ), stringIDToTypeID( "densityUnit" ), theRes );
        desc6.putEnumerated( idmethod, idmethod, stringIDToTypeID( "halftoneScreen" ) );
        desc6.putUnitDouble( stringIDToTypeID( "frequency" ), stringIDToTypeID( "densityUnit" ), 53.000000 );
        desc6.putUnitDouble( stringIDToTypeID( "angle" ), stringIDToTypeID( "angleUnit" ), 22.500000 );
        desc6.putEnumerated( idshape, idshape, stringIDToTypeID( "round" ) );
    desc5.putObject( idto, stringIDToTypeID( "bitmapMode" ), desc6 );
executeAction( stringIDToTypeID( "convertMode" ), desc5, DialogModes.NO );
activeDocument.mode = DocumentMode.GRAYSCALE;
activeDocument.selection.load(activeDocument.channels[0], SelectionType.REPLACE, true);
// =======================================================
    var desc19 = new ActionDescriptor();
        var ref5 = new ActionReference();
        ref5.putName( idchannel, theChannelName );
        ref5.putName( iddocument, docName );
    desc19.putReference( idnull, ref5 );
        var ref6 = new ActionReference();
        ref6.putProperty( idchannel, idselection );
    desc19.putReference( idto, ref6 );
executeAction( idset, desc19, DialogModes.NO );
activeDocument.close(SaveOptions.DONOTSAVECHANGES)
};

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

hi sir

why it is invert and why startt from channel 3you will find a file so you can test on it thanks very much for your time

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

I was expecting a spot channel PSD from your original request?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

hi 

this is a file for tst

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

@wael mohammedt42523860 

 

Thank you for the sample image, it really does help others to try to assist you!

 

Is the attached PSD what you are looking for? It is using a 60 lpi round dot at 45° angle for all channels...

 

The sample was created using an action automating 8 manual steps per spot channel, selecting each channel one at a time and then running the action.

 

A script could of course further automate this task.

 

Here is a JPEG preview of the multi-channel PSD:

 

halftone-preview.jpg

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

@wael mohammedt42523860 – try the following script.

 

It uses hard-coded values for the halftone, which I have placed near the top of the script for "easy access". More code would be required for a GUI to enter the required values.

 

/*
Contone Spot Channels to Halftone.jsx
v1.0, 23rd July 2022, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/select-the-channel-by-index-and-convert-the-mode/td-p/13077384
*/

// Doc variable
var doc = activeDocument;
// Halftone screen LPI variable
var freqValue = 80;
// Halftone screen angle
var angleValue = 22.5;
// Halftone shape
var shapeValue = "round";

// Save the current active channels
var savedChannelState = doc.activeChannels;

// For loop from the late Michael_L_Hale
for (var channelIndex = 0; channelIndex < doc.channels.length; channelIndex++) {
    if (activeDocument.channels[channelIndex].kind == "ChannelType.SPOTCOLOR") {
        doc.activeChannels = [doc.channels[channelIndex]];
        contoneToHalftone();
    }
}

// Restore the saved active channels
doc.activeChannels = savedChannelState;

// Loop over channels and set each to visible
for (var i = doc.channels.length - 1; i >= 0; i--) {
        doc.channels[i].visible = true;
}

function contoneToHalftone() {

// Set the original doc variable
    var origDoc = activeDocument;

// Dupe the active channel to a new doc
    var docName = doc.channels[channelIndex].name;
    var idmake = stringIDToTypeID("make");
    var desc846 = new ActionDescriptor();
    var idnew = stringIDToTypeID("new");
    var desc847 = new ActionDescriptor();
    var idname = stringIDToTypeID("name");
    desc847.putString(idname, docName);
    var iddocument = stringIDToTypeID("document");
    desc846.putObject(idnew, iddocument, desc847);
    var idusing = stringIDToTypeID("using");
    var ref402 = new ActionReference();
    var idchannel = stringIDToTypeID("channel");
    var idordinal = stringIDToTypeID("ordinal");
    var idtargetEnum = stringIDToTypeID("targetEnum");
    ref402.putEnumerated(idchannel, idordinal, idtargetEnum);
    desc846.putReference(idusing, ref402);
    executeAction(idmake, desc846, DialogModes.NO);

// Convert to grayscale mode
    activeDocument.changeMode(ChangeMode.GRAYSCALE);

// Convert to bitmap mode with halftone settings
    var idconvertMode = stringIDToTypeID("convertMode");
    var desc911 = new ActionDescriptor();
    var idto = stringIDToTypeID("to");
    var desc912 = new ActionDescriptor();
    var idresolution = stringIDToTypeID("resolution");
    var iddensityUnit = stringIDToTypeID("densityUnit");
    desc912.putUnitDouble(idresolution, iddensityUnit, 300);
    var idmethod = stringIDToTypeID("method");
    var idmethod = stringIDToTypeID("method");
    var idhalftoneScreen = stringIDToTypeID("halftoneScreen");
    desc912.putEnumerated(idmethod, idmethod, idhalftoneScreen);
    var idfrequency = stringIDToTypeID("frequency");
    var iddensityUnit = stringIDToTypeID("densityUnit");
    desc912.putUnitDouble(idfrequency, iddensityUnit, freqValue);
    var idangle = stringIDToTypeID("angle");
    var idangleUnit = stringIDToTypeID("angleUnit");
    desc912.putUnitDouble(idangle, idangleUnit, angleValue);
    var idshape = stringIDToTypeID("shape");
    var idshape = stringIDToTypeID("shape");
    var idround = stringIDToTypeID(shapeValue);
    desc912.putEnumerated(idshape, idshape, idround);
    var idbitmapMode = stringIDToTypeID("bitmapMode");
    desc911.putObject(idto, idbitmapMode, desc912);
    executeAction(idconvertMode, desc911, DialogModes.NO);

// Convert to grayscale mode
    activeDocument.changeMode(ChangeMode.GRAYSCALE);

// Set the temp doc variable
    var tempDoc = activeDocument;

// Return to the original document
    activeDocument = origDoc;

// Apply image temp doc to active channel
    var idapplyImageEvent = stringIDToTypeID("applyImageEvent");
    var desc1208 = new ActionDescriptor();
    var idwith = stringIDToTypeID("with");
    var desc1209 = new ActionDescriptor();
    var idto = stringIDToTypeID("to");
    var ref519 = new ActionReference();
    var idchannel = stringIDToTypeID("channel");
    var idordinal = stringIDToTypeID("ordinal");
    var idtargetEnum = stringIDToTypeID("targetEnum");
    ref519.putEnumerated(idchannel, idordinal, idtargetEnum);
    var idlayer = stringIDToTypeID("layer");
    var idbackground = stringIDToTypeID("background");
    ref519.putProperty(idlayer, idbackground);
    var iddocument = stringIDToTypeID("document");
    ref519.putName(iddocument, docName);
    desc1209.putReference(idto, ref519);
    var idpreserveTransparency = stringIDToTypeID("preserveTransparency");
    desc1209.putBoolean(idpreserveTransparency, true);
    var idcalculation = stringIDToTypeID("calculation");
    desc1208.putObject(idwith, idcalculation, desc1209);
    executeAction(idapplyImageEvent, desc1208, DialogModes.NO);

// Close the temp doc
    tempDoc.close(SaveOptions.DONOTSAVECHANGES);

}

 

I am not well versed in screen printing, so I still have the following concerns:

 

* Is it OK to use the same screen angle for all channels? The default would usually be 45° in offset printing (is 22.5° a screenprint thing, perhaps to avoid moiré with the screen?).

 

* 300ppi resolution is low, a well-formed digital halftone may require a greater PPI value (600, 1200).

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 25, 2022 Jul 25, 2022

Copy link to clipboard

Copied

thank you so much

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

LATEST

@wael mohammedt42523860 wrote:

thank you so much


 

You're welcome.

 

Is there any feedback, comment, does this do what you want etc?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines