Jump to content

Recommended Posts

Posted

AFAIK not in an dynamic image independent manner, since an Affinity macro usually records here fixed absolute values of the already loaded document during the state of recording.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Posted
9 minutes ago, IanBarber said:

Does Affinity Photo have any scripting capabilities or API's you can use do you know.

NO not yet! - The only thing it offers beside it's limited macros facility is a partial support of the PS Plug-in API (... much reduced to image transfer & update from the PS plugins API, so a limited functionality subset).

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Posted
35 minutes ago, IanBarber said:

Is it possible to retrieve the document width and height from a Macro

What ultimately are you trying to achieve?

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.

Posted

You do know that if you enter "w" into a dialog box you will get the document width?

John

Windows 11, Affinity Photo 2.4.2 Designer 2.4.2 and Publisher 2.4.2 (mainly Photo).

CPU: Intel Core i5 8500 @ 3.00GHz. RAM: 32.0GB  DDR4 @ 1063MHz, Graphics: 2047MB NVIDIA GeForce GTX 1050

Posted
2 minutes ago, John Rostron said:

You do know that if you enter "w" into a dialog box you will get the document width?

John

Can you please explain a little more

Posted
3 hours ago, IanBarber said:

Do you have a working example of using these expressions in input boxes. Cannot seem to get these to stick

Not sure what you mean, just try/use some of the expressions in the named input fields, for example the transform panel. - For example try to resize an object's/shape's height via typing "2*w" into the height field. For an object/shape let's say of w=150 px, h=150 px you would get then as a new height value h = 2*w = 2*150 = 300 px.

Similar when setting dimensions using the New Document or Document Setup dialogs w will give you the docs actual width as a value. - Those vars are like placeholders for the related value here, so you can perform some simple math operations with them. The result will be always numeric values.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Posted
Just now, v_kyr said:

Similar when setting dimensions using the New Document or Document Setup dialogs w will give you the docs width as a value.

Note that it should be a lower case w; upper case W does not work,

All 3 1.10.8, & all 3 V2.6 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
A
ll 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Posted
4 minutes ago, R C-R said:

Note that it should be a lower case w; upper case W does not work,

Somebody forgotten to apply a toLower function call for the input validation or calc expression there. - Or they intensionally wanted to give users a chance to be able in future to define custom uppercase vars of these on demand (who knows).

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Posted (edited)

What I wanted to do was for example, make this shape extend to the edge of the picture but I don't see a way of getting the image width dynamically because it could change for different images loaded.

1235239159_Screenshot2022-03-09at20_38_53.thumb.jpg.dce57bccfd6fb2aeded1e165d5bca041.jpg

Edited by IanBarber
Posted (edited)

💡might be getting somewhere now, sprw gives the spreadwidth so might be able to use that.

sw works but only for that one document unfortunately

Edited by IanBarber
Posted
2 hours ago, IanBarber said:

What I wanted to do was for example, make this shape extend to the edge of the picture but I don't see a way of getting the image width dynamically because it could change for different images loaded.

That sounds like you tried to use that in some macro (?). However that won't work since as I said before in another thread, those commands aren't recording in a dynamically variable manner in macros. Instead a macro always records and contains only the absolut fixed size values of that specific doc/image it has been recorded on. In other words, a macro doesn't record a dynamically getWidth() function call, instead it only records the absolut static doc values of that one document in use during recording.

So for what you want to do there above, an external Python script which then manipulates a passed image accordingly, or some ImageMagick commands in batch script are overall better suited.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Posted

@v_kyr I did try this in a Macro but then quickly realised that what you had said is correct which is very frustrating.

If you set the Scale option in the Macro Library panel to Min Fit, I am sure it worked every time on any image. I never tried it it but I also think this option is Global across all Macros in the Library which if it is could lead to issues for other Macros in there.

Do you know without me doing a bunch of testing if the Scale is Global to all.

1727504562_Screenshot2022-03-10at09_10_43.jpg.daba3802b6b9433703dd8fdb969e52e2.jpg

Posted
12 hours ago, IanBarber said:

What I wanted to do was for example, make this shape extend to the edge of the picture but I don't see a way of getting the image width dynamically because it could change for different images loaded.

Just extend the shape's width to a very high number (e.g. 10,000px)

The fact that it extends off the canvas will be irrelevant in most situations

But if you don't mind rasterising the shape, use the Rasterise and Trim command after resizing it, which will constrain/crop it back to the canvas width

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.

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.