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

Enhance Resizing Workflow with Fit-to-Canvas Option

Explorer ,
Oct 03, 2024 Oct 03, 2024

When inserting a larger image that exceeds the canvas area, pressing Ctrl+T (for resizing) should have the default position set to the top-left corner (or remember the previous position).

In the resize function, there should be an additional button to automatically scale the entire image to fit the canvas size, instead of just having rotate and flip options. This would be a much more useful feature than rotate and flip.

The current resizing options are limiting. A "Fit to Canvas" feature would be much more practical and accessible for everyday use than rotate and flip.

This function would streamline workflows and save time for users who frequently need to resize images. Many users, especially those working with large or multiple images, face this challenge. It would benefit a broad user base, not just a niche group.

Idea No status
TOPICS
macOS , Windows
1.6K
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
12 Comments
Community Expert ,
Oct 03, 2024 Oct 03, 2024

@Balázs28016806xdji 

 

How would you propose different aspect ratios and proportions be handled when fitting the oversized layer content to the canvas?

 

If the layer was landscape orientation and the canvas was portrait, would the resize fit to the canvas width, leaving blank space at the top and bottom (letterboxing)? Or would the landscape content be sized to the height of the portrait canvas, with the wider sides "cropping" or falling off to the sides of the canvas? And vice/versa for portrait layers on a landscape canvas.

Translate
Report
Community Expert ,
Oct 03, 2024 Oct 03, 2024

A scripted option, obviously not as convenient as the transform toolbar but better than nothing for now:

 

2024-10-03_22-16-30.png

 

/*
Resize Layer to Canvas scriptUI GUI.jsx
v1.0 - 3rd October 2024, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-ideas/enhance-resizing-workflow-with-fit-to-canvas-option/idc-p/14895563
Inspiration from:
https://forums.adobe.com/message/5413957
https://forums.adobe.com/thread/1968642
https://forums.adobe.com/message/8022190
https://gist.github.com/jawinn/ab4df1c33d0743e41fd3
https://gist.githubusercontent.com/jawinn/ab4df1c33d0743e41fd3/raw/72ff297ae42ed029c86be7644bd021ef46971070/Fit%2520Layer%2520To%2520Canvas.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/trying-to-do-text-to-fit-the-width-of-the-canvas-dimensions/m-p/11589399
*/

#target photoshop

// Check if there's an active document
if (app.documents.length > 0) {

    var win = new Window("dialog", "Resize Layer to Canvas (v1.0)");

    // Dropdown for resize options
    var resizeGroup = win.add("group");
    resizeGroup.add("statictext", undefined, "Resize Option:");
    var resizeDropdown = resizeGroup.add("dropdownlist", undefined, [
        "Maintain Aspect Ratio",
        "Fill Canvas (may crop)",
        "Fit to Canvas (may distort)"
    ]);
    resizeDropdown.selection = 0; // Default to maintain aspect ratio

    // OK and Cancel buttons, right-aligned
    var buttonGroup = win.add("group");
    buttonGroup.alignment = "right"; // Right-align the button group
    var cancelButton = buttonGroup.add("button", undefined, "Cancel");
    var okButton = buttonGroup.add("button", undefined, "OK");

    okButton.onClick = function () {
        win.close();
        fitLayerToCanvas(resizeDropdown.selection.index);
    }

    cancelButton.onClick = function () {
        win.close();
    }

    win.show();

    function fitLayerToCanvas(resizeOption) {
        if (app.documents.length > 0) {
            app.activeDocument.suspendHistory('Fit Layer to Canvas', 'FitLayerToCanvas(' + resizeOption + ')');
        }
    }

    function FitLayerToCanvas(resizeOption) {
        var doc = app.activeDocument;
        var layer = doc.activeLayer;

        // do nothing if layer is background or locked
        if (layer.isBackgroundLayer || layer.allLocked || layer.pixelsLocked ||
            layer.positionLocked || layer.transparentPixelsLocked) return;

        // do nothing if layer is not normal artLayer or Smart Object
        if (layer.kind != LayerKind.NORMAL && layer.kind != LayerKind.SMARTOBJECT) return;

        // store the ruler
        var defaultRulerUnits = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        var width = doc.width.as('px');
        var height = doc.height.as('px');
        var bounds = layer.bounds;
        var layerWidth = bounds[2].as('px') - bounds[0].as('px');
        var layerHeight = bounds[3].as('px') - bounds[1].as('px');

        // Calculate new dimensions
        var newWidth, newHeight;
        var layerRatio = layerWidth / layerHeight;
        var canvasRatio = width / height;

        switch (resizeOption) {
            case 0: // Maintain Aspect Ratio
                if (layerRatio > canvasRatio) {
                    newWidth = width;
                    newHeight = newWidth / layerRatio;
                } else {
                    newHeight = height;
                    newWidth = newHeight * layerRatio;
                }
                break;
            case 1: // Fill Canvas (may crop)
                var scale = Math.max(width / layerWidth, height / layerHeight);
                newWidth = layerWidth * scale;
                newHeight = layerHeight * scale;
                break;
            case 2: // Fit to Canvas (may distort)
                newWidth = width;
                newHeight = height;
                break;
        }

        // Resize the layer
        var resizePercentX = newWidth / layerWidth * 100;
        var resizePercentY = newHeight / layerHeight * 100;
        layer.resize(resizePercentX, resizePercentY, AnchorPosition.TOPLEFT);

        // Always center the layer
        var newX = (width - newWidth) / 2;
        var newY = (height - newHeight) / 2;

        // Move the layer to the new position
        layer.translate(new UnitValue(newX - layer.bounds[0].as('px'), 'px'), new UnitValue(newY - layer.bounds[1].as('px'), 'px'));

        // restore the ruler
        app.preferences.rulerUnits = defaultRulerUnits;
    }

} else {
    alert("A document must be open to run this script!");
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

 

Translate
Report
Explorer ,
Oct 03, 2024 Oct 03, 2024

Thank you so much! This script is absolutely fantastic - I tried it, and it works brilliantly.

But it raises the question: why do users have to rely on scripts to enhance Photoshop with such essential functionality? This feature should really be included by default, as it would greatly improve the workflow for many people.

It’s exactly the kind of feature that could be tied to a couple of icons within the resizing tools, solving a common problem with just a click. If the developers could integrate this into the main interface, it would make a huge difference for a lot of users. It’s time to focus on practical, useful tools like this - beyond just AI features!

Translate
Report
LEGEND ,
Oct 03, 2024 Oct 03, 2024

If you read through these forums, you'll find dozens of "essential features" that someone wants, most of which I personally would never use. Photoshop is already bloated and hard to learn, dumping more and more and more in isn't improving the experience IMHO.

Professional tools usually allow extension via scripts and plugins. This is expected, pro users can customize things to their liking. Adobe apps are one good example, Microsoft Office is another example where the sky is the limit to customizing via scripts and plugins.

Translate
Report
Explorer ,
Oct 03, 2024 Oct 03, 2024

Yes, the issue often seems to be that it’s easier for developers to respond in forums with "we know better." But more often, it would be worth opening the program and actually trying out what users are talking about. Just because you don’t use a feature doesn’t mean that it isn’t exactly what others need.

I can see you’re an expert, answering a lot of questions, but I’d suggest you try it out yourself in Photoshop. When you insert a large image that extends beyond the canvas, try resizing it to fit the canvas. Look at how many steps it takes and how much manual adjustment is needed with the mouse. Now, check out the script—imagine solving this with one click.

If you’re building software, make it good, don’t just look for reasons to say it's fine as it is. Innovation means moving forward and providing better solutions. Instead of telling users to deal with their own problems, it would be better to approach these issues with an open mind and look for ways to improve the experience.

Translate
Report
LEGEND ,
Oct 03, 2024 Oct 03, 2024

Photoshop has options to transform when placing and to create a smart object. Both are helpful if you do this often. I've been using Photoshop since version 2.5 and have never had any problems with this so I dunno...

Translate
Report
Explorer ,
Oct 03, 2024 Oct 03, 2024

When you drag in a local file, it resizes perfectly to fit the canvas. However, when you paste an image with Ctrl+V or use drag-and-drop from the web, that's when the issues start to occur.

Translate
Report
LEGEND ,
Oct 03, 2024 Oct 03, 2024

Yes there are inconsistencies. I doubt that Adobe is going to revise this, just saying.

Translate
Report
Community Expert ,
Oct 03, 2024 Oct 03, 2024

This functionality already exists when bringing in smart objects (either via Place or by dragging/dropping from outside Photoshop). Oversized smart objects will be scaled to fit if the checkbox "resize during place" is checked in Preferences - which it is by default.

 

When you drag and drop from within Photoshop, it's a regular copy/paste with normal pixel-to-pixel alignment.

 

A large number of users are already very unhappy with the built-in behavior of smart objects to honor physical print size, as determined by the ppi number, and not honor pixel dimensions. There are good reasons for that behavior, but any further movement towards automatic scaling will most likely spark huge protests.

 

To most seasoned users, upscaling is not something you want - unless it's a very deliberate decision by the user, weighing all the pros and cons. You don't want to upsample except as a last resort.

 

This may fit your particular workflow, but to most users it will not make a lot of sense.

Translate
Report
LEGEND ,
Oct 03, 2024 Oct 03, 2024

"When you drag and drop from within Photoshop, it's a regular copy/paste with normal pixel-to-pixel alignment."

There is a bug when dragging layers from one document to another, if zoom levels are different, where they don't align. I reported it and it popped up again with another user reporting.

Translate
Report
Community Expert ,
Oct 03, 2024 Oct 03, 2024

OK. I haven't seen that one. But there's been a few bugs lately which only affect a few users with no apparent pattern. I reported another one myself recently, but only 4 or 5 other users so far have seen it.

Translate
Report
LEGEND ,
Oct 04, 2024 Oct 04, 2024
LATEST

I frequently drag layers between same-size images. If one is at 50% and the other 66%, the dragged layer won't align to the edges but with both at 50%, it will.

Translate
Report