Image Scaling Script

Let us know if you have a nice R.U.B.E script to share!
Post Reply
karanseq
Posts: 1
Joined: Wed Apr 24, 2013 6:38 am

Image Scaling Script

Post 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);
}
Post Reply