I tested the code and it worked fine. I'm running x-cart version 3.4.3.
The one thing to check is that the widths of your images are being stored in the 'xcart_products' table. In newer versions this is added automatically when you upload your images. Older versions don't do it automatically. You could add the widths manually if you wanted.
One more thing, the line in my code:
Code:
{math equation="x/3" x=$products[product].image_x assign="proportional"}
Should be changed to:
Code:
{math equation="x/3" x=$products[product].image_x assign="proportional" format="%01d"}
By the way, this code will make all of your images 1/3 of their actual size. If you wanted them to be 1/4, you could change the equation to "x/4". For 30% you could change the equation to "30 * (x/100)".