Memory allocation problem (imagecreatefromjpeg) ?

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

    Memory allocation problem (imagecreatefromjpeg) ?

    Hi,
    I have the following code in my php script :

    $fhSrc = imagecreatefrom jpeg($srcFile);

    This cause me the following error : Fatal error: Allowed memory size
    of 8388608 bytes exhausted (tried to allocate 4800 bytes).

    I read that I should increase the memory allowed php. Not sure.
    This script works fine on a Windows 2000/Apache/php4 machine but not
    on a Fedora Linux/Apache/php4 machine. The configuration of php for
    both computer is the same.
    The gd version is 2.0.15 on Linux and 2.0 on Windows.

    $srcFile is valid jpeg image of 900kb (2400x1200px). If I check the
    memory use by the script just before calling imagecreatefrom jpeg I get
    356760.

    So it seems that imagecreatefrom jpeg allow too much memory on Linux.

    Any idea ?

    Thanks,
    Olivier
  • Markku Uttula

    #2
    Re: Memory allocation problem (imagecreatefro mjpeg) ?

    Olivier wrote:[color=blue]
    > This cause me the following error : Fatal error: Allowed memory size
    > of 8388608 bytes exhausted (tried to allocate 4800 bytes).[/color]

    There was a similar problem just few days ago :)
    [color=blue]
    > $srcFile is valid jpeg image of 900kb (2400x1200px). If I check the
    > memory use by the script just before calling imagecreatefrom jpeg I
    > get
    > 356760.[/color]

    Even if your image was 8bit (which it isn't), you'd need 2.74MB to
    load it into memory. But JPEGs are 24bit, so you actually need 8.22MB
    to load it, which is higher than the max. memory setting on your Linux
    box, which is set to only 8MB. I believe you have higher setting on
    your Windows box (or it is disabled alltogether).
    [color=blue]
    > So it seems that imagecreatefrom jpeg allow too much memory on Linux.[/color]

    Nope. Size of image in memory is much larger than the filesize because
    JPEG-files are packed. The size of the file does not correlate with
    the memory required to open it.

    --
    Markku Uttula

    Comment

    Working...