Jump to content
You must now use your email address to sign in [click for more info] ×

support for percent resize in macros and input boxes


Recommended Posts

At the moment it is AFAIK impossible to write image size independent macros if you want to use "resize canvas/document" because these operations work on pixels.

Problem:
Affinity photo should be 360 aware but it isn't really - local adjustment filters and tonemapping leave visible seams.

Workaround:
One easy way to get around that is to increase the canvas width by 20% (<- this is the problem),
   use equations to fill the right and left border,
   make the adjustment and
resize the width of the canvas back to the original size - shrink width by 16.66% (<-again a problem)

At them moment this can't really be done independent of the image size because a size increase/decrease will be calculated to pixels - so there will be a fixed pixel number in the macro

Solutions:

  • The easiest solution would be if Affinity Photo would support resize by percent properly - by that I mean also in macros
  • support expressions in input fields also in macros -> if you put "*1.2" in an input field this expression will also be used in the macro
  • support variables in macros - reading image size into variables which can be used in later operations


To give an example - I have written a macro which increases a 360 panorama by 10% on each side and fills the properly BUT it will only work properly with a 10000 x 5000 px panorama (my main publishing size).

Would be really good for Affinity photo if the macro capabilities got better - it can really speed up a workflow and make repetitive tasks a lot easier but for that it needs to be possible to do pretty much everything independent of the image size and in a way - that's where percentages come in really handy.

 

10kBy5kPlus10%eachSide.afmacro

Link to comment
Share on other sites

This probably can be done, but it will require that you use Filters > Distort > Equations... in your macro to perform the resizing operation.

For an example:

For more information on using Equations, there are some topics in the Tutorials forum.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

18 hours ago, Kronpano said:

One easy way to get around that is to increase the canvas width by 20% (<- this is the problem),

The attached macro should do that

It adds a transparent canvas width of 10% to each side of the document 

Tested on 2000px - 20000px width documents

In multiples of 500px (e.g. 2500px, 3000px, 3500px etc) you "should" get accurate resizing results but due to rounding (up/down) in the macros and equation filter, the resize can be 2-4 pixels off if you use totally random widths to start with.

It works at the layer level, not the document level so either start with a jpg/png file etc or merge (flatten?) all layers into one in your document first.

To run just select the layer  then run the macro

 

add-10%-each-side.afmacro

To save time I am currently using an automated AI to reply to some posts on this forum. If any of "my" posts are wrong or appear to be total b*ll*cks they are the ones generated by the AI. If correct they were probably mine. I apologise for any mistakes made by my AI - I'm sure it will improve with time.

Link to comment
Share on other sites

OK, thanks for that.
I see - I did pretty much the same BUT I didn't think of using a "dummy" layer, then resizing the canvas, clipping it and throw away the dummy.

So close and yet so far.

Thanks again.

Will try to incorporate it into my macro.
If I can't get there are you happy to share the equation??

Link to comment
Share on other sites

6 hours ago, carl123 said:

It adds a transparent canvas width of 10% to each side of the document 

When you say "each side" do you mean "right and left sides"? That's what I get, but I wasn't sure if you meant to include all 4 sides.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

Yes, just "right and left sides" which was the OP's requirement.

More specifically the ability to do this as a percentage value on any size image rather than a hardcoded pixel value which will only work on images of the same dimensions

To save time I am currently using an automated AI to reply to some posts on this forum. If any of "my" posts are wrong or appear to be total b*ll*cks they are the ones generated by the AI. If correct they were probably mine. I apologise for any mistakes made by my AI - I'm sure it will improve with time.

Link to comment
Share on other sites

Yes, left and right side.

The whole idea is to overcome Affinity photos inability to treat 360 panoramas properly.
A 360 panorama is usually a file with a 2:1 ratio - 360 degrees around and 180 degrees up/down - so a full sphere.
The problem are the right and left "edges" of the file. When looking at a panorama (example here on kuula ) the right and left side need to fit together seamlessly otherwise there will be a vertical line visible in the panorama.
General changes in brightness, colours... don't affect that BUT local changes (like clarity, local contrast, tonemapping) cause a problem because if I apply them to the original image the edges have no neighbour - so the left edge will be treated differently from the right edge and when I put them together there is a visible seam.
This can be prevented by by extending the original image (basically give each edge neighbours) - this is possible because the 360 panorama can just be wrapped around so it will fit seamlessly.

My macro I provided in the post at the top does just that - BUT it is size dependent.

Now I had a go with the macro @carl123 posted yesterday and I am not sure it helps.
Yes - it adds 10% to each side - so that problem is solved BUT once I have done that (manually or in a macro) I have "lost" my original width of the panorama and don't know how far to shift the image to extend the right/side because the width w is now the extended width.

Let me explain my macro
Assume a 10000x5000px panorama

Extend the canvas by 20% centred  - this will result in a 12000x5000 canvas with the original panorama in the middle and 10% transparent on each side
Duplicate that layer and shift it to the right by 10000px - this will seamlessly fill the right hand side 10% extension
Duplicate the layer and shift it to the left by 10000px - the same for the left hand side 10% extension
Merge them all down and you are done

You will end up with a 12000x5000px document which has no seams in itself

Apply any local adjustment and the "original" edges will be treated the same because they have the "proper" neighbours
Once you are done with the adjustments you can just resize the canvas back (centred)  to 10000x5000px and you will have again a 360 panorama with no seams.

This is what Affinity photo should probably do in the first place since it claims to be 360 aware so all of that is only to get around the limitations the program shouldn't have in the first place.
I have raised that problem about 18 month ago and after a long silence it was confirmed here

that it will NOT be solved.
A solution provided by @James Ritson relies on as far as I can see on resizing the pixels (squashing and expanding like equation x/0.9 and x/(1/0.9) ) which will deteriorate the image quality since the final expansion is not working on the original pixels but the squashed ones.

So please give us either a % resize that can be used in macros or even better - a macro scripting language (like Mathmap for GIMP) so you can work with variables and stuff and not just one line equations which can't be saved and edited properly.

Not sure it makes sense to anybody who is not working with panoramas but I hope my explanation makes sense.
Cheers.
 

Link to comment
Share on other sites

OK, I think I am giving up

Just thought I had it - using distort -> affine 
Extend the canvas to really wide (like 20000x100) and then use distort -> affine with 120% and clip the canvas again

Should result in a 10000 scaled to 120% should be 12000 pixels wide 

NOOOOO

it is 12002 pixels wide - internal rounding problem I would guess but that that is out of my control and again - probably size dependent.

Same happens with all my equations - they are all 2 pixels to wide - grrrr:(

Link to comment
Share on other sites

I'm due a coffee break so give me 10 minutes to have a look at this. 

(I think I understand what the second part of your process is -  if so it should be doable) 

To save time I am currently using an automated AI to reply to some posts on this forum. If any of "my" posts are wrong or appear to be total b*ll*cks they are the ones generated by the AI. If correct they were probably mine. I apologise for any mistakes made by my AI - I'm sure it will improve with time.

Link to comment
Share on other sites

Ok, from what I understand after the 20% canvas resize you need to shift copies of the image left and right to fill in the transparent areas.

I can only test on normal images as I don't have one of your 360 panoramas to see if this works on them.

So you will need to let me know what happens if it's incorrect

To run just select the layer then run the macro 

(There is no need to run the previously supplied macro first)

PS Macro may take a minute or 2 to run on very large documents

 

360-panorama-macro.afmacro

To save time I am currently using an automated AI to reply to some posts on this forum. If any of "my" posts are wrong or appear to be total b*ll*cks they are the ones generated by the AI. If correct they were probably mine. I apologise for any mistakes made by my AI - I'm sure it will improve with time.

Link to comment
Share on other sites

42 minutes ago, Kronpano said:

I have tried clamp, round, floor in my equation but I ended up with 12001 - still one pixel too wide 

I'm afraid you went down the wrong track when analyzing one of my old macros.

It has nothing to do with clamp, round, or floor - it's a lot simpler than that

I wrote down the important specific value I needed in the equation formula but not all of it so I just need to recreate it fully and will post back shortly.

 

To save time I am currently using an automated AI to reply to some posts on this forum. If any of "my" posts are wrong or appear to be total b*ll*cks they are the ones generated by the AI. If correct they were probably mine. I apologise for any mistakes made by my AI - I'm sure it will improve with time.

Link to comment
Share on other sites

Ok, my first equation used the Polar Coordinate System not the Cartesian

Value (1.1999) as shown in the screenshot below


 

equations.jpg

To save time I am currently using an automated AI to reply to some posts on this forum. If any of "my" posts are wrong or appear to be total b*ll*cks they are the ones generated by the AI. If correct they were probably mine. I apologise for any mistakes made by my AI - I'm sure it will improve with time.

Link to comment
Share on other sites

Thanks for that!!!
I had a play with polar but didn't come up with that formula.
Doesn't really seem intuitive but hey - it works.

Still a shame that the cartesian calculations seem to be out by a pixel - if I do floor(x/1.2) - which I would expect to increase my image to 120% I end up with an extra pixel.
Should have done x/1.1999 all along :D

In a way the 1.1999 in your solution is also just solving a problem that shouldn't be there - some internal rounding errors??

Thanks for all the help - now I can use Affinity photo a bit more for my intended purpose - post-processing panoramas. 

Link to comment
Share on other sites

  • 2 weeks later...

It would be very helpful to increase the canvas size by percentage. 

On Photoshop I used it often when I had a lot of products (often with different resolution) - so it is not possible to set the same padding for all in a batch job.
In that programme was also an option to set the size relatively that allows you to add the same padding in pixels for all images after resizing. But in AP you can not use Resize document in macro. So you have to do all the steps in a few parts and sometimes quite strange ways :)

Regards,
Dominik

Link to comment
Share on other sites

  • 1 year later...
On 12/2/2019 at 1:39 PM, walt.farrell said:

This probably can be done, but it will require that you use Filters > Distort > Equations... in your macro to perform the resizing operation.

For an example:

For more information on using Equations, there are some topics in the Tutorials forum.

Can someone please add the macro as a macros (with an S) file so it can be imported onto an iPad. 
 

thanks!

Link to comment
Share on other sites

2 hours ago, JonnyPanic said:

Can someone please add the macro as a macros (with an S) file so it can be imported onto an iPad. 
 

thanks!

Perhaps @carl123 would consider doing that :)

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

2 hours ago, JonnyPanic said:

Can someone please add the macro as a macros (with an S) file so it can be imported onto an iPad. 
 

thanks!

Done

 

Selectively resize image height from 1000px to 100.afmacros

To save time I am currently using an automated AI to reply to some posts on this forum. If any of "my" posts are wrong or appear to be total b*ll*cks they are the ones generated by the AI. If correct they were probably mine. I apologise for any mistakes made by my AI - I'm sure it will improve with time.

Link to comment
Share on other sites

1 hour ago, JonnyPanic said:

Can i also get the 360-panorama-macro.afmacro as a macroS file...

Thank you!

You should post in the topic where the macro was offered, and ask the author.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.