ubuntu php imagecreatefrompng,imagecreatefrompng

[#3]

marcos at assl-site dot net [2007-02-28 12:23:27]

I had the same problem as jboyd1189 at yahoo dot com but I solve d it allocating more memory dynamically.

Usually the memory_limit var on php.ini is set to 8M. Unfortunately, the required amount of memory to manage a PNG image about 1000x1000 could be bigger !

The approach I used to solve the problem is:

1-Calculate the memory required by the image

2-Set the new memory_limit value

3-Create the PNG image and thumbnail

4-Restore the original value

1-The following value works for me:

$required_memory = Round($width * $height * $size['bits']);

Note that for JPEG the requirements are not the same:

http://es2.php.net/manual/en/function.imagecreatefromjpeg.php#60241

2-Use somthing like:

$new_limit=memory_get_usage() + $required_memory;

ini_set("memory_limit", $new_limit);

4-ini_restore ("memory_limit");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值