Canvas: resize images in selected folder script

Use case or problem

Canvas lag and freeze with large number of images, especially large.

Proposed solution

I proposed a more complex implementation in

But, probably, it’s much simpler to just have a universal script that finds all the pictures in Obsidian folder, makes copies of originals, resize pictures without changing the names, and, if specified, converting them into .jpg.
Button which you can press when canvases or notes begin to slow down and freeze. Preferably in Obsidian UI, but not necessarily.