简体   繁体   English

php裁剪真的很大的形象

[英]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 ?). 关于用PHP图片库(GD或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. 例如,我采取一个非常大的文件(5000 x 35000像素)8位颜色3 chanels内存所需的内存只是加载这在内存是aprx。 50 Mo ! 50莫!

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. 我想得到右下角的区域,大小(600 x 600)像素。
  • 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. PHP不是为数字运算而设计的。

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. 如果可以,请使用ImageMagick。

I would look at something like http://phpthumb.sourceforge.net/ 我会看看像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." 我以前从未将它用于如此大的图像,但在主页上它说“ImageMagick(如果可用)可以被调用以生成大于PHP的源图像的缩略图。内存限制将允许仅GD的缩略图执行,或者对于GD不支持的图像格式。“

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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