Jump to content

Recommended Posts

Posted

Crop to selection can be done in a macro but I don't understand this...

5 hours ago, JosseF said:

It would allow to automate (batch) cropping based on a background color.

Can you be more specific about what you want to do?

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.

  • 3 weeks later...
Posted

This is for automated cropping of reproduction photography.
E.g. a drawing is shot against a black background.
In Photoshop I set a selection of black, invert the selection, enlarge it by 20 pixels (to leave a margin around the drawing) and then do a crop to selection.
As far as I can tell I can't do that or something similar in Affinity Photo.

Posted

You can copy your selection and then select File > New from Clipboard.

John

Windows 11, Affinity Photo 2.4.2 Designer 2.4.2 and Publisher 2.4.2 (mainly Photo).

CPU: Intel Core i5 8500 @ 3.00GHz. RAM: 32.0GB  DDR4 @ 1063MHz, Graphics: 2047MB NVIDIA GeForce GTX 1050

Posted

1. Use the Flood Select Tool to select the background
2. Press the Delete key to delete it
3. Use Select > Invert Pixel Selection to invert the selection
4. Use Select > Grow / Shrink  to enlarge the selection by 20px
5. Use Document > Clip Canvas to "crop to selection"

Steps 2-5 can be made into a macro, Step 1 may also be possible in a macro it just depends on how "complex" or contiguous the background is.

If Step 1 is also recordable in a macro you can then use File > New batch Job to automate the process across several images

If the above is unclear or does not work for you we would need some samples of the images you work with in order to give more insightful information

  

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.

Posted

Thank you for your assistance. It is getting close to what I want to do, but not quite.

In step 2 the background is deleted. That is not allowed in cultural heritage photography as it may remove a few pixels from the object being reproduced.

That is why I have to leave a 20 pixel margin around the object.

I tried leaving out that step, but then the Document > Clip Canvas doesn't work anymore.

I also tried a variation where I first inverted the selection, enlarged it by 20 pixels, inverted it again, deleted the background and finally inverted it once more.

Now Document > Clip Canvas works, but (unless the object is perfectly rectangular and perfectly parallel to the image) I am left with an irregular edge on the outside of the selection.

Posted

Try this macro for the first three steps Add 20 pix.afmacro  

Select the background

Invert the selection

Grow the selection

   Now you have to

   Copy (Command + C)

   Make a new document from the clipboard. File > New From Clipboard (Command + Option + Shift + N)

You should have 20 pixels of black background around the picture.

Mac Pro (Late 2013) Mac OS 12.7.6 
Affinity Designer 2.5.7 | Affinity Photo 2.5.7 | Affinity Publisher 2.5.7 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Posted

Thanks for the suggestion, but still not the solution.

I made a couple of example images, no. 1 is an irregular shaped object against a dark background:

1-photo.png.623960a72b625d7e4e7f8b24781c474b.png

 

No. 2 is how I would like to have it cropped:

2-intended_result.png.ea901354606d146b3e98636efbc5bc48.png

 

No. 3 is the result of using carl123's suggestion:

3-result_carl123.png.68fd42e1150eb5ec986bd9d2226569e2.png

 

No 4. is the result of using Old Bruce's suggestion:

4-result_Old_Bruce.png.1bfa1d4879328076e18b8eb55e35b5a5.png

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.