in reply to Excel Picture Size Changes & other actions

Just an aside regarding your formatting: I see the site stripped out a bunch of your "</br>" tags (because I set my preferences to show me what was modified by the server from what you entered). That is quite understandable, because that kind of tag doesn't legally exist in HTML!

You should be using either "<br />" (slash at the back, space not required) or plain old "<br>".

As for keeping the aspect ratio: why don't you keep it in the proper ratio yourself? Try to reduce either the width or the height, so the other value has its maximum allowed value, and the current aspect ratio is respected. You can do that like this (untested):

my $width = $pic_cur ->{Width}; my $height = $pic_cur ->{Height}; my $aspect = $height / $width; my $max_height = 100; my $max_width = 200; my $new_width = $max_width; my $new_height = $max_width * $aspect; if($new_height > $max_height) { # too high, so reduce width < max_width $new_height = $max_height; $new_width = $new_height / $aspect; } # else: height <= max_height

Replies are listed 'Best First'.
Re^2: Excel Picture Size Changes & other actions
by merrymonk (Hermit) on Nov 02, 2010 at 13:46 UTC
    Thanks for that. However, I want to be able to change the aspect ratio so that I can distort the original image.
    I have tried the following 2 lines
    $pic_cur ->{AspectRatio} = "False"; $pic_cur ->{LockAspectRatio} = "False";
    but neither had the desired effect.
      Well, as I calculate the aspect ratio from the picture dimensions from the original image as it is loaded, you can simply ignore that value and set the desired aspect ratio yourself — or at least, modify it at will. For example, inserting
      $aspect *= 2;
      before using the value, will make the picture twice as high as it should be, although it might be scaled back to fit the maximum allowed size.
        Thanks for that but I still have a problem.
        In my original Perl I had the lines
        $pic_cur ->{Width} = 200; $pic_cur ->{Height} = 100;
        The issue is that setting the width to 200 is, in effect, ignored because I believe some setting is there which
        means that the aspect ratio of the image is kept the same.
        Therefore the Height setting and the 'fixed' aspect ratio means that after setting the Height the Width is reset to 81.818.
        Therefore I am still puzzling how to say that I do not want the aspect ratio of the image to be constant.
        Then I will be able set the Width and Height to what I want.
Re^2: Excel Picture Size Changes & other actions
by JavaFan (Canon) on Nov 02, 2010 at 15:04 UTC
    To be pedantic, <br /> isn't actually legal in HTML either. (If you think it is, I challenge you to give the relevant SGML/HTML-DTD rules and the derivation)
      Go to http://validator.w3.org/ and enter
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><HEAD><TITLE>Br</TITLE></HEAD><BODY><br/></body></html>
      compare with
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR +/html4/strict.dtd"> <html><HEAD><TITLE>Br</TITLE></HEAD><BODY><br/></body></html>
        <html><HEAD><TITLE>Br</TITLE></HEAD><BODY><br/></body></html> The sequence <FOO /> can be interpreted in at least two different ways +, depending on the DOCTYPE of the document. For HTML 4.01 Strict, the '/' terminates the tag <FOO + (with an implied '>'). However, since many browsers don't interpret it this way, even in the +presence of an HTML 4.01 Strict DOCTYPE, it is best to avoid it completely in pure HTML documen +ts and reserve its use solely for those written in XHTML.
        Ah, yes, I forgot that nettags are formally supported by the DTD. So, yes, <br/> is valid, but it's not a simple line break: it's a line break followed by a greater than sign. Not supported by most browsers though.