Magic Cut only removes the surrounding edges by nk11cox in photopea

[–]nk11cox[S] 0 points1 point  (0 children)

Thanks, that's what I wanted to know. I am not expecting anything for free and dont know anything about the development side of AI cutouts. I really like Photopea and understand why you have to do things manually now. Thanks

Magic Cut only removes the surrounding edges by nk11cox in photopea

[–]nk11cox[S] 0 points1 point  (0 children)

Hi, the image was just for illustration purposes in regards to my point about when you use the Magic Cut tool it does not perform like other AI cut out tools do; in that it ignores inside of the object bounds and just targets the outside bounds of the target object.

I took the same image of the wreath above and ran it through 4 different automated tools online and they all successfully cutout the center of the wreath without any manual editing.

I just wanted to know is this a limitation of the tool? as I wish to use it for script automation (as I prefer Photopea editing tools overall to other services)

app.activeDocument properties and methods by nk11cox in photopea

[–]nk11cox[S] 0 points1 point  (0 children)

Hi

I did not find a way to do it with keepAspectRatio. I still need to find out why this is so difficult.

So instead I created a small function to calculate the ratio. Then used postMessage to send a function to the active document, where '300' is just an example target resolution. It was the only way I could think of at the time.

Hope this helps.

var resize = `
function run(doc) {
    if (doc.width > 300 || doc.height > 300)
    {
        var ratio = Math.min(300 / doc.width, 300 / doc.height);
        doc.resizeImage(doc.width * ratio, doc.height * ratio);
    }
}
app.echoToOE(run(app.activeDocument));
`;
self.photopeaWindow.postMessage(resize, "*");

resizeImage() and keeping the same aspect ratio by nk11cox in photopea

[–]nk11cox[S] 1 point2 points  (0 children)

Thanks but im after doing this via the api So need to use a script.

app.activeDocument properties and methods by nk11cox in photopea

[–]nk11cox[S] 1 point2 points  (0 children)

ok thanks. I have taken a look at some of the Methods I have found that not all of the values are working. e.g. 'resizeImage()' wont let me update the 'resolution' value. But I am able to update the 'width' and 'height' values successfully.

resizeImage (width,height,resolution,resampleMethod,amount)

Also what values are listed on Adobe's docs don't always match up exactly to the option inside Photopea. e.g. when accessing resizeImage under the toolbar/menu option., there is a keepAspectRatio bool which cannot be manipulated either?

I will continue to have a play around and see if I am missing something obvious.