Jump to content
You must now use your email address to sign in [click for more info] ×

Macro to dynamically resize an image's height from 1000px to 100px in 100px increments using the Equations Filter


carl123

Recommended Posts

Attached is a resizing macro with a slider that allows you to dynamically resize your image's height  from 1000px to 100px in 100px increments

The slider values goes from 0 to 1.0

Where...

1.0 = 1000px for the height
0.8 = 800px for the height
0.7 = 700px for the height
0.2 = 200px for the height
etc
etc

You can use the CTRL + Arrow keys in the Slider adjustment box to quickly change increments in 0.1 (100px) values

But for those of you that prefer using the slider to change the value, the macro has been written so that any values after the first decimal place are effectively ignored.
So you do not have to move the slider to precisely 0.600 to get a 600px high image.  Any value from 0.600 to 0.699 will always result in an image size of 600px

Likewise moving the slider to any value from 0.300 to 0.399  will always result in an image size of 300px, etc, etc, etc

Once you have resized the image you would need to perform a Document > Clip Canvas command to get rid of the transparent pixels now surrounding the image

Note: The macro has a clip canvas command at the end of it which I have disabled in this demo so you can see the macro working in "real time" but it can be reenabled by editing then resaving the macro if you prefer the macro to do this step for you automagically

The Equations formula used in the macro is

x*h/clampmax((rounddown(a*10)*100),h)
y*h/clampmax((rounddown(a*10)*100),h)

This macro has been tested but not exhaustively, it is here as a demo for others to use or adapt as required.  The main purpose in writing it was to find a way for the slider to ignore any decimal points values after the first one, which was (eventually) achieved using the "rounddown" command.

Note: There is either a bug or misinformation regarding the use of the "rounddown" command which I will file a separate bug report for and link to from this post at a later time

 

Selectively resize image height from 1000px to 100px.afmacro

 

EDIT: The link to the bug report can now be found here

 

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.

Link to comment
Share on other sites

No you cant control the sampling method used and I have no idea what the default is

But bear in mind we are only having to use the Equations Filter for stuff like this because the macros, currently, cant deal with documents of different sizes when resizing them.  Once they have fixed that we will no longer need to use Equations.

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.

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

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.