简体   繁体   中英

php crop really large image

This question is not about the code for crop images.

I know how it's work.

It's just au question about handling very large pictures with PHP an picture library ( GD or ImageMagick ?).

For exemple i take a really big file ( 5000 x 35000 pixels ) 8bits color 3 chanels the memory needed just for load this in memory is aprx. 50 Mo !

Now, i want to make this action ( just for example ) :


  • i want to get the area in the bottom right , with size (600 x 600) pixel.
  • on this image part, i want to add a graphic tag ( no worries about this i know)
  • and after, i want to write this part in the original file.

I think, the workflow must be this :

  1. read the original bytes from large picture ( just for get de part file )

  2. work on part file

  3. write the part in the large image.

All with small memory footprint.

Can you help me for write this code ( or link to ressources )

thanks a lot.

尝试在调整大小之前添加此内容:

  ini_set('memory_limit', '128M');

PHP isn't designed for number crunching.

Image editing involves a lot of number crunching.

Any workaround would have to be native to see a significant difference in performance. Use ImageMagick if you can.

I would look at something like http://phpthumb.sourceforge.net/

I've never used it for images so large before, but on the home page it says "ImageMagick (if available) can be called to generate thumbnails for source images larger than PHP's memory limitation would allow a GD-only thumbnailer to do, or for image formats that GD does not support."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM