IanBarber Posted March 8, 2022 Posted March 8, 2022 Is it possible to retrieve the document width and height from a Macro Quote
v_kyr Posted March 8, 2022 Posted March 8, 2022 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. Quote ☛ 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
IanBarber Posted March 8, 2022 Author Posted March 8, 2022 @v_kyrthanks for clarifying that. Does Affinity Photo have any scripting capabilities or API's you can use do you know. Quote
v_kyr Posted March 8, 2022 Posted March 8, 2022 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). Quote ☛ 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
carl123 Posted March 8, 2022 Posted March 8, 2022 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? Quote 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.
IanBarber Posted March 8, 2022 Author Posted March 8, 2022 I was creating a Macro but needed the current document width to start from. I have managed to create a work around for now which should work Quote
John Rostron Posted March 9, 2022 Posted March 9, 2022 You do know that if you enter "w" into a dialog box you will get the document width? John Quote 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
IanBarber Posted March 9, 2022 Author Posted March 9, 2022 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 Quote
v_kyr Posted March 9, 2022 Posted March 9, 2022 13 minutes ago, IanBarber said: Can you please explain a little more See related the APhoto ... Expressions for field input John Rostron 1 Quote ☛ 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
IanBarber Posted March 9, 2022 Author Posted March 9, 2022 4 hours ago, v_kyr said: See related the APhoto ... Expressions for field input Do you have a working example of using these expressions in input boxes. Cannot seem to get these to stick Quote
v_kyr Posted March 9, 2022 Posted March 9, 2022 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. Quote ☛ 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
R C-R Posted March 9, 2022 Posted March 9, 2022 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, Quote 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 All 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7
v_kyr Posted March 9, 2022 Posted March 9, 2022 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). Quote ☛ 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
IanBarber Posted March 9, 2022 Author Posted March 9, 2022 (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. Edited March 9, 2022 by IanBarber Quote
IanBarber Posted March 9, 2022 Author Posted March 9, 2022 (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 March 9, 2022 by IanBarber Quote
v_kyr Posted March 9, 2022 Posted March 9, 2022 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. Quote ☛ 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
IanBarber Posted March 10, 2022 Author Posted March 10, 2022 @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. Quote
carl123 Posted March 10, 2022 Posted March 10, 2022 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 Quote 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.
Recommended Posts
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.