Page 2 of 2

Re: Add image file processor (resize image files)

Posted: Wed Aug 17, 2022 5:45 am
by Mister Anderson
OK, I've got it working well enough now that I'm happy enough to deploy it. I've worked out how to attach it as a file this time (no idea how I didn't see that before...
Compress image files_copy.json
(13.6 KiB) Downloaded 95 times
So, I've gone with what steinar has suggested and added a Stills decoder and a Resize node (again, how did I not find that before) and that's done the trick.

I've now got a workflow that:
  • Watches the folder C:\image resizer
  • Picks up files only in subfolders named like a resolution through regex matching (e.g. C:\image resizer\1920x1080)
  • Sets the new image width and height to fit within that resolution while respecting the original aspect ratio (uses regex to get the two resolutions from the folder name)
  • Resizes the image and outputs it to C:\image resizer\output in .png format for .png originals, and .jpg format for all other image files
  • Deletes the originals
I seem to be getting errors on random .png files (rarely) and .heic files, so I excluded .heic files for now.


I wouldn't say no to a new "image resize" node or an update to work with .heic files, but this is now deployed and working well enough. Thanks for your help.

Re: Add image file processor (resize image files)

Posted: Mon Aug 22, 2022 3:22 am
by Mister Anderson
Oh, I just wanted to ask, is there any easy way to detect if an image has transparency or not? It would be nice to have logic to decide to convert to png or jpg.

Re: Add image file processor (resize image files)

Posted: Mon Aug 29, 2022 6:59 am
by emcodem
Hey ho!
for heic support, you might get lucky with the proposed commandline workflow i posted before that uses imagemagick instead of ffmpeg.
For detecting transparency for your usecase, it might help if you just use a conditional processor to check if "rgba" is in s_ffprobe.

Re: Add image file processor (resize image files)

Posted: Mon Aug 29, 2022 10:24 am
by admin
Hi Mr. Anderson,

The easiest way is to add a conditional that checks if:
%s_pixel_format% = *a*

It basically detects the letter "a" in the pixel format. If there's an "a" in it the media has transparency layer.

You could also be more specific by testing *yuva* or *rgba* instead of just *a*.

-steinar