PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > php-GD image calculate memory usage
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
php-GD image calculate memory usage

Réponse
 
LinkBack Outils de la discussion
Vieux 04/10/2007, 09h15   #1 (permalink)
Bob Bedford
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut php-GD image calculate memory usage

Hi all,

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 ?
neededmemory is the memory I need to load the original file and resize it
(imagecreatefromjpeg for the original and imagecreatetruecolor for the
copy).

Thanks for ing.

Bob


  Réponse avec citation
Vieux 04/10/2007, 09h58   #2 (permalink)
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: php-GD image calculate memory usage

..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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h50.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07447 seconds with 10 queries