Add image file processor (resize image files)

Use this forum to request features. Maybe you'll get lucky!
Mister Anderson
Posts: 6
Joined: Tue Aug 02, 2022 12:52 pm

Re: Add image file processor (resize image files)

Post 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 402 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.
Mister Anderson
Posts: 6
Joined: Tue Aug 02, 2022 12:52 pm

Re: Add image file processor (resize image files)

Post 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.
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Add image file processor (resize image files)

Post 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.
emcodem, wrapping since 2009 you got the rhyme?
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: Add image file processor (resize image files)

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