Skip to main content
Inspiring
February 8, 2021
Answered

Toggle anti-aliasing tools on and off

  • February 8, 2021
  • 2 replies
  • 1608 views

Is there a way in Photoshop to easily switch rectangluar marquee, oval marquie, magic wand and fill to not use anti-aliasing in one go? Not individual tools. In that,  I often to pixel art and want to switch all anti-aliasing settings to off and then back on again when I'm done.

 

I don't think this is possible via scripting, tool settings, workspace settings.

 

 

 

 

This topic has been closed for replies.
Correct answer JJMack

Jazz-y is very good at Photoshop scripting. However the code he posted is missing a comma and did not include the Paint Bucket Tool.  So I added the missing comma and added  the Paint Bucket Tool and code to  make the script a toggle.  However, For some reason the Rectangle Marquee Tool's Ant-a;ias is not toggling???

 

  "ToggleAntiAlias.jsx" 

 

#target photoshop;

var s2t = stringIDToTypeID,
    c2t = charIDToTypeID,
    tools = {
        marqueeRectTool: 'MrqA',
        marqueeEllipTool: 'MrqA',
        lassoTool: 'DrwA',
        polySelTool: 'DrwA',
        magneticLassoTool: 'DrwA',
        magicWandTool: 'WndA',
	    bucketTool: 'BckA',
    },
    antiAlias = true;
	
var desc = new ActionDescriptor(); 							// Set up Photoshop to remember variables
try {var desc = app.getCustomOptions('antiAlias Toggle');}	// Try to get CustomOption for Toggling
catch(e) {
	desc.putInteger(0,1);									// 1 true
	app.putCustomOptions('antiAlias Toggle',desc,false);	// Initialize CustomOption for Toggling
}
var Toggle = desc.getInteger(0);                            // get CustomOption for Toggling
if (Toggle) {
	antiAlias = false;
	desc.putInteger(0,0);    
}
else {
	antiAlias = true;
	desc.putInteger(0,1);    	
}
app.putCustomOptions('antiAlias Toggle',desc,false);			// CustomOption for Toggling
for (t in tools) {
    (d = new ActionDescriptor()).putBoolean(c2t(tools[t]), antiAlias);
    (r = new ActionReference()).putClass(s2t(t));
    (d1 = new ActionDescriptor()).putReference(s2t('target'), r);
    d1.putObject(s2t('to'), s2t('target'), d);
    executeAction(s2t('set'), d1, DialogModes.NO);
}

 

2 replies

Legend
February 8, 2021

What is the fill tool?

 

Save 2 versions of the script - one with antiAlias = true; another with antiAlias = false; Assign hotkeys to them

 

#target photoshop;

var s2t = stringIDToTypeID,
    c2t = charIDToTypeID,
    tools = {
        marqueeRectTool: 'MrqA',
        marqueeEllipTool: 'MrqA',
        lassoTool: 'DrwA',
        polySelTool: 'DrwA',
        magneticLassoTool: 'DrwA',
        magicWandTool: 'WndA',
    },
    antiAlias = true;

for (t in tools) {
    (d = new ActionDescriptor()).putBoolean(c2t(tools[t]), antiAlias);
    (r = new ActionReference()).putClass(s2t(t));
    (d1 = new ActionDescriptor()).putReference(s2t('target'), r);
    d1.putObject(s2t('to'), s2t('target'), d);
    executeAction(s2t('set'), d1, DialogModes.NO);
}

 

Inspiring
February 8, 2021

The fill tool? Haha, I'm old skool, in Photoshop, it's the paint bucket tool.

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
February 8, 2021

Jazz-y is very good at Photoshop scripting. However the code he posted is missing a comma and did not include the Paint Bucket Tool.  So I added the missing comma and added  the Paint Bucket Tool and code to  make the script a toggle.  However, For some reason the Rectangle Marquee Tool's Ant-a;ias is not toggling???

 

  "ToggleAntiAlias.jsx" 

 

#target photoshop;

var s2t = stringIDToTypeID,
    c2t = charIDToTypeID,
    tools = {
        marqueeRectTool: 'MrqA',
        marqueeEllipTool: 'MrqA',
        lassoTool: 'DrwA',
        polySelTool: 'DrwA',
        magneticLassoTool: 'DrwA',
        magicWandTool: 'WndA',
	    bucketTool: 'BckA',
    },
    antiAlias = true;
	
var desc = new ActionDescriptor(); 							// Set up Photoshop to remember variables
try {var desc = app.getCustomOptions('antiAlias Toggle');}	// Try to get CustomOption for Toggling
catch(e) {
	desc.putInteger(0,1);									// 1 true
	app.putCustomOptions('antiAlias Toggle',desc,false);	// Initialize CustomOption for Toggling
}
var Toggle = desc.getInteger(0);                            // get CustomOption for Toggling
if (Toggle) {
	antiAlias = false;
	desc.putInteger(0,0);    
}
else {
	antiAlias = true;
	desc.putInteger(0,1);    	
}
app.putCustomOptions('antiAlias Toggle',desc,false);			// CustomOption for Toggling
for (t in tools) {
    (d = new ActionDescriptor()).putBoolean(c2t(tools[t]), antiAlias);
    (r = new ActionReference()).putClass(s2t(t));
    (d1 = new ActionDescriptor()).putReference(s2t('target'), r);
    d1.putObject(s2t('to'), s2t('target'), d);
    executeAction(s2t('set'), d1, DialogModes.NO);
}

 

JJMack
JJMack
Community Expert
Community Expert
February 8, 2021

I do not think you can toggle Photoshop UI and if you can some an other script could also you would still need to check the state of the option  in the tool option bar when you use the tool. Eacj tool has ite options ithe tool oprine bar is not the same foe all tools the toggle would not bet common to all tools.  You would need to create you own toggle the keep all tools in sync with your master toggle.  The problem is you can not use an event handler to sync them for event handlers are traggered after the event.  After the tool has been used.,

 

You can Script  using the Anti-Alias option in script I developed a Plug-in script that can be used in Actions to pass aspect ratio to the script to mats a selection or path relative the the current document's size. Its hard to deal with size in Actions.  A little scripting goes a long way.

 

Create a function using Action Manager code like I created for my Plug-in script Aspect Ratio Selection that is modeled after Adobe Fit Image Plug_in Script.  basically its Fit Image with a different function. The Plug-in can create  a rectangle or elliptical  its a combined tool for a selection or vector tool. 

 

/* SetMarqueeSelection function from Scriptlistner plugin
// ========================================================================== */
function setMarqueeSelection(x1, y1, x2, y2, type, shape, feather, antiAlias, doPath) {
	if (doPath ==null) { doPath = false; }
	var SelectionType =null;
	if (type ==null)      {	var SelectionType = "setd" }
	if (type ==diminish)  {	var SelectionType = "SbtF" }
	if (type ==extend)    {	var SelectionType = "AddT" }
	if (type ==intersect) {	var SelectionType = "IntW" }
	if (type ==replace)   {	var SelectionType = "setd" }

	var id3	= charIDToTypeID( SelectionType	);
	    var	desc2 =	new ActionDescriptor();
	    var	id4 = charIDToTypeID( "null" );
		var ref1 = new ActionReference();
		if (doPath) {
			var id5	= charIDToTypeID( "Path" );
			var id6	= charIDToTypeID( "WrPt" );
			}
		else {
			var id5	= charIDToTypeID( "Chnl" );
			var id6	= charIDToTypeID( "fsel" );
			}
		ref1.putProperty( id5, id6 );
	    desc2.putReference(	id4, ref1 );
	    var	id7 = charIDToTypeID( "T   " );
		var desc3 = new	ActionDescriptor();
		var id8	= charIDToTypeID( "Top " );
		var id9	= charIDToTypeID( "#Pxl" );
		desc3.putUnitDouble( id8, id9, y1 );
		var id10 = charIDToTypeID( "Left" );
		var id11 = charIDToTypeID( "#Pxl" );
		desc3.putUnitDouble( id10, id11, x1 );
		var id12 = charIDToTypeID( "Btom" );
		var id13 = charIDToTypeID( "#Pxl" );
		desc3.putUnitDouble( id12, id13, y2 );
		var id14 = charIDToTypeID( "Rght" );
		var id15 = charIDToTypeID( "#Pxl" );
		desc3.putUnitDouble( id14, id15, x2 );
	    var	id16 = charIDToTypeID( shape );
	    desc2.putObject( id7, id16,	desc3 );
	    var	id17 = charIDToTypeID( "Fthr" );
	    var	id18 = charIDToTypeID( "#Pxl" );
	    desc2.putUnitDouble( id17, id18, feather );
	    var	id19 = charIDToTypeID( "AntA" );
	    desc2.putBoolean( id19, antiAlias );
	executeAction( id3, desc2, DialogModes.NO );
}

 

 

 

JJMack
Inspiring
February 9, 2021

Thans JJ. But that's not quite what I'm after. Possibly a bit of communication confusion on my behalf.  #actuallyautistic

Your function allows a selection with a number of settings to be performed on that selection.

 

What I'm after is just to be able to switch all the anti-aliasing buttons off, do some work, and then switch them back on again. So for simplicty's sake, let's consider the marquee tool. I'd just toggle the antialias button on and off.

 

Think of it as a lofi,-retro pixel art mode. and then back to glorius normal Photoshop mode.

 

JJMack
Community Expert
Community Expert
February 9, 2021

Jazz-y script toggle anti-alias option for fall tools that have a anti-alias option  via a master custom  toggle script option.  However, the code that does the rectangle marquee tool does not seem to work. It may be a problem in all version of Photoehop after CS6. The script will not work in CS6 and prior perpetual Photoshop versions.

JJMack