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

Force snapping to pixels when placing image? Placed embedded images look messed up

Community Expert ,
Sep 10, 2024 Sep 10, 2024

Copy link to clipboard

Copied

For Context: I have an action that is meant to cut off the rounded corners of windows in screenshots. For this I use a small "mask" image that looks like this and is 12x12 px, and the action basically is multiple steps to align this image to each corner and use it update the layer mask of the base layer so the corners look rounded using transparency. The whole thing is automated with the action except for the placing of the image for the reason described below.

 

Here is what it is supposed to look like:

ThioJoe_0-1726003781043.png

 

But here's the problem:

For an image this small, when I go to place it via File > Place Embedded, apparently photoshop tries to apply to the center, but uses subpixels, so often times it "lands" in between pixels and looks messed up:

ThioJoe_1-1726003867343.png

 

When not using an action, I can fix this by simply dragging the image a bit and then it aligns it. But I can't do that with an action, because the action always records the transform relatively, looking like this:

ThioJoe_2-1726003986667.png


Because it's relative, that just lands me in the same problem of it completely depending on chance of the resolution of the project image and the zoom level for whether it will "land" centered or not.

I even tried using the "corner" mode, but it seems to ignore this, it still gets placed at the center of the view.

Note that the placed image here actually does look too thin with the left chopped off - it's not just that I cut it off while screenshotting.

ThioJoe_3-1726004103643.png

 

It seems like "corner" actually refers to like the corner of the bounds of the Free Transform box, not the canvas? Which again causes the same problem because that might land in betwen pixels. Notice the anchor point and the bounding box when set to corner:

ThioJoe_4-1726004322152.png

Here's the contents of the a test action of just placing the image, maybe someone has an idea of what needs to be edited to force an absolute location of the placed image? It doesn't matter where it goes since it will be auto aligned by a later step, it just needs to not be in between pixels!

 

 

 

 

 

<ActionFile key="ActionCornerTest.atn" file="~/AppData/Local/Temp/ActionCornerTest.atn">
  <ActionSet version="16" name="ActionCornerTest" expanded="false" count="1">
    <Action key="1" name="Action Corner Test" expanded="false" count="1">
      <ActionItem key="TEXT" expanded="true" enabled="true" withDialog="false" dialogOptions="0" identifier="TEXT" event="placeEvent" name="Place" hasDescriptor="true">
        <ActionDescriptor key="placeEvent" count="4">
          <DescValueType.INTEGERTYPE key="1231318644" id="1231318644" symname="Identifier" sym="Idnt" integer="24"/>
          <DescValueType.ALIASTYPE key="1853189228" id="1853189228" symname="Null" sym="null" path="/c/example/path/WindowCorner.png"/>
          <DescValueType.ENUMERATEDTYPE key="1179935603" id="1179935603" symname="FreeTransformCenterState" sym="FTcs" enumeratedTypeString="QuadCenterState" enumeratedType="QCSt" enumeratedValueString="QCSCorner0" enumeratedValue="Qcs0"/>
          <DescValueType.OBJECTTYPE key="1332114292" id="1332114292" symname="Offset" sym="Ofst" objectTypeString="Offset" objectType="Ofst" count="2">
            <ActionDescriptor key="1332114292" id="1332114292" symname="Offset" sym="Ofst" count="2">
              <DescValueType.UNITDOUBLE key="1215461998" id="1215461998" symname="Horizontal" sym="Hrzn" unitDoubleTypeString="Pixels" unitDoubleType="#Pxl" unitDoubleValue="0"/>
              <DescValueType.UNITDOUBLE key="1450341475" id="1450341475" symname="Vertical" sym="Vrtc" unitDoubleTypeString="Pixels" unitDoubleType="#Pxl" unitDoubleValue="0"/>
            </ActionDescriptor>
          </DescValueType.OBJECTTYPE>
        </ActionDescriptor>
      </ActionItem>
    </Action>
  </ActionSet>
</ActionFile>

 

 

 

 

 

 This is the image itself for testing:

WindowCorner.png

 

I have already have the "Snap vector tools" option enabled. I also tried enabling legacy transform, enabling/disabling "resize image during place", and "skip transform while placing".

-------------------

UPDATE:

I figured out a work around at least, it takes an extra step and requires placing it as a linked object instead of embedded.

For the action, record: 

  1.  File > "Place Linked" (Not embedded)
  2.  Layer > Smart Objects > Reset Transform

    The "Reset Transform" step might not be recorded if there wasn't a transform done, but you can force it by just doing a transform on the smart object yourself while recording, then reset transform, and delete the step where you transformed it, leaving only the reset transform step.
TOPICS
Actions and scripting , Windows

Views

201

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

correct answers 1 Correct answer

Community Expert , Sep 10, 2024 Sep 10, 2024

Hm unless I misinterpreted you mean align the layer after it's been placed. But the problem is once it's placed, it's already too late, it stays messed up since it seems to render the final pixels upon placing. Resizing, transforming, moving afterwards won't make it look like it should.

 

One thing I noticed is that when placing an asset from the Library panel by right clicking and hitting "Place Layers", it always aligns it to pixels and never looks messed up. But unfortunately actions don't seem

...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 10, 2024 Sep 10, 2024

Copy link to clipboard

Copied

Try adding a select all step and then with the move tool active align the layer to the selection using the toolbar alignment options.

 

Alternatively, on the rectangular mask, look at using the median filter to round the edges instead.

Votes

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
Community Expert ,
Sep 10, 2024 Sep 10, 2024

Copy link to clipboard

Copied

Hm unless I misinterpreted you mean align the layer after it's been placed. But the problem is once it's placed, it's already too late, it stays messed up since it seems to render the final pixels upon placing. Resizing, transforming, moving afterwards won't make it look like it should.

 

One thing I noticed is that when placing an asset from the Library panel by right clicking and hitting "Place Layers", it always aligns it to pixels and never looks messed up. But unfortunately actions don't seem to be able to record placing an item from the library.

Also the reason I want to use my image instead of a rounding filter or something is because it's custom made pixel by pixel to fit the corners of Windows 11 windows.


Update: Ok I figured out a workaround that seems to work. For the action, record: 

  1.  File > "Place Linked" (Not embedded)
  2.  Layer > Smart Objects > Reset Transform

    When placing as a linked object it still looks messed up upon placing, and fortunately 'reset transform' actually puts it back to normal. 
    Strangely, even placing linked, doing stuff like free transforming and aligning doesn't fix it, it still uses the messed up raster. But reset transform apparently forces it back despite not actually being transformed.

Votes

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
Community Expert ,
Sep 10, 2024 Sep 10, 2024

Copy link to clipboard

Copied

LATEST

@ThioJoe 

 

Glad you found a workable solution!

Votes

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