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

Problem using a macro to scale a photo


Recommended Posts

Hi everybody, I have a problem with AP where I can't do what I used to to with Photoshop. Let me explain:

I have a picture 3000 x 3000px at 72 dpi. I want to scale it to 2360 x 2360 px at 300dpi. If I do it with a single photo,  it's ok, no problem.

The problem is when I use a macro to scale multiple photos with different dimension. For example, a photo with 4000 x 2250px at 72 dpi I want that it will change to 2360x1327.

If I record a macro with the first photo, than it will change the second photo to 2360x2360 twisting the photo.

In Photoshop there was an option "Maintain proportion" and with a recorded action I could record the first one with 2360 (H) x 2360 (W) and then, using that action, changing the second photo to 2360 (H) x 1327 (W). It maintained the height dimension.

This gave me the chance to have different actions such as "H 10 cm", "H 20 cm" and so on. I could use those actions with photos with different dimensions and I could transform them in photos with H10cm or 20cm and so on. With AP is impossible,

How can I do the same with AP?

 

Thank you!

Link to comment
Share on other sites

The current implementation of macros will bake in the parameters of a resize operation. I have found that the only way to do what you want is to use Equations. I have written a set of macros to do that here.

If you want to change the dpi, I also have a set of macros for that here. You should apply this macro before the resize one.

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

Thank you for your macros, they are useful to change the dimensions without changing the dpi.

The problem is after (or before) that: when I go to change the dpi using a macro (i.e. "300 dpi"), even the dimensions change. And that's because there is no "fit image" command.

I also tried to figure out what you meant in "Distortion > Equation" but I don't know how to do it with macro with one picture. Batch is not an option, because Batch is for multiple pictures that I already know I want to resize with 2000 dpi, but I know it only once I open each single image.

Any help?

Link to comment
Share on other sites

When you resize a document, there are two options - 1) scaling and 2) resampling.  It is important to understand the distinction.  The "DPI" value is simply a metadata tag that is used in situations where the image will take on actual physical dimensions, like printing.  When performing scaling, you alter this tag to be whatever you want (300 DPI, 72 DPI, whatever) WITHOUT CHANGING THE PIXEL DIMENSIONS OF THE IMAGE.  In contrast, resampling actually will change the pixel dimensions of the image to accommodate the new pixel dimensions that you enter into the W and H fields in the Resize dialog.  You can perform both scaling and resampling simultaneously, and AP will increase or reduce the required number of pixels accordingly by creating (upsampling) or combining (downsampling) pixels to achieve the final pixel dimensions at the specified DPI.

In PS, if you want to record an action that will change the dimensions of any image you feed it by a specified percentage, you can do this by changing the units in the Preferences to Percent prior to recording the action.  Then, every time you run the action, the image you feed it will be reduced by the given percentage with the aspect ratio of the image maintained.  This is what AP appears to be lacking because it appears that AP records the absolute pixel values of the W and H fields when recording the macro instead of the relative expression that generated those values.  That is, it appears that AP permits the user to enter expressions into the W and H boxes in the Resize Document dialog (like "50%" or "<original_dimension>*0.5") but does not record these relative measures (the expression itself) in the macro - it appears to record the resulting value, not the expression that generated that value.  

Maybe I am missing something, but it appears to me that this is how AP currently works.

Kirk

 

Link to comment
Share on other sites

Hi Kirk, and thank you for your reply.

My problem is exactly that I work in the printing environment and in a page for a magazine I could have final photos with 10cm (or 15, 20 and so on) and 300dpi, no matter what is the original size of the images. 

So, if I have two images (for example, one 1500x1500 and one 1500x843, both at 72dpi) with PS I can record an Action that easily resize them: 2362x2362 and 2362x1574 at 300dpi. With AP this is possible only if I do it for each photos. Not with a macro.

In PS, I just record once multiple actions with different size (same dpi) such as "10 cm" or "20 cm" (I use to work with cm) and then, every time I open a photo I just click on the preferred action. In AP this is not possible. Or maybe yes, but I don't know how. 

For example, using the macros that John kindly let us to download (and I thank him for that) I can modify the size using a macro, but I can't modify the resolution, so, if the original dpi was 72 I can't modify it to 300 dpi using a macro because it change the photo using the same size of the photo used to create the macro. That's why his macros are usefull but only for the 50% of my work.

Dan

Link to comment
Share on other sites

You can stack the Macros in the Batch Job dialog - for example, if you want to convert a set of images of different long edges to a max long edge of 1280px and set the resolution to 300 DPI and save as JPEG, you can set up a Batch Job where you add the files you want to resize, set the destination folder and then apply the two actions from John's set.  This way you can plug in any combination of macros to get the final size and resolution you want.

There's nothing stopping you from applying this to an individual image also, from the macro Library.

See screenshot.

Kirk

dialog.jpg

Link to comment
Share on other sites

This is the problem. I get a photo of 3000x3000 (72dpi) and I record the macro "Change DPI to 300" changing just the dpi in 300. Then I stop the macro, save it and ok.

Afterwards, I open a new photo of 2400x1475 (72dpi) and I use that macro. So, I'd expect to have a transformation of the picture in 2400x1475 with 300 dpi, ok? No, I don't. I have a new picture with 300 dpi at 3000x3000.

This is the problem. How can I record a macro where I set up only the height (3000) and every time I use that macro I'll have photos with 3000 as height and different width (the proportion of the original photo).

Look at this screenshot. How can I create a macro that will change the height as I want changing the width in proportion without ruining the photo?

Once I have this macro, I can surely use batch.

Schermata 2020-10-01 alle 19.32.05.jpg

Link to comment
Share on other sites

I'm sorry, I just found the "Change DPI" macro created by John, I downloaded it and it works. That's exactly what I need.

And ok, now I can use a batch.

Thank you John and Kirk, this was a big problem for me (the other was a "macro with export" but I know this is not possible yet) and now I'm fin.

Really really thank you to both of you!

Link to comment
Share on other sites

The macros that John provided to change pixel dimensions employ the Equations filter cleverly, combined with selecting the empty space in the resulting image canvas and clipping it away.  It is a kludge, but the Equations filter permits the macro to record the actual equation, not the resulting value.  Well done!

Glad you got it all working.

Kirk

Link to comment
Share on other sites

18 hours ago, NY32 said:

The problem is after (or before) that: when I go to change the dpi using a macro (i.e. "300 dpi"), even the dimensions change. And that's because there is no "fit image" command.

These macros are supposed to change the dpi without changing the pixel dimensions. Is this not what happens? If you can confirm this, then I can re-record them. 

Which version of Affinity are you using? It may make a difference.

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

No John, it was my fault. I haven't noticed I had downloaded 2 macros, so I hadn't upload into AP the "Change DPI" macro. Once I did it, now everything works.

I only have a further question, is it possible to have a macro of more than 2000 px? When I change it in centimeters they are around 16 cm, but I need 20 cm or a bit more (2500 px). 

Anyway, if it's too problematic, don't worry, you've already been so kind to record this macros and I really thank you for them!

Dan

 

PS: APhoto 1.8.4 Mac desktop

Link to comment
Share on other sites

The macros using Equations can be written for any target size, but they will not work for pixel dimensions larger than the canvas size. There are workarounds, but they are not elegant.

The macro has the form:

Layer > Unlock
Layer > Rasterize and Trim

Filter > Distort > Equations Enter the following in the x and y fields, substituting your own maximum size, then Apply
   (x/MAXSIZE)*max(h,w)
   (y/
MAXSIZE)*max(h,w)
Document > Clip Canvas
Layer > Rasterize

Select > Alpha Range > Select Partially Transparent
Edit > Fill> Inpainting
Select > Deselect

Just replace MAXSIZE with your target maximum dimension.

You may find that you do not actually need the resize macros. Set up your batch file using the change dpi macro, then enter your target maximum in both the W and H boxes, and ensure the Aspect Ration (A) box is ticked.

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

3 hours ago, John Rostron said:

... and ensure the Aspect Ration (A) box is ticked.

It took me longer than it should to understand that here that box refers to aspect ratio & not to alpha.

All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo 
1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

On 10/2/2020 at 1:01 PM, R C-R said:

It took me longer than it should to understand that here that box refers to aspect ratio & not to alpha.

It took me quite a long time to discover what Alpha was!

John

Edited by John Rostron

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.