Memory exhausted

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ron Eggler

    Memory exhausted

    Hi,

    I'm trying to resize a pic with the Code pasted below and get following
    Error, why, how to resize it correctly???
    src:

    Error: <br />
    <b>Fatal error</b>: Allowed memory size of 8388608 bytes exhausted at
    (null):0 (tried to allocate 9088 bytes) in
    <b>/srv/www/htdocs/web2/html/php/gallerytest/resizePic.php</b> on line
    <b>39</b><br />

    Source:
    <?php
    header("Content-type: image/jpeg");
    header("Content-Disposition: inline; filename=\"". $src . "");

    if (isset($x))
    $detail_max_x=$ x;
    else
    $detail_max_x = 300;

    if (isset($y))
    $detail_max_y=$ y;
    else
    $detail_max_y = 300;

    $type = "jpg";

    // Orginalbild
    $pic=$src;

    // Bilddaten feststellen
    $size=getimages ize($pic);
    $faktor_y=$size[0]/$detail_max_y;
    $faktor_x=$size[1]/$detail_max_x;

    $breite = $size[0];
    $hohe = $size[1];

    // Verkleinerungsf aktor / Vergrösserungsa faktor
    if($faktor_y < $faktor_x)
    { $sfaktor = $faktor_x; }
    else
    { $sfaktor = $faktor_y; }

    $neueBreite=int val($size[0]/$sfaktor);
    $neueHoehe=intv al($size[1]/$sfaktor);


    //JPG ausgabe
    $altesBild=Imag eCreateFromJPEG ($pic);
    $neuesBild=Imag eCreate($neueBr eite,$neueHoehe );
    ImageCopyResize d($neuesBild,$a ltesBild,0,0,0, 0,$neueBreite,$ neueHoehe,$brei te,$hohe);
    //$info = getimagesize($n euesBild);
    //$farbe_b = imagecoloralloc ate($neuesBild, 10,36,106);
    //imagerectangle( $neuesBild,1,1, $info[0]-1,$info[1]-1,$farbe_b);
    Imagejpeg($neue sBild);
    ?>

    Thank you very much!!!!
    --
    roN



  • Janwillem Borleffs

    #2
    Re: Memory exhausted

    Ron Eggler wrote:[color=blue]
    > I'm trying to resize a pic with the Code pasted below and get
    > following Error, why, how to resize it correctly???[/color]

    Your version of PHP is probably compiled with memory limit support, which
    defaults to 8M. Just increase the allowed memory (e.g. by adjusting the
    memory_limit directive in your php.ini file to 16M) and it will work fine.


    JW



    Comment

    • Ron Eggler

      #3
      Re: Memory exhausted

      Janwillem Borleffs wrote:[color=blue]
      > Ron Eggler wrote:[color=green]
      >> I'm trying to resize a pic with the Code pasted below and get
      >> following Error, why, how to resize it correctly???[/color]
      >
      > Your version of PHP is probably compiled with memory limit support,
      > which defaults to 8M. Just increase the allowed memory (e.g. by
      > adjusting the memory_limit directive in your php.ini file to 16M) and
      > it will work fine.[/color]

      had to set it to 32M... :| seems like there is anything bad.... but what?[color=blue]
      >
      >
      > JW[/color]

      --
      roN



      Comment

      • Markku Uttula

        #4
        Re: Memory exhausted

        Ron Eggler wrote:[color=blue]
        > had to set it to 32M... :| seems like there is anything bad.... but
        > what?[/color]

        Well, JPEG-images *are* 24-bit bitmaps. So an image at size of
        3000x3000 pixels *will* require 25.7MB of memory. In your script, the
        memory required to finish the script depends on the size of $altesBild
        (because it *gets* loaded into memory) even though $neuesBild would
        only be quite small.

        --
        Markku Uttula

        Comment

        Working...