dtnd30892 2012-12-30 12:41
浏览 21

在php上从大文件创建拇指

I need to create thumbs from uploaded file(jpg, gif, png). I am using GD for it.

And when try to create thumb from uploaded file that is large(1262x16482) - I get fatal error Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 60126336 bytes)
on line
$image = imagecreatefromjpeg($file);

I've tried to find answers on this issues and most of them are about increasing memory_limit in php.ini. For some reasons this solutions doesn't suit me.

Maybe there are some php extensions that allow to read not all file into memory, but only some part of it.

  • 写回答

2条回答 默认 最新

  • duangan6797 2012-12-30 12:55
    关注

    Depending on the type of file it may be mandatory to load the whole thing into memory before doing work on it.

    Most graphics file formats don't store the info in a linear format. Rather the data in one section may refer to some structure in another section or vv. Your best bet would be to either up your allowed memory in php.ini or limit the file size at upload time.

    评论

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥15 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换