Page 1 of 1

Image Scaling Script

Posted: Sat May 18, 2013 9:18 am
by karanseq
I wrote a script that will scale images to their appropriate size.
If you notice, every time you import an image into RUBE, the image is automatically scaled down so its height is 1m...irrespective of its height in pixels.
This is unhelpful when you want to shape bodies based on those images.
Hence this script uses a pixel-to-meter ratio to scale bodies so that they are in proportion to their size in pixels.

Code: Select all

float PTM_RATIO = 128;
image[] imgs = getSelectedImages();
for(uint i = 0; i < imgs.length; i ++)
{
	float h = imgs[i].getPixelHeight();
	float s = h/PTM_RATIO;
	imgs[i].setScale(s);
	print("Image:" + imgs[i].getName() + " Scale:" + s);
}