Reply to Re: php-GD image calculate memory usage

Your name:

Reply:


Posted by Michael Fesser on 10/04/07 08:58

..oO(Bob Bedford)

>I'm using GD library version 2.0.28 for resizing images on my server. As
>I've checked out, the maximum allowed memory (16MB) is reached when my
>original picture is 2158*1618 pixels. For now I just check the width and
>height of the pictures and if there is one bigger than 1900 pixels I don't
>try to resize and do it with an other program.
>
>Now the memory limit has been raised by the hosting company (This setting
>can't be changed in any way since the hosting company did disallow all ways
>to do so).
>I can now deal with 50MB memory limit. I'd like to know how to check the
>needed memory for resizing and the maximum allowed memory the script can
>deal with...like
>
>if(neededmemory > availablememory)
> resizepicture
>else
> tagpicturetoberesized
>
>How to check the neededmemory and availablememory ?

With ini_get() you can get the value of the memory_limit directive.

A quite good estimation of the needed memory for an image in bytes is to
calculate the number of pixels and multiply that value with 4 (3 bytes
for the RGB colors, 1 byte for the alpha channel).

Micha

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация