Image Proportions

FlexibleLearning at aol.com FlexibleLearning at aol.com
Tue Mar 30 02:04:12 EST 2004


>From: Rick Harrison <harrison at all-auctions.com>
>Subject: Image Proportions
>To: How to use Revolution <use-revolution at lists.runrev.com>
>Message-ID: <586D877A-81C7-11D8-B6CC-000393C10758 at all-auctions.com>
>Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>Hi there,
>
>I have a bunch of randomly sized large images that I want to
>fit proportionally into a much smaller image frame.  Kind of
>like making thumbnails.
>
>I figure this has to be a common problem which probably
>has a common solution.  Rather than re-invent the wheel
>I thought I'd see if anyone on this list knows the formula
>for doing this.

Try this as an option, Rick... I am sure others will post alternatives for 
you...

on mouseUp
  if the platform is "Win32" then
    answer file "Select Image..." with filter "Images (*.gif;*.jpg;*.png), 
*.gif;*.jpg;*.png"
  else answer file "Insert Image" of type "JPEGGIFf"
  if it is empty then exit mouseUp
  FLCsetThumbnail it
end mouseUp

on FLCsetThumbnail tPath
  lock screen
  put "50" into tW # Adjust maximum thumbnail width as required
  put "55" into tH # Adjust maximum thumbnail height as required
  put the topLeft of img "thumbnail" into tTL
  set the lockLoc of img "thumbnail" to false
  set the fileName of img "thumbnail" to tPath
  put the width of img "thumbnail" into w
  put the height of img "thumbnail" into h
  if not (w<=tW and h<=tH) then
    put min (tW/w,tH/h) into tscaleFactor
    set the width of img "thumbnail" to w * tscaleFactor
    set the height of img "thumbnail" to h * tscaleFactor
  end if
  set the lockLoc of img "thumbnail" to true
  set the topLeft of img "thumbnail" to tTL
  # OPTIONAL... Use a button to display the image
  # hide img "thumbnail" 
  # set the icon of btn "thumbnail" to ""
  # set the icon of btn "thumbnail" to the id of img "thumbnail"
  unlock screen
end FLCsetThumbnail


More information about the use-livecode mailing list