Search found 20 matches

by FUrn
2019-04-24T15:24:55-07:00
Forum: Users
Topic: Categorising Images By Background
Replies: 12
Views: 7203

Re: Categorising Images By Background

This is excellent, @snibgo, and worked like a charm! Thanks so much - you've saved me a *lot* of time :)
by FUrn
2019-04-24T13:34:38-07:00
Forum: Users
Topic: Categorising Images By Background
Replies: 12
Views: 7203

Re: Categorising Images By Background

for %%F in (*.jpg) do ( for /F "usebackq" %%L in (`magick ^ %%F ^ -fill Black +opaque White ^ -format "ISWHITE=%[fx:mean>0.7?1:0] ^ info:`) do set %%L if %ISWHITE%==1 ( copy %%F whiteBackground\%%F ) else ( copy %%F otherBackground\%%F ) ) Thanks for this, @snibgo. I'm not too familiar with ...
by FUrn
2019-04-23T16:18:18-07:00
Forum: Users
Topic: Categorising Images By Background
Replies: 12
Views: 7203

Re: Categorising Images By Background

I’m worried I won’t use the correct technical terms, but if you look at the original images I posted the 3rd image (with two chairs) would need trimming as the chairs appear considerably smaller than the chairs in the other images. Conversely, if you imagine an image with the chair going all the way ...
by FUrn
2019-04-23T16:04:57-07:00
Forum: Users
Topic: Categorising Images By Background
Replies: 12
Views: 7203

Re: Categorising Images By Background

How do decide visually which to pad and which to trim? If they have white background, there is no need to explicitly make this decision. Once each image is trimmed and then given a 12% border, the end outcome is that each chair (in these example images) takes up the Sam proportion of the canvas ...
by FUrn
2019-04-23T16:01:35-07:00
Forum: Users
Topic: Categorising Images By Background
Replies: 12
Views: 7203

Re: Categorising Images By Background

Finding the proportion of pixels that are white is easy. Turn the other pixels black ("-fill Black +opaque White"), and the mean ("-format %[fx:mean]") is the required proportion, on a scale of 0.0 to 1.0. If you want a percentage, multiply by 100 ("-format %[fx:mean*100]"). Thanks @snibgo! I’ll g ...
by FUrn
2019-04-23T15:58:13-07:00
Forum: Users
Topic: Categorising Images By Background
Replies: 12
Views: 7203

Re: Categorising Images By Background

Thanks Fred. I think a simpler method would be best for now, as I don’t want to risk distorting images wrongly and would therefore prefer a more cautious approach. The issue with taking the average colour of each edge is that this approach would work for images that need additional background, and n ...
by FUrn
2019-04-23T15:21:28-07:00
Forum: Users
Topic: Categorising Images By Background
Replies: 12
Views: 7203

Categorising Images By Background

I am looking to make a number of batch modifications to a set of product images, with the end purpose of getting them all to look somewhat aligned. The following portion of code trims each image and then re-borders it so that each fills the same proportion of the canvas: magick $filename -fuzz 10 ...
by FUrn
2019-04-03T01:46:01-07:00
Forum: Users
Topic: Adjust Canvas Size To Align Canvas Fill Proportions Across Images
Replies: 7
Views: 5457

Re: Adjust Canvas Size To Align Canvas Fill Proportions Across Images

Thanks both! Focusing on doing this for image batches, how would I amend it to only operate on images called 'Main.jpg'? I have lots of images in a number of sub-folders, but only want to trim and border those fitting a certain naming convention. I thought of putting it into a loop such as this, but ...
by FUrn
2019-04-02T13:38:53-07:00
Forum: Users
Topic: Adjust Canvas Size To Align Canvas Fill Proportions Across Images
Replies: 7
Views: 5457

Re: Adjust Canvas Size To Align Canvas Fill Proportions Across Images

I've amended your code to this: magick Original.jpg -fuzz 90% -trim +repage -background white -border 10 -bordercolor white Output/modified.jpg A couple of things though: The border colour is grey, despite my use of '-bordercolor white'. Am I doing something wrong here? More than that, the border ...
by FUrn
2019-04-01T15:45:50-07:00
Forum: Users
Topic: Adjust Canvas Size To Align Canvas Fill Proportions Across Images
Replies: 7
Views: 5457

Re: Adjust Canvas Size To Align Canvas Fill Proportions Across Images

Thanks fmw42, and thanks for pointing out the need to always mention my IM version! I'm using IM 7 on a Windows PC. Would the IM 6 Unix syntax you wrote earlier be the same or similar for my setup?
by FUrn
2019-04-01T12:18:53-07:00
Forum: Users
Topic: Adjust Canvas Size To Align Canvas Fill Proportions Across Images
Replies: 7
Views: 5457

Adjust Canvas Size To Align Canvas Fill Proportions Across Images

I have a large number of images with differing levels/amounts of white background/border, meaning the contents of each image takes up different amounts of the canvas. See for example this image: https://i.imgur.com/HLT2Obh.jpg Which fills a lot less of the canvas than this image: https://i.imgur.com ...
by FUrn
2019-04-01T08:32:35-07:00
Forum: Users
Topic: Process Images in Sub-Directories
Replies: 11
Views: 6415

Re: Process Images in Sub-Directories

Worked like a charm, snibgo.
Thanks so much!
by FUrn
2019-04-01T07:18:37-07:00
Forum: Users
Topic: Process Images in Sub-Directories
Replies: 11
Views: 6415

Re: Process Images in Sub-Directories

Sorry snibgo, but I really am a beginner at this...please do bear with me. I've tried this: for ONEDIR in $(ls -d */); do pushd $ONEDIR for filename in *.jpg; do magick "$filename" -gravity Center -background White -extent "%[fx:max(w,h)]x%[fx:max(w,h)]" "$filename" done popd done But still no luck ...
by FUrn
2019-04-01T00:33:06-07:00
Forum: Users
Topic: Process Images in Sub-Directories
Replies: 11
Views: 6415

Re: Process Images in Sub-Directories

"VAR" is a poor choice of name. Use "ONEDIR" instead. Try running "ls -d */". This writes a list of directories. Putting it inside "$(...)" runs the command, replacing it within the outer command by its output, the list of directories. "for ONEDIR in $(ls -d */) ..." is a loop that will set ONEDIR ...
by FUrn
2019-03-31T17:02:55-07:00
Forum: Users
Topic: Process Images in Sub-Directories
Replies: 11
Views: 6415

Re: Process Images in Sub-Directories

For your problem, I suggest you nest your bash commands inside an outer bash loop. That loop might be something like "for VAR in $(ls -d */)". Thanks for this. Would you be so kind as to explain the loop you’ve written out? I’d like to understand it, both to advance my knowledge but also to adapt it ...