Croping bitmap in maxscript

Does anyone have the idea how to crop a bitmap using maxscript ? Say i have bitmap size 2560 x 1600 , I can resize it to 150 x xx , but I have problem when I want to resize it to 150 x 150, kind of rectangular image, its height is strecht out. How to solve it ?

Thanks a lot guys for attention.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fajar's picture

here is some for someone who

here is some for someone who might need it someday, just leaving the traill...not the resizing tho, but to make it white background

fn makeRectImage theImgSource=
(
	myImage =theImgSource
	theImg=openBitmap myImage
	srcW=theImg.width
	srcH=theImg.height
 
	if srcW < 150 then srcW=((150-srcW)/2) else srcW=0
	if srcH < 150 then srcH=((150-srcH)/2) else srcH=0
 
	tempFile=getFilenamePath myImage
	tempName=getFilenameFile myImage
	tempExt=getFilenameType myImage
	newTempName=(tempFile+tempName+"___"+tempExt)
 
	theTemImg=bitmap 150 150 color:white filename:newTempName
	theTemImg.gamma =2.2
	pasteBitmap theImg theTemImg (box2  0 0 150 150) [srcW,srcH]	--src dest
 
	save theTemImg
	deleteFile myImage
	renameFile newTempName myImage
	myImage --return for image file name in case someone need to batch it
)
fajar's picture

Ok miauu, ive done it with

Ok miauu, ive done it with the way you wrote...

Thanks for replay

miauu's picture

Can you do this in PS-

Can you do this in PS- resizing 2560 x 1600 image to 150x150 without stretching it?
I think that you can't resize 16:9 image to 4:3 without stretching of the image. When you crop the image you will loose some of the pixels. So, what I suggest:
- resize 2560 x 1600 to 150 x XX pixels(the XX must be less than 150).
- create new image 150x150
- use pasteBitmap(depends of MAX version tha tyou have) or use per pixel loop to "put" the 150 x XX over the 150x150.
At the end your 2560 x 1600 imagw will be resized to 150x150, but you will have black(or any other color that you choose) fields on the right side of the image(blackPixelsWidth = 150 - XX).

Maybe this is not what you need, but... :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.