BigT Posted January 19 Posted January 19 Hi, I'm new to Affinity and have been looking to replicate actions that I had in Photoshop. One in particular would Flatten the image, Resize the image to 1200 px tall, add a 2 px white Stroke around the image, then save as a Jpg in a specified folder before quitting the edit. In Affinity Macros I can Flatten the Layers, Rasterise and Trim to lose any additional data post cropping (found this on another post), and use Layer Effects to add a border. I don't seem to be able to automate the resize option for a generic 1200 high, and it won't export the jpg file. Am I missing something or is this just not possible yet? Quote
Komatös Posted January 19 Posted January 19 Hello @BigT and welcome to the forums. You don't missing anything. It's impossible to add file operations to macros. But you can use youre macro with a New Batch Job... Quote MAC mini M4 | MacOS Sequoia 15.3.2 | 16 GB RAM | 256 GB SSD AMD Ryzen 7 5700X | INTEL Arc A770 LE 16 GB | 32 GB DDR4 3200MHz | Windows 11 Pro 24H2 (26100.3194) Affinity Suite V 2.6.1 & Beta 2.6 (latest) Interested in a free (selfhosted) PDF Solution? Have a look at Stirling PDF I already had a halo, but it didn't suit me!
R C-R Posted January 19 Posted January 19 1 hour ago, Komatös said: It's impossible to add file operations to macros. This is at least in part because currently macros store results, not actions, so a save step in a macro would include the file path, which may not even exist or be available at a later time. Hopefully, the promised scripting functions will make this more feasible at some point in the future. 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
Komatös Posted January 19 Posted January 19 6 minutes ago, R C-R said: This is at least in part because currently macros store results, not actions Hence the intermediate step via the batch! Quote MAC mini M4 | MacOS Sequoia 15.3.2 | 16 GB RAM | 256 GB SSD AMD Ryzen 7 5700X | INTEL Arc A770 LE 16 GB | 32 GB DDR4 3200MHz | Windows 11 Pro 24H2 (26100.3194) Affinity Suite V 2.6.1 & Beta 2.6 (latest) Interested in a free (selfhosted) PDF Solution? Have a look at Stirling PDF I already had a halo, but it didn't suit me!
Ldina Posted January 19 Posted January 19 @BigT Attached is a macro you can try out. It resizes your image to 1200 px high, rasterizes and flattens it, then adds a 2 pixel white border (to the inside). You can run it on an image by image basis, or as part of a New Batch Job if you want to process a bunch of files all at once. Test it out first on both a vertical and horizontal image to be sure it's working properly. Import the macro first. Window > Macros, and from the hamburger menu, Import macro. You can add it to the default category, or one of your own. To run the macro on a Batch, File > New Batch Job. Select and Add the images you want to process. Deselect AfPhoto as output format, and select JPG or whatever you want as your desired output. You can leave the size and width fields empty, since the macro automatically resizes to 1200 px high (using Equations). Select your output folder at the top, "Save Into:", then choose your folder location using the "...". (I strongly recommend you select a new output folder to avoid possibly overwriting existing files if exporting to the same file format!). Batch jobs will automatically overwrite existing files with the same filename and extension, without warning. Add this macro to the "Applied Macros" window. Click OK to run. Warning: This macro is a destructive operation, flattens and rasterizes your file after resizing. But, if you write to a new, empty file folder, your originals will NOT be altered. BTW, you don't really need to resize in the Macro with a New Batch Job, because you can specify a height, width or both from the New Batch Job window. Reize 1200H-Add 2px border.afmacro Quote 2024 MacBook Pro M4 Max, 48GB, 1TB SSD, Sequoia OS, Affinity Photo/Designer/Publisher v1 & v2, Adobe CS6 Extended, LightRoom v6, Blender, InkScape, Dell 30" Monitor, Canon PRO-100 Printer, i1 Spectrophotometer, i1Publish, Wacom Intuos 4 PTK-640 graphics tablet
BigT Posted January 20 Author Posted January 20 20 hours ago, Ldina said: @BigT Attached is a macro you can try out. It resizes your image to 1200 px high, rasterizes and flattens it, then adds a 2 pixel white border (to the inside). You can run it on an image by image basis, or as part of a New Batch Job if you want to process a bunch of files all at once. Test it out first on both a vertical and horizontal image to be sure it's working properly. Import the macro first. Window > Macros, and from the hamburger menu, Import macro. You can add it to the default category, or one of your own. To run the macro on a Batch, File > New Batch Job. Select and Add the images you want to process. Deselect AfPhoto as output format, and select JPG or whatever you want as your desired output. You can leave the size and width fields empty, since the macro automatically resizes to 1200 px high (using Equations). Select your output folder at the top, "Save Into:", then choose your folder location using the "...". (I strongly recommend you select a new output folder to avoid possibly overwriting existing files if exporting to the same file format!). Batch jobs will automatically overwrite existing files with the same filename and extension, without warning. Add this macro to the "Applied Macros" window. Click OK to run. Warning: This macro is a destructive operation, flattens and rasterizes your file after resizing. But, if you write to a new, empty file folder, your originals will NOT be altered. BTW, you don't really need to resize in the Macro with a New Batch Job, because you can specify a height, width or both from the New Batch Job window. Reize 1200H-Add 2px border.afmacro 1.04 kB · 1 download thank you, this works great but of course the macro only shows the steps (no parameters) and I can't seem to get a formula in the Equation part that I can see working like yours. Can you give me the content of the X and Y boxes that you used please? Again thanks for the warning and I know this is destructive but that's not an issue, I keep the modified base file and keep different size jpg files depending on where they will be used, so will end up with several versions of the macro. Quote
Ldina Posted January 20 Posted January 20 35 minutes ago, BigT said: Can you give me the content of the X and Y boxes that you used please? Sure. The macro is set to a fixed height of 1200 px, as requested. You can change the "1200" to any value you like to 'downsize' your image. If you 'upsize', I believe your image will be cropped to the current canvas size, at least the way this macro was written. You can also use parameters (a,b,c) in your formulas which allow you to scale. BigT 1 Quote 2024 MacBook Pro M4 Max, 48GB, 1TB SSD, Sequoia OS, Affinity Photo/Designer/Publisher v1 & v2, Adobe CS6 Extended, LightRoom v6, Blender, InkScape, Dell 30" Monitor, Canon PRO-100 Printer, i1 Spectrophotometer, i1Publish, Wacom Intuos 4 PTK-640 graphics tablet
BigT Posted January 21 Author Posted January 21 On 1/20/2025 at 5:44 PM, Ldina said: Sure. The macro is set to a fixed height of 1200 px, as requested. You can change the "1200" to any value you like to 'downsize' your image. If you 'upsize', I believe your image will be cropped to the current canvas size, at least the way this macro was written. You can also use parameters (a,b,c) in your formulas which allow you to scale. Thank you again, I typed in exactly as above and it works perfectly. However, I don't understand the maths involved (40 years in IT so always want to understand how things work). If I explain just the "Y" parameter maybe someone can shed some light on what I'm missing and I can sleep tonight . Assuming the existing layer is 2400px high (H), and its being shortened to 1200px, so both H and Y are 2400 and the formula reads 2400 (Y) divided by (1200 divided by 2400 (H)) [this is 0.5], so 2400 divided by 0.5 equals 4800, not 1200? Quote
Ldina Posted January 21 Posted January 21 1 hour ago, BigT said: I don't understand the maths involved Me neither!! The math was simple enough, however it seemed to require an "inverse" operator than what I expected. For example, for the Y value, I entered y/(1200/h), which scales the image perfectly to a height of 1200 px. However, it seemed to me that the formula should have been y*(1200/h). After trial and error, I just accepted it and used a "division" operator instead of a "multiplication" operator. I'm obviously missing the logic as to why. I assumed that "y" on the left side of the equation would define the new vertical location of each pixel (after rescaling), using the original image height and pixel locations as the source. So, if the original image height was 3600 px, and my desired image height was 1200 px, y*(1200/h) would be correct, i.e., 3600*(1200/3600) =1,200. The halfway point would be 1800*(1200/3600) = 600. For whatever reason, the 'divide' operator gave the correct result, so I used it. I was asking myself the same question. I'm sure I'm missing something simple and obvious, so hopefully someone else can enlighten us both. Quote 2024 MacBook Pro M4 Max, 48GB, 1TB SSD, Sequoia OS, Affinity Photo/Designer/Publisher v1 & v2, Adobe CS6 Extended, LightRoom v6, Blender, InkScape, Dell 30" Monitor, Canon PRO-100 Printer, i1 Spectrophotometer, i1Publish, Wacom Intuos 4 PTK-640 graphics tablet
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.