Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Picture adornments  - resize in aspect ratio? (Read 1761 times)
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Picture adornments  - resize in aspect ratio?
May 20th, 2013, 7:50am
 
This question crops up from time to time as in TB v5.x (or older) there is no mechanism for resizing picture adornments whilst maintaining aspect ratio. A bit of action code can help…

Before you paste in your picture, make a note of its pixel width height. (How? Open in Preview, Cmd+I to show Inspector, General tab lists image pixel sizes).

Add your image. Let's assume it is 450px wide by 200px high. You can give the adornment this rule.

$Height = $Width*(200/450)

Now, whenever you reset the width of the adornment, the height is reset to scale. OK, that's fine for one adornment but what about if you've lots of picture adornments and they are all different sizes? What if you tend to resize height rather than width?

Stamps can help here, not least it is avoids running rules all the time - given that you won't re-size too often. Add 2 new Number-type user attributes $ImgWidth and $ImgHeight. Now add a stamp called "Resize by Width" with this code:

$Height = $Width*($ImgHeight/$ImgWidth);

Add a second stamp "Resize by Height" with this code:

$Width = $Height*($ImgWidth/$ImgHeight);

Now, when ever you add a picture, set the original image's pixel width in the adornment's $ImgWidth and its pixel height into $ImgHeight. After manually resizing the picture adornment by dragging, use either of the above stamps to to reset it to the original aspect ratio either based on current width or current height.

By extension, you can use the same trick with ordinary adornments. Simply use the original $Height and $Width map units values. The action code is using the ratio of the values so it's their relative values and not the size of the values that matters.

Back to top
 
« Last Edit: May 20th, 2013, 7:52am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Picture adornments  - resize in aspect ratio?
Reply #1 - May 20th, 2013, 12:47pm
 
The above and a 'reset' stamp example added to aTbRef here.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print