Page 1 of 1

Fit an image perfectly in html() dimensions?

Posted: 10 Oct 2021 21:57
by highend
I have an animated.gif that I want to preview via the inbuilt html() command

Does anybody know how to put that inside the html code so that I don't need arbitrary values for html() width and height?

Ofc the scrollbars must be hidden...

Code: Select all

    $dims   = property("#image.dimensions", <curitem>);
    $width  = gettoken($dims, 1, " x ", "t");
    $height = gettoken($dims, 2, " x ", "t");
    $src    = replace(<curitem>, "\", "/");
    $file   = gpc(<curitem>, "file");

    // CSS styles
    $cssStyles = <<<>>>
        body {
          overflow: hidden;
        }
    >>>;

    $html = <<<>>>
    <html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <style>
            $cssStyles
        </style>
    </head>
    <title></title>
    <body>
        <div style="position:absolute;left:0px;top:0px">
            <img src="$src" alt="$file" width="$width" height="$height"></img>
        </div>
    </body>
    </html>
>>>;
    html($html, $width + 40, $height + 100, self("base"));

Re: Fit an image perfectly in html() dimensions?

Posted: 11 Oct 2021 21:25
by mazot
I am not an expert in HTML but have you tried percentages(%).

Re: Fit an image perfectly in html() dimensions?

Posted: 11 Oct 2021 21:51
by klownboy
Hi highend, have you taken a look at TheQwerty's HTML Image Preview script viewtopic.php?f=7&t=13690? I know he must do some sizing of the GIF files within that script.