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

Affinity Photo: Macros and Batch Jobs - Resize to Percent


Recommended Posts

Hello,

I'm trying to resize a bunch of images to 50% size (so no absolute values, every image has to be 50% of its original size), but it seems like neither the Batch Job dialog, nor the Macro recorder can deal with this.

The Batch Job dialog completely disregards percentages, and the Macro recorder just stores the final resolution _after_ multiplying by percent.

Have I missed anything or is this just not possible in Photo?

 

Thanks,
Attila

Link to comment
Share on other sites

You can macro your doc-settings. Just type "/2" behind W or H (Take care that the Keep-relation-symbol is on).

Save that macro and run it as batch.

 

EDIT: NOPE, that saves ABSOLUT values. 

You can instead macro that stunt via the the transform panel "/2" behind H and W. That is RELATIVE/perrcentage. But than you have to crop the empty space and cropping will also macro as "absolut"value, not relative. Hm, i do not really know.

OSX 12.5  / iMac Retina 27" / Radeon Pro 580X / Metall: on! --- WWG1WGA WW!

Link to comment
Share on other sites

Thanks, yeah, that that's what I came up with too :/

In the end I solved it with ImageMagick in a shell script:

find . -type f -exec file {} \; | awk -F: '{if ($2 ~/image/) { cmd="mogrify -resize 50% " $1; print(cmd); system(cmd) }}'

 

Link to comment
Share on other sites

You can do it in a macro if you use Filter > Distort > Equations. Off the top of my head you just need the two lines:

X=x/2

Y=y/2

John

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

I have only resized flat files using this macro technique, and it does work. You might have to add a Clip Canvas after the resizing (as part of the macro). I do not know what would happen with a layered file. Why not try it and see?

Can I re-iterate that using Equations in a macro does not enforce absolute dimensions (unlike Document > Resize or Transform). Indeed, this is the only known way to apply resizing within a macro.

John

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

52 minutes ago, John Rostron said:

 You might have to add a Clip Canvas after the resizing (as part of the macro).

Thats the point i struggle. What exactly is clip canvas (not the same as crop????)? And does it work percentage or just absloute? How to find?

OSX 12.5  / iMac Retina 27" / Radeon Pro 580X / Metall: on! --- WWG1WGA WW!

Link to comment
Share on other sites

1 hour ago, Polygonius said:

Thats the point i struggle. What exactly is clip canvas (not the same as crop????)? And does it work percentage or just absloute? How to find?

Suppose you have an image, and for simplicity assume it just has the background layer. Now suppose you were to unlock that layer (allowing it to be transformed), select the Move tool, open the Transform studio, and change the width to 1/2 of whatever it currently is (with the aspect ratio locked).

You should see that you now have a canvas where the transformed image is in the upper left quadrant (roughly), and 3/4 of the canvas is transparent (if you have that option enabled) or white.

Now try Document > Clip Canvas. You should now have your transformed image occupying the whole canvas, which has shrunk to the size needed to contain the image pixels.

So, in a way, when you use it after a transform operation that shrinks the image, it performs a kind of crop, but only of the parts of the canvas that don't contain part of the image. However, when you use it at other times, it can seem to do other things. E.g., if you perform an actual crop, and then use Clip Canvas you undo the crop.

In either case, it is (I think) basically making the canvas just small enough to hold all the non-transparent image pixels. That means shrinking the canvas if you've transformed the image smaller, or enlarging the canvas if you've done a crop but not yet rasterized the image to "finalize" the crop and make it destructive.

-- 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

The Filters-Distort-Equations route suggested by @John Rostron works for me with one significant modification. Somewhat counter-intuitively, the equations are as follows:

208202029_Screenshot2018-08-29at11_22_27.thumb.png.150a736aedd31ef50455d4eae8cac6ab.png

 

x=x*2

y=y*2

(Dividing the dimensions by 2 halves the depth and height of the image visible in the document window, giving a quarter of the original image.)

Your macro would then need to clip the canvas. 

I've attached a .afmacro file which shrinks images to 50%. It can be incorporated into a batch process if needed.

Make backups before using, and use at your own risk.

 

Half size.afmacro

Affinity Photo 2.0.3,  Affinity Designer 2.0.3, Affinity Publisher 2.0.3, Mac OSX 13, 2018 MacBook Pro 15" Intel.

Link to comment
Share on other sites

8 minutes ago, h_d said:

The Filters-Distort-Equations route suggested by @John Rostron works for me with one significant modification. Somewhat counter-intuitively, the equations are as follows:

x=x*2

y=y*2

(Dividing the dimensions by 2 halves the depth and height of the image visible in the document window, giving a quarter of the original image.)

Your macro would then need to clip the canvas. 

I've attached a .afmacro file which shrinks images to 50%. It can be incorporated into a batch process if needed.

Make backups before using, and use at your own risk.

@h_d, you are quite right. I was writing that message on my tablet, without access to AP on my desktop. I have been confused by that paradox before. One of the mods did explain it to me. As I recall, the expression x=x*2 is interpreted as meaning: for the new pixel at position x, look at the pixel in current position 2*x. It does make writing such equations something of a black art.

John

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

For extra points, the attached macro exposes the a parameter of the equations

  • x=x*(1/a)

and

  • y=y*(1/a)

and then clips the canvas, to give a sliding image scaler:

Original:

1811637098_Screenshot2018-08-29at13_47_35.png.412e9b648e922103bf72dc4559f79aab.png

Scaled to 0.25 (25%)

1397307750_Screenshot2018-08-29at13_48_14.png.e4966e5b17ee2dd60eabb7ca6c02513c.png

 

Hope this helps someone!

 

 

 

 

Image Scaler.afmacro

Affinity Photo 2.0.3,  Affinity Designer 2.0.3, Affinity Publisher 2.0.3, Mac OSX 13, 2018 MacBook Pro 15" Intel.

Link to comment
Share on other sites

4 minutes ago, h_d said:
  • x=x*(1/a)

and

  • y=y*(1/a)

As a matter of interest, why not just write:

x=x/a

and 

y=y/a

John

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

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.