Hi again,
this time I am confronted with the following issue:
I want to import an image (or more) , guess easy thing with the open/import file commands,
check the Resolution size of these images (f.e. 800*600) and resize the image to 68*68 if it exceeds these values.
I don´t have a clue how to archieve that and would be grateful if anyone could help me.
Cheers,
Masterchief
How to resize an image?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: How to resize an image?
Hi cheif,
do this, and do this behind the screnes
You get the picture 
Best
Klaus
do this, and do this behind the screnes

Code: Select all
...
lock screen
## behind the scenes, user will not see any of your magic
## import here your image or set the filename of an existing image...
## Now get the original dimension of this image:
put the formattedwidth of img "your image here" into tWide
put the formattedheight of img "your image here" into tHeigh
## Now check if these values fit
if tWide > 800 AND tHeigh > 600 then
## resize the image accordingly
end if
unlock screen
...

Best
Klaus
Re: How to resize an image?
Hello JB,
This function calculates the new widh and height of an object:
usage:
put rescale(the formattedWIdth of img 1,the formattedHeight of img 1,64,64) into myHW
--> myHW example values: 54,64 or 64,48 etc.
Best regards,
Mark
This function calculates the new widh and height of an object:
Code: Select all
function rescale theImgWidth,theImgHeight,theCdWidth,theCdHeight
if theCdWidth/theImgWidth < theCdHeight/theImgHeight then
put theCdWidth / theImgWidth into myRatio
else
put theCdHeight / theImgHeight into myRatio
end if
put theImgWidth * myRatio into myNewWidth
put theImgHeight * myRatio into myNewHeight
return myNewWidth,myNewHeight
end rescale
put rescale(the formattedWIdth of img 1,the formattedHeight of img 1,64,64) into myHW
--> myHW example values: 54,64 or 64,48 etc.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode