Jump to content
Máté

How do I create a macro to rotate images by 45 degrees?

Recommended Posts

This is driving me nuts. I have a few hundred images that I need rotated by -5 degrees and the behavior of the Move Tool/Transform Studio is inconsistent. Almost all images get distorted when I run the macro.I'm actually surprised I managed to set it up in a way to work consistently WITH THE SAME file I recorded it with.

Why does the Transform step have to include anything else apart from how many degrees to turn an image (and anchor point used, I don't think it can actually remember the anchor point chosen)? How I can create a universal rotate by 45 degrees macro that work for all image sizes?

I've included the macro and two sample images.

Thanks for any help!

rotate.afmacro

macro doesn't work.png

macro works.jpg

Share this post


Link to post
Share on other sites

Hi @Máté,

Welcome to the forums. 

It looks like the macro only works if your images are the exact size. Otherwise, they will be distorted. I've logged this as a bug. 

moved to bugs. 

Thanks,

Gabe. 

Share this post


Link to post
Share on other sites

Thanks @carl123

It worked perfectly for all the pics I needed to rotate. Took my CPU to its knees as well :4_joy: but it was worth the few minutes.

How did you do it? If you have the time I'm sure the info would be useful to others as well.

@GabrielM thanks! Hope it'll be fixed soon. I'm surprised nobody had a problem like this before. I did a search in the forums but came up with nothing and I thought maybe I just don't know how the software works.

edit: Okay here's another thing. You can't resize images by only one dimension. For example, you define the height to be 1800px and leave the width untouched to let the program calculate to correct width based on the 1800px input to keep the correct aspect ratio. What it does however is to apply a width adjustment as well.

Here are again two examples:

I created the macro using the Cross ink bottle image and when I apply it to other Cross ink images it works, but if I try a different brand it changes the aspect ratio of the product image. I assume because the original dimensions are different. So basically macros are either broken or I can't use them properly in Affinity.

ink.afmacro

cross ink.png

waterman.png

Edited by Máté
here's something new

Share this post


Link to post
Share on other sites
On 06 July 2018 at 6:03 PM, Máté said:

It worked perfectly for all the pics I needed to rotate. Took my CPU to its knees as well :4_joy: but it was worth the few minutes.

How did you do it? If you have the time I'm sure the info would be useful to others as well.

Hi Máté

The macro is broken down as follows

1. Unlock (unlock layer - probably not needed but just in case it is)
2. Resize Canvas ( Resized to a large value of 10,000px X 10,000px to give working space to rotate the images, the maximum sizes of which were unknown)
3. Equations (see below)
4. Clip Canvas (Resize canvas from 10,000px X 10,000 to just that required to encompass the rotated image)
5. Rasterise (Probably not needed but just tidying up)

 

Equations:

Filter > Distort > Equations

Uses the Polar coordinate "t" value to specify the angle of the rotation

In my macro I used 0.75, which was a quick guess to give a 45 degree rotation as I did not have the time to find the correct value

I now know the correct value for a 45 degree rotation is Pi/4 or 0.78539816339744830961566084581988

Fortunately the Equation filter allows you to enter Pi as a mathematical constant, so no need to calculate the value first (as shown below).

 

equations.png

Share this post


Link to post
Share on other sites
On 06 July 2018 at 6:03 PM, Máté said:

edit: Okay here's another thing. You can't resize images by only one dimension. For example, you define the height to be 1800px and leave the width untouched to let the program calculate to correct width based on the 1800px input to keep the correct aspect ratio. What it does however is to apply a width adjustment as well.

It can be done via macros using Equations (search the forum for examples)

but File > New Batch Job will also do the job, just specify the Height as 1800 and leave the width field empty

Share this post


Link to post
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.


×
×
  • Create New...

Important Information

Please note the Annual Company Closure section in the Terms of Use. These are the Terms of Use you will be asked to agree to if you join the forum. | 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.