Newbie Image Resizing Question...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Newbie Image Resizing Question...
I'm struggling to understand the numerous things I can do with images.
If I create an Image Area on a card that is, say, 200x100px, and I place an image in there, using "set the filename of img" (to some url) the remote image gets resized to 200x100 before it is displayed.
That's fine if the image was 400x200, or some exact multiple, but not if it was 600x200, coz then it gets squished.
Could someone please explain, or point me to a tutorial that explains, how I can resize the image to a max width of 200 and a max height of 100px before it's displayed.
Many tkx...
--paul
If I create an Image Area on a card that is, say, 200x100px, and I place an image in there, using "set the filename of img" (to some url) the remote image gets resized to 200x100 before it is displayed.
That's fine if the image was 400x200, or some exact multiple, but not if it was 600x200, coz then it gets squished.
Could someone please explain, or point me to a tutorial that explains, how I can resize the image to a max width of 200 and a max height of 100px before it's displayed.
Many tkx...
--paul
Re: Newbie Image Resizing Question...
Hi Paul,
This function return the max width and height proportional
Best regards
Jean-Marc
This function return the max width and height proportional
Code: Select all
function PourCrop pWidthSource,pHeightSource,pWidthDest,pHeightDest,pMarge
if pWidthSource ≤ pWidthDest-pMarge and pHeightSource ≤ pHeightDest-pMarge then
put pWidthSource into LaWdef
put pHeightSource into LaHdef
else
if pWidthSource = pHeightSource then -- that is a square
put pWidthDest-pMarge into LaWdef
put pHeightDest-pMarge into LaHdef
return LaWdef,LaHdef
exit PourCrop
end if
subtract pMarge from pWidthDest
subtract pMarge from pHeightDest
put (pWidthDest/pWidthSource) into LeDivW
put (pHeightDest/pHeightSource) into LeDivH
put min(LeDivW,LeDivH) into LeDiv
put trunc(pWidthSource*LeDiv) into LaWdef
put trunc(pHeightSource*LeDiv) into LaHdef
end if
return LaWdef,LaHdef
end PourCrop
Jean-Marc
https://alternatic.ch
Re: Newbie Image Resizing Question...
Merci Jean-Marc...
But, maybe I'm not understanding something, it looks like the image has been resized before it is displayed on the card.
Using my example: if my image area is 200x100 and the remote image is 600x200, what is see in my image area is 200x100. If I inspect its size, it is 200x100. So I can no longer resize it in the way I want.
I must be missing something?
--paul
But, maybe I'm not understanding something, it looks like the image has been resized before it is displayed on the card.
Using my example: if my image area is 200x100 and the remote image is 600x200, what is see in my image area is 200x100. If I inspect its size, it is 200x100. So I can no longer resize it in the way I want.
I must be missing something?
--paul
Re: Newbie Image Resizing Question...
Hi Paul
In the Inspector of your image: Size & Position: "lockloc" (Lock size and position)
Here is what you need to do:
1. Set the filename of your image (load the image into the image object)
2. get "the formattedwidth" and "formattedheight" of the image (= original dimensions in Pixels)
3. apply the "rule of three" to get the new width and height so it fits into the 200*100 image area WITHOUT getting distorted
4. set the new computed width and height of the image
Please work through these stacks if not done already:
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
This sound as if your image is "locLock"ed!paulsr wrote:...
Using my example: if my image area is 200x100 and the remote image is 600x200, what is see in my image area is 200x100. If I inspect its size, it is 200x100. So I can no longer resize it in the way I want.
I must be missing something?--paul
In the Inspector of your image: Size & Position: "lockloc" (Lock size and position)
Here is what you need to do:
1. Set the filename of your image (load the image into the image object)
2. get "the formattedwidth" and "formattedheight" of the image (= original dimensions in Pixels)
3. apply the "rule of three" to get the new width and height so it fits into the 200*100 image area WITHOUT getting distorted
4. set the new computed width and height of the image
Please work through these stacks if not done already:
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
Re: Newbie Image Resizing Question...
Hi Paul,
The stack in attachment play with some ways to resize an image
I hope this help
I changed the PourCrop function its did'nt work with squares
Best regards
Jean-Marc
The stack in attachment play with some ways to resize an image
I hope this help
I changed the PourCrop function its did'nt work with squares

Code: Select all
function PourCrop pWidthSource,pHeightSource,pWidthDest,pHeightDest,pMarge
if pWidthSource ≤ pWidthDest-pMarge and pHeightSource ≤ pHeightDest-pMarge then
put pWidthSource into LaWdef
put pHeightSource into LaHdef
else
if pWidthSource = pHeightSource then -- that is a square
put min(pWidthDest,pHeightDest) into t
put t-pMarge into LaWdef
put t-pMarge into LaHdef
return LaWdef,LaHdef
exit PourCrop
end if
subtract pMarge from pWidthDest
subtract pMarge from pHeightDest
put (pWidthDest/pWidthSource) into LeDivW
put (pHeightDest/pHeightSource) into LeDivH
put max(LeDivW,LeDivH) into LeDiv
put trunc(pWidthSource*LeDiv) into LaWdef
put trunc(pHeightSource*LeDiv) into LaHdef
end if
return LaWdef,LaHdef
end PourCrop
Jean-Marc
- Attachments
-
- stResizeImage.livecode.zip
- (2.63 KiB) Downloaded 310 times
https://alternatic.ch
Re: Newbie Image Resizing Question...
Thanks Guys, I've got the hang of this now.
But a related question, if I may...
I want my image to be resized and to fit in an area 200x100. Let's say the resized image is 200x50.
Is there a (hopefully easy!) way to expand the image to 200x100 by inserting white space top & bottom?
I'm not asking for an instant solution... Just point me to the right commands and I'll try to figure it for myself.
Thanks...
--paul
But a related question, if I may...
I want my image to be resized and to fit in an area 200x100. Let's say the resized image is 200x50.
Is there a (hopefully easy!) way to expand the image to 200x100 by inserting white space top & bottom?
I'm not asking for an instant solution... Just point me to the right commands and I'll try to figure it for myself.
Thanks...
--paul
Re: Newbie Image Resizing Question...
Selamat Datang Paul,
Why not a white graphic like frame 200X100 and setting the loc of the image to the loc of the graphic ?
Best regards
Jean-Marc
This forum is made for thatBut a related question, if I may...
Why not a white graphic like frame 200X100 and setting the loc of the image to the loc of the graphic ?
Best regards
Jean-Marc
https://alternatic.ch
Re: Newbie Image Resizing Question...
Terima Kasih Jean-Marc,
Your solution would work fine.
--paul
Your solution would work fine.
--paul