John Rostron Posted May 19, 2020 Share Posted May 19, 2020 (edited) Some time ago I produced a macro to Wrap an Image around a Bottle or Mug. This involved some complex trigonometrical operations on the image. I present here an alternative approach for a macro to perform the same action. Here is my original image: o It is easily possible to produce an equation that contracts the image width-wise to emulate the reduction in perceived width as the image is wrapped. Such an equation has the form: x=w/2+(w/2-x)*pi/2 and has the result of: The contraction is uniform across the reduced width. The expression pi/2 is the appropriate scaling for a bottle diameter that accepts the image around its half-circumference. What I was aiming for was a function that would scale the edges so that they appeared contracted, whilst applying zero scaling to the centre of the image. After much trial and error, I came up with this: x=w/2-(w/2-x)*(1+1.571*(1-sqrt(1-(1-2*x/w)^2))) Edit: Note that this has a minus sign after the first w/2. The original had a plus sign. The value 1.571 is just half pi. The resulting image is: This is a single result. I have further refined by including a scaling parameter, a, which accentuates the compression at the edges. w/2+(w/2-x)*(1+(1.571/a)*(1-sqrt(1-(1-2*x/w)^2))) Here it is with the a parameter around half. Note that in these images, the central squares remain square. Edit: Like my previous version it has a parameter (in this case b) which affects the viewpoint, above or below. If you want to use this then you need to enlarge the canvas vertically beforehand to give room for the curvature. You may wish to use Document > Clip Canvas at the end in this case. Edit: various members had pointed out that the final image was flipped horizontally. This has now been fixed. I have also added Layer > Unlock and Layer > Rasterize at the start of the macro. I have not added a clip canvas at the end. Do you think that this is desirable? Here is the macro: WrapAroundV2.afmacro John Edited May 20, 2020 by John Rostron Update Blende21, Callum and Paul Mudditt 1 2 Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
catlover Posted May 19, 2020 Share Posted May 19, 2020 John, I've played your macro - brilliant. Resetting now goes without a hitch. However, besides wrapping, it also flips the picture horizontally. It makes no difference whether I copy & paste the function directly, or play the macro, change the extend mode to randomly. It always flips the picture. You would not have been able to notice this happening, when creating & testing the macro because of the checkerboard example. This will remain a checkerboard whatever the macro will perform and flipping (no pun intended !) would not be noticed. Here's a screenrecording to show what I mean. (Just one extend mode used, no changes made to parameters). In the meantime, thanks again for your effort. Best, C.L. wrap.mov John Rostron 1 Quote Link to comment Share on other sites More sharing options...
T V Posted May 19, 2020 Share Posted May 19, 2020 1 hour ago, catlover said: John, I've played your macro - brilliant. Resetting now goes without a hitch. However, besides wrapping, it also flips the picture horizontally. It makes no difference whether I copy & paste the function directly, or play the macro, change the extend mode to randomly. It always flips the picture. You would not have been able to notice this happening, when creating & testing the macro because of the checkerboard example. This will remain a checkerboard whatever the macro will perform and flipping (no pun intended !) would not be noticed. Here's a screenrecording to show what I mean. (Just one extend mode used, no changes made to parameters). In the meantime, thanks again for your effort. Best, C.L. wrap.mov catlover, ran into same problem on vertical oriented photos. Horiz no problems...John fixed this problem in last macro with rasterize. I have tested this and it works no problem, just rasterize and it should work for you too! PS. John, while it is good form to add unlock as a macro step, rasterize seems to unlock the images without that step. So far, I have only run into this issue with distortion related commands on Vertical oriented images. Keep up the good work! - T V Update...this is flipping the image horizontally for me. Without rasterize, it flips horizontally and vertically. John Rostron 1 Quote Link to comment Share on other sites More sharing options...
catlover Posted May 19, 2020 Share Posted May 19, 2020 The images were rasterized in my example, so what else could cause this to happen ? Quote Link to comment Share on other sites More sharing options...
T V Posted May 19, 2020 Share Posted May 19, 2020 The equation is interesting to play with...and manipulating it does some fun mirroring and warping. I am missing the y calculation with second parameter...flip document? Quote Link to comment Share on other sites More sharing options...
Cecil Posted May 19, 2020 Share Posted May 19, 2020 When I try to import the Macro in Library from Desktop, the file is grayed out. If I drag and drop into open Photo document I get "This file is not Affinity document." What am I'm doing wrong, please. Thank you. Quote Cecil iMac Retina 5K, 27”, 2019. 3.6 GHz Intel Core 9, 40 GB Memory DDR4, Radeon Pro 580X 8 GB, macOS,iPad Pro iPadOS Continuous improvement is better than delayed perfection Link to comment Share on other sites More sharing options...
catlover Posted May 19, 2020 Share Posted May 19, 2020 The macro cannot be imported into the Library, you have to load it via View>Studio>Macro>import ( the little square with the down-arrow.). John Rostron 1 Quote Link to comment Share on other sites More sharing options...
Cecil Posted May 19, 2020 Share Posted May 19, 2020 11 minutes ago, catlover said: The macro cannot be imported into the Library, you have to load it via View>Studio>Macro>import ( the little square with the down-arrow.). The first time I did that for some reason Import would not open, however it did work this go around and I saved to the Library. Thank you. Quote Cecil iMac Retina 5K, 27”, 2019. 3.6 GHz Intel Core 9, 40 GB Memory DDR4, Radeon Pro 580X 8 GB, macOS,iPad Pro iPadOS Continuous improvement is better than delayed perfection Link to comment Share on other sites More sharing options...
John Rostron Posted May 19, 2020 Author Share Posted May 19, 2020 @catlover, @T V, @Cecil, Thanks to all for your feedback. I was unaware of the flipping problem. I usually start off my macros with unlock and rasterise, but I did not in this case. I will amend the macro and re-post. I will also edit the original posting. Like my previous version it has a parameter (in this case b) which affects the viewpoint, above or below. If you want to use this then you need to enlarge the canvas vertically beforehand to give room for the curvature. John Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
T V Posted May 19, 2020 Share Posted May 19, 2020 John, here is something to consider...including your macro(renamed 'equation'). Run either...hope this helps, feel free to rewrite...I have done this to all of them and I get a better feel for what you are doing. Really great stuff - T V curvewarpmacros.afmacros *one further macro option is to merge visible to start...that way you unlock and select that new layer from a position of having a layer selected or not when you run the macro. Quote Link to comment Share on other sites More sharing options...
John Rostron Posted May 20, 2020 Author Share Posted May 20, 2020 I have amended the macro to take onboard the comments from @catlover, @T V, and @Cecil, I have given the amendments in some edits in the original posting. Here is an example of the revised macro. It is of a stained glass window in St Oswald's church, Oswestry, Shropshire. Before: and after (with Crop Canvas): John Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
Cecil Posted May 20, 2020 Share Posted May 20, 2020 @John Rostron very nice. Is this just modifying the original download or will you post updated macro? Thank you, your work is outstanding. Quote Cecil iMac Retina 5K, 27”, 2019. 3.6 GHz Intel Core 9, 40 GB Memory DDR4, Radeon Pro 580X 8 GB, macOS,iPad Pro iPadOS Continuous improvement is better than delayed perfection Link to comment Share on other sites More sharing options...
John Rostron Posted May 20, 2020 Author Share Posted May 20, 2020 Just now, Cecil said: will you post updated macro? The original posting now has a link to the updated macro. I shall provide a couple of extra macros as follows: One to Merge visible first (as @T V has suggested). One with this plus a Document > Clip Canvas at the end. I feel that there are circumstances where the plain macro without these addition would be appropriate. John Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
catlover Posted May 20, 2020 Share Posted May 20, 2020 Thanks, John. Going to have a go ASAP and let you know my findings. The original macro : is that this one (below) ? I just downloaded this one : WrapAround1.8.afmacro 976 B · 12 downloads John Rostron 1 Quote Link to comment Share on other sites More sharing options...
Cecil Posted May 20, 2020 Share Posted May 20, 2020 50 minutes ago, catlover said: Thanks, John. Going to have a go ASAP and let you know my findings. The original macro : is that this one (below) ? I just downloaded this one : WrapAround1.8.afmacro 976 B · 12 downloads It’s V2, located at end of first post. John Rostron 1 Quote Cecil iMac Retina 5K, 27”, 2019. 3.6 GHz Intel Core 9, 40 GB Memory DDR4, Radeon Pro 580X 8 GB, macOS,iPad Pro iPadOS Continuous improvement is better than delayed perfection Link to comment Share on other sites More sharing options...
catlover Posted May 20, 2020 Share Posted May 20, 2020 Thanks, Cecil. Found it. Quote Link to comment Share on other sites More sharing options...
T V Posted May 20, 2020 Share Posted May 20, 2020 John, looks good. Personally, I prefer to see the edges. Clipping the canvas would be good for saving file size. Are you starting a 'Heavenly Brew'? Cheers - T V John Rostron 1 Quote Link to comment Share on other sites More sharing options...
T V Posted May 22, 2020 Share Posted May 22, 2020 Clipping Macros I haven't been making macros everyday lately, so, I thought I would try some new things to get confidence with these equation anomalies...tested on horiz & vert format images and working great. - notes : larger canvas - 10,000 px x 10,000 px , clip canvas crops to image size leaving curved edges exposed , controls modified in equation... 👽 - T V S-curve CLIP.afmacros larger canvas - rasterize - S-curve equation - clip canvas larger canvas - rasterize - S-curve Radial equation - clip canvas Curve-warp CLIP.afmacros larger canvas - rasterize - Curve-warp equation - clip canvas rasterize - Horizontal Curvature Shift equation - clip canvas John Rostron 1 Quote Link to comment Share on other sites More sharing options...
John Rostron Posted May 24, 2020 Author Share Posted May 24, 2020 On 5/20/2020 at 10:25 AM, John Rostron said: I shall provide a couple of extra macros as follows: One to Merge visible first (as @T V has suggested). One with this plus a Document > Clip Canvas at the end. I have decided against providing these additional macros. Adding Merge Visible at the beginning creates a suitable target layer on top of the stack, but the original layers are still visible below, which somewhat defeats the purpose. Adding Clip Canvas at the end of the macro does not work. It does indeed clip the canvas, but it does so before I have a chance to adjust the parameters. I will explore this further and make a bug report if I feel that it needs it. John T V 1 Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
T V Posted May 24, 2020 Share Posted May 24, 2020 5 hours ago, John Rostron said: I have decided against providing these additional macros. Adding Merge Visible at the beginning creates a suitable target layer on top of the stack, but the original layers are still visible below, which somewhat defeats the purpose. Adding Clip Canvas at the end of the macro does not work. It does indeed clip the canvas, but it does so before I have a chance to adjust the parameters. I will explore this further and make a bug report if I feel that it needs it. John John, Dido on the Merge Visible. Clip Canvas worked like a live layer for me, but, I do have to wait for the processing to catch up between changing settings as it is not instant. Creating a larger canvas also seems to add to the bog at the beginning. This is why I kept it lean and avoided the Merge. It is completely possible to turn off visibility of layers in macros, but, how many and which ones... - T V John Rostron 1 Quote Link to comment Share on other sites More sharing options...
marksep Posted September 19, 2023 Share Posted September 19, 2023 On 5/24/2020 at 11:43 AM, T V said: John, Dido on the Merge Visible. Clip Canvas worked like a live layer for me, but, I do have to wait for the processing to catch up between changing settings as it is not instant. Creating a larger canvas also seems to add to the bog at the beginning. This is why I kept it lean and avoided the Merge. It is completely possible to turn off visibility of layers in macros, but, how many and which ones... - T V Hi, but this macro can't be import into AF 2? regards Mark Quote Link to comment Share on other sites More sharing options...
walt.farrell Posted September 19, 2023 Share Posted September 19, 2023 12 minutes ago, marksep said: but this macro can't be import into AF 2? There are several file attachments in this topic. The very first one is a .afmacro file which you would import into the Macro panel. The others are .afmacros files which you would import into the Library panel. All successfully import into V2 for me. If that doesn't help, please tell us which file (by name) you're referring to, and how you're trying to import it. marksep 1 Quote -- 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 More sharing options...
marksep Posted September 19, 2023 Share Posted September 19, 2023 21 minutes ago, walt.farrell said: There are several file attachments in this topic. The very first one is a .afmacro file which you would import into the Macro panel. The others are .afmacros files which you would import into the Library panel. All successfully import into V2 for me. If that doesn't help, please tell us which file (by name) you're referring to, and how you're trying to import it. jep, ur right 🙂 Thanks walt.farrell 1 Quote Link to comment Share on other sites More sharing options...
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.