A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: image resize

  1. #1
    Senior Member JFlashK's Avatar
    Join Date
    Dec 2000
    Posts
    618
    Does anybody have a source of a php imageresizer?
    I have GD Version 1.6.2 so please no 2.0 files. Anybody an idea?

    Thanks

  2. #2
    Senior Member
    Join Date
    Mar 2002
    Posts
    161
    I think this is my old pre2.0 code for a webpage based jpeg image resizer, alter for png/gif as necessary:

    Code:
    <html>
    <body>
    <head><title>jpeg Maker</title>
    <script>
    function sizer(){
    document.forms[0].h.value=document.images[0].height;
    document.forms[0].w.value=document.images[0].width;
    }
    function checkh(){
    if(document.forms[0].proportional.checked){
    ox=(document.images[0].width*1);
    oy=(document.images[0].height*1);
    ny=(document.forms[0].h.value*1);
    nx=(ox*ny)/oy;
    document.forms[0].w.value=Math.floor(nx);
    }}
    function checkw(){
    if(document.forms[0].proportional.checked){
    oy=(document.images[0].height*1);
    ox=(document.images[0].width*1);
    nx=(document.forms[0].w.value*1);
    ny=(oy*nx)/ox;
    document.forms[0].h.value=Math.floor(ny);
    }}
    </script>
    </head>
    <body>
    <noframes><marquee>WebTv Bug Alert!!! Press cmd+r for 5 seconds to fix!</marquee></noframes>
    <center>
    <h1><a href="http://webwizardsways.com">WebWizardsWays</a> <a href="index.html">jpeg Maker</a></h1><hr><h1>Resize Image</h1><h3>Enter the new image dimensions</h3><font size="1" effect="shadow">(you may need to re-transparentize after resizing)</font><p>
    <shadow><form action="size.php" method="get"><font size="2" effect="shadow">Proportional:</font><input type="checkbox" name="proportional" checked> Width:<input name="w" size="3" onChange="checkw()"> Height:<input name="h" size="3" onChange="checkh()"><input name="rndm" type="hidden"><input type="submit"></form></shadow><p>
    <?php
    if($w){
    if(!$temp_url){$temp_url="temp.jpeg";}
    $npic=ImageCreate($w,$h);
    $opic=ImageCreateFromjpeg($temp_url);
    $ow=ImageSX($opic);
    $oh=ImageSY($opic);
    ImageCopyResized($npic,$opic,0,0,0,0,$w,$h,$ow,$oh);
    Imagejpeg($npic,$temp_url);
    ImageDestroy($npic);
    }
    $file_size=filesize("temp.jpeg");
    $fpic=ImageCreateFromjpeg("temp.jpeg");
    $fw=ImageSX($fpic);
    $fh=ImageSY($fpic);
    ImageDestroy($fpic);
    print "<img src=\"temp.jpeg?$rndm\" onLoad=\"sizer()\"><br>Width=$fw Height=$fh<br>$file_size k<hr>
    ";
    ?>
    <form action="main.php" method="get"><input type="hidden" name="rndm"><input type="hidden" name="pic_url" value="temp.jpeg"><input type="submit" value="Click Here When Finished Resizing"></form>
    </center>
    <script>
    document.forms[0].rndm.value=document.forms[1].rndm.value=Math.random();
    </script>
    </body>
    </html>
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center