Skip to main content
Inspiring
May 25, 2015
Answered

Deleting channels is incredibly slow

  • May 25, 2015
  • 2 replies
  • 902 views

Photoshop CC 2014 with all updates. My script saves two selections to two channels. At the end I delete the channels using the following function.

function deleteChannelByName(channelNameToDelete) {

  var channelRef = activeDocument.channels.getByName(channelNameToDelete);

  channelRef.remove();

}

When I run the script in the Extend Script IDE  and call this function to delete a channel containing a selection a dialog with a green progress bar and the title "Rebuilding histogram..." appears nine, yes 9, times. This makes deleting a channel an unbelievably slow operation. Am I doing something wrong or is this just the way it is? Thanks.

This topic has been closed for replies.
Correct answer DBarranca

Hi,

give this a try and let me know if it's quicker:

function deleteChannelByName(channelName) {

    var desc = new ActionDescriptor(),

        ref = new ActionReference();

    ref.putName( stringIDToTypeID("channel"), channelName );

    desc.putReference( stringIDToTypeID("target"), ref);

    executeAction( stringIDToTypeID("delete"), desc, DialogModes.NO );

}

   

// deleteChannelByName("aChannelToDelete");

Regards,

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

2 replies

DBarranca
DBarrancaCorrect answer
Legend
May 26, 2015

Hi,

give this a try and let me know if it's quicker:

function deleteChannelByName(channelName) {

    var desc = new ActionDescriptor(),

        ref = new ActionReference();

    ref.putName( stringIDToTypeID("channel"), channelName );

    desc.putReference( stringIDToTypeID("target"), ref);

    executeAction( stringIDToTypeID("delete"), desc, DialogModes.NO );

}

   

// deleteChannelByName("aChannelToDelete");

Regards,

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

BazslAuthor
Inspiring
May 26, 2015

Thanks for the code Davide. It is similar to the code Script Listener generated but yours is shorter and it works perfectly. I also used Script Listener to generate code to load a selection from a channel and I no longer have the annoying "Rebuilding histogram..." dialogs anywhere.

Bill

Inspiring
December 4, 2017

It feels like `getByName` function is performing very slow

I need following functionality:

- select channel by name

- create a channel if it doesn't exist already

- remove channel

- copy channel (that is, remove then duplicate with a new name)

How can I re-write it via photoshop script instead of using `channels.getByName`?

BazslAuthor
Inspiring
May 25, 2015

I just discovered that I also get multiple displays of the "Rebuilding histogram..." progress dialog when I load a selection from a channel in one place in my script while in another part of the script I load a selection from a channel using the same code and do not get the "Rebuilding histogram..." dialogs. Very strange.