Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to border selection with sharp corners

New Here ,
Oct 11, 2022 Oct 11, 2022

lets say i have a selection in the shape of a rectangle, and i need to border the selection. select>modify>border creates a border with rounded corners. what i really need is an offset of the original selection as a border, with sharp corners. how can i do this?

photoshop help 1.PNG

photoshop help 2.PNG

  

TOPICS
Windows
1.9K
Translate
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
LEGEND ,
Oct 11, 2022 Oct 11, 2022

That would be best achieved by just manually drawing the selections and combining them. To make it more controllable you can also draw paths and convert them to a selection.

 

Mylenium 

Translate
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
Community Expert ,
Oct 11, 2022 Oct 11, 2022

One solution to retain the existing selection would be with a script. I don't have time right now, however, I can look into this if there is interest.

Translate
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 Employee ,
Oct 11, 2022 Oct 11, 2022

Hi there,

 

Thanks for reaching out. We're here to help.

From what I understood, you want to get the edges with sharp corners. There are multiple ways to do it. 

Let me help you with one.

1) First, we can use the rectangular shape tool (Shift + U)

2) Select the area, remove the fill and increase the stroke.

RanjishaSengupta_0-1665522662129.png

3) We go to properties and make the corner radius 0, or you can manually adjust it from the boundaries.

RanjishaSengupta_1-1665522729870.png     

RanjishaSengupta_2-1665522803536.png

 

 

That's how you can get the result quickly and fast.

 

Let us know if this helps,

 

Thanks,

Ranjisha

 

 

Translate
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
Community Expert ,
Oct 11, 2022 Oct 11, 2022

You could use Select > Transform Selection, using 100% + X px in the Width and Height fields, with X being twice the offset.

Translate
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
Community Expert ,
Oct 11, 2022 Oct 11, 2022

That's how I would it too John.  @Will5CD1 's intended use of the expanded selection might help us provide a better answer.  One issue is that transforming the selection and Alt Shift (Opt Shift) dragging a corner handle expands the selection by as percentage of the initial size, so does not work if you want the same sized border on all four sides.  I am sure Stephen could acieve it wi a script though.

image.png

 

I have just tested this and it works. 

Start with your rectangular selection, and start a new Action.

  1. Make a new layer.
  2. Fill the new layer with the foreground colour.
  3. Make the new layer a Smart Object.
  4. Double click the Smart Object to open it in a new window.
  5. Add Canvas with Relative checked using a value twice the size of the required border.
  6. Fill the enlarged canvas with foreground colour
  7. Save and delete the Smart Object window, which takes you back to the main document.
  8. Ctrl click the now larger Smart Object layer to load it as a selection.
  9. Delete the Smart Object layer.

Stop recording the Action.

image.png

It works a treat and takes less than a second to run on my five year old system.  I don't know how to pause an Action to enter the Canvas Size value.  Is that doable?

Translate
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
Community Expert ,
Oct 11, 2022 Oct 11, 2022

I feel I should add to the above that the only reason I did it with an Action is that it seemed like a lot of steps.  You could obviously do it all manually, and it would still only take about ten seconds, but I am thinking a lot of people would think it long winded.  Like I said in the above post, knowing how the OP needs to use the expanded selection might make all the difference in providing the best solution.

Translate
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
Community Expert ,
Oct 11, 2022 Oct 11, 2022

I'm still going to look into a script, however, I'm also looking at an action based around QuickMask mode and the Min/Max filters.

Translate
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
Community Expert ,
Oct 11, 2022 Oct 11, 2022

The Select>Modify>Border command or Select>Fringe in ps 1 and 2 always creates a feathered border

good for getting rid of Halos of a pasted object/image or using Gaussian Blur to blend in a pasted object/image

better.

 

Anyway, you ca get rid of the feather by:

 

1. With the selection active after running the Modify Border command, press Q on your keyboard to

     enter Quickmask Mode

 

2. Go to Filter>Other>Maximum with Preserve Squareness, enter about half the value you used in

     the Border command.

 

qm1.png

 

3. Then go to Image>Adjustments>Threshold and move the slider all the way to the right (255)

 

qm2.png

 

4. Unfortunately when doing this and using higher values in the Border command above

     about 15, the threshold leave a 1px cutout at each corner, though it's easily corrected by

     using the pencil tool set to 1px and just filling in each corner.

 

qm3.png

 

5. Press Q to Exit Quick Mask Mode

 

 

qm4.png

Translate
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
Community Expert ,
Oct 11, 2022 Oct 11, 2022

OK, I have just learned a new trick.  I had to use Minimum to expand the selection, but it worked with perfectly sharp square corners.  Thank you Jeff and Stephen for the heads up.

Translate
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
Community Expert ,
Oct 11, 2022 Oct 11, 2022

@Will5CD1 wrote:

select>modify>border creates a border with rounded corners. what i really need is an offset of the original selection as a border, with sharp corners. how can i do this?

 


 

To clarify, Select > Modify > Border does not create rounded corners, although it appears to. What it has actually done is feathered the selection. This behavior started in CS3, and I have hated it ever since.

 

To confirm that the issue is actually feathering, try filling your selection after you have made the border.

 

Jane

 

Translate
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
Community Expert ,
Oct 12, 2022 Oct 12, 2022
LATEST

Here are three scripts to force sharp corners, so should only be used to modify square/rectangular selections...

 

Border:

 

/*
Select Modify Border Sharp Corners.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-border-selection-with-sharp-corners/td-p/13260671
Stephen Marsh, v1.0 - 12th October 2022
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/transform-selection-script/td-p/12707931
*/

#target photoshop

function main() {

	if (app.documents.length > 0) {

		// Save the current ruler units and set to pixels
		var origRulers = app.preferences.rulerUnits;
		app.preferences.rulerUnits = Units.PIXELS;

		// Loop the input prompt until a number is entered
        var userInput;
        while (isNaN(userInput = prompt("Border Selection (sharp corner):", "")));
        // Test if cancel returns null, then terminate the script
        if (userInput === null) {
            //alert('Script cancelled!');
            return
        }
        // Test if an empty string is returned, then repeat 
        while (userInput.length === 0) {
            userInput = prompt("Blank value not accepted, please enter a value in pixels:", "");
        }
        // Convert decimal input to integer
        var promptValue = parseInt(userInput);
		var borderValue = promptValue / 2;

		// Original selection bounds
		var origSelBounds = activeDocument.selection.bounds;

		expandSelection(SelectionType.REPLACE);
		contractSelection(SelectionType.DIMINISH);

		// Restore the ruler units
		app.preferences.rulerUnits = origRulers;


		// Functions

		function expandSelection(selType) {
			var expandArray = [
				[origSelBounds[0] - borderValue, origSelBounds[1] - borderValue],
				[origSelBounds[2] + borderValue, origSelBounds[1] - borderValue],
				[origSelBounds[2] + borderValue, origSelBounds[3] + borderValue],
				[origSelBounds[0] - borderValue, origSelBounds[3] + borderValue]
			];
			activeDocument.selection.select(expandArray, selType, 0, false);
		}

		function contractSelection(selType) {
			var contractArray = [
				[origSelBounds[0] + borderValue, origSelBounds[1] + borderValue],
				[origSelBounds[2] - borderValue, origSelBounds[1] + borderValue],
				[origSelBounds[2] - borderValue, origSelBounds[3] - borderValue],
				[origSelBounds[0] + borderValue, origSelBounds[3] - borderValue]
			];
			activeDocument.selection.select(contractArray, selType, 0, false);
		}

	} else {
		alert('A document must be open to use this script!');
	}
}
app.activeDocument.suspendHistory("Select Modify Border Sharp Corners.jsx", "main()");

 

 

Expand:

 

/*
Select Modify Expand Sharp Corners.jsx 
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-border-selection-with-sharp-corners/td-p/13260671
Stephen Marsh, v1.0 - 12th October 2022
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/transform-selection-script/td-p/12707931
*/

#target photoshop

function main() {

    if (app.documents.length > 0) {

        // Save the current ruler units and set to pixels
        var origRulers = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        // Loop the input prompt until a number is entered
        var userInput;
        while (isNaN(userInput = prompt("Expand Selection (sharp corner):", "")));
        // Test if cancel returns null, then terminate the script
        if (userInput === null) {
            //alert('Script cancelled!');
            return
        }
        // Test if an empty string is returned, then repeat 
        while (userInput.length === 0) {
            userInput = prompt("Blank value not accepted, please enter a value in pixels:", "");
        }
        // Convert decimal input to integer
        var theValue = parseInt(userInput);

        // Original selection bounds
        var origSelBounds = activeDocument.selection.bounds;

        // Expand selection array
        var theArray = [
            [origSelBounds[0] - theValue, origSelBounds[1] - theValue],
            [origSelBounds[2] + theValue, origSelBounds[1] - theValue],
            [origSelBounds[2] + theValue, origSelBounds[3] + theValue],
            [origSelBounds[0] - theValue, origSelBounds[3] + theValue]
        ];

        // Replace the selection with new selection
        activeDocument.selection.select(theArray, SelectionType.REPLACE, 0, false);

        // Restore the ruler units
        app.preferences.rulerUnits = origRulers;

    } else {
        alert('A document must be open to use this script!');
    }
}
app.activeDocument.suspendHistory("Select Modify Expand Sharp Corners.jsx", "main()");

 

 

Contract:

 

/*
Select Modify Contract Sharp Corners.jsx 
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-border-selection-with-sharp-corners/td-p/13260671
Stephen Marsh, v1.0 - 12th October 2022
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/transform-selection-script/td-p/12707931
*/

#target photoshop

function main() {

    if (app.documents.length > 0) {

        // Save the current ruler units and set to pixels
        var origRulers = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        // Loop the input prompt until a number is entered
        var userInput;
        while (isNaN(userInput = prompt("Contract Selection (sharp corner):", "")));
        // Test if cancel returns null, then terminate the script
        if (userInput === null) {
            //alert('Script cancelled!');
            return
        }
        // Test if an empty string is returned, then repeat 
        while (userInput.length === 0) {
            userInput = prompt("Blank value not accepted, please enter a value in pixels:", "");
        }
        // Convert decimal input to integer
        var theValue = parseInt(userInput);

        // Original selection bounds
        var origSelBounds = activeDocument.selection.bounds;

        // Contract selection array
        var theArray = [
            [origSelBounds[0] + theValue, origSelBounds[1] + theValue],
            [origSelBounds[2] - theValue, origSelBounds[1] + theValue],
            [origSelBounds[2] - theValue, origSelBounds[3] - theValue],
            [origSelBounds[0] + theValue, origSelBounds[3] - theValue]
        ];

        // Replace the selection with new selection
        activeDocument.selection.select(theArray, SelectionType.REPLACE, 0, false);

        // Restore the ruler units
        app.preferences.rulerUnits = origRulers;

    } else {
        alert('A document must be open to use this script!');
    }
}
app.activeDocument.suspendHistory("Select Modify Contract Sharp Corners.jsx", "main()");

 

 

Translate
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