как уменьшить размер картинки на php

Discussion in 'PHP' started by VladZombie, 20 Oct 2010.

  1. VladZombie

    VladZombie New Member

    Joined:
    18 Apr 2009
    Messages:
    47
    Likes Received:
    2
    Reputations:
    0
    Господа, подскажите, плз, как уменьшить размер картинки на php.

    Т.е. мне надо вставить в одну страницу <img src="imаgеs.php">, а imаgеs.php будет открывать картинку с большим разрешением, менять его на 100x100 и выдавать в браузер.
     
  2. Партнёр

    Joined:
    7 Sep 2010
    Messages:
    224
    Likes Received:
    67
    Reputations:
    1
    <?php
    header('Content-type: imаgе/jpeg');
    //$myimаgе = resizeimаgе('filename', 'newwidthmax', 'newheightmax');
    $myimаgе = resizeimаgе('test.jpg', '150', '120');
    print $myimаgе;
    function resizeimаgе($filename, $newwidth, $newheight){
    list($width, $height) = getimаgеsize($filename);
    if($width > $height && $newheight < $height){
    $newheight = $height / ($width / $newwidth);
    } else if ($width < $height && $newwidth < $width) {
    $newwidth = $width / ($height / $newheight);
    } else {
    $newwidth = $width;
    $newheight = $height;
    }
    $thumb = imаgеcreatetruecolor($newwidth, $newheight);
    $source = imаgеcreatefromjpeg($filename);
    imаgеcopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); return imаgеjpeg($thumb);}
    ?>
     
  3. VladZombie

    VladZombie New Member

    Joined:
    18 Apr 2009
    Messages:
    47
    Likes Received:
    2
    Reputations:
    0
    неработает!
     
  4. roxblnfk

    roxblnfk Elder - Старейшина

    Joined:
    6 Feb 2010
    Messages:
    189
    Likes Received:
    42
    Reputations:
    19