php调整大小类失败,在dreamhost上使用更大的图像文件大小

问题描述:

This is an odd error I'm encountering and reaching out to see if anyone can help me pin down why this is happening.

So basically, I've got a form that uploads an image using jquery ajax, then uses a resizing class http://jarrodoberto.com/articles/2011/09/image-resizing-made-easy-with-php to crop the image. I've noticed with images over 1mb the script fails with no error messages. Also, this is only happening on dreamhost. On my host gatorserver everything works as it should.

What is odd to me is that images smaller in size seem to work fine. All of the php ini settings are well above the limits so I know that's not the issue and both servers are running php 5.6. and have error reporting on.

I've also tested this script directly without ajax and it does not work on images much over 1mb.

include('resize-class.php');
$resizeObj = new resize('photo.jpg');
$resizeObj -> resizeImage(250,250,'auto');
$resizeObj -> saveImage('photo-test.jpg', 100);

So this obviously is something with the script and how dreamhost is setup.

Any ideas why this is happening?

Upon further testing I'm finding this error Allowed memory size of 94371840 bytes exhausted this same test only produces this error on dreamhost and only certain jpg files, not on hostgator. So this has something to do with dreamhost and certain jpg files.

The solution was to modify the dreamhost phprc file located in /home/username/.php/5.6/phprc to something similar to the following

upload_max_filesize = 100M
post_max_size = 105M
max_execution_time = 500
max_input_time = 250
memory_limit = 256M

https://help.dreamhost.com/hc/en-us/articles/214894037-How-do-I-create-a-phprc-file-via-FTP-

ONE IMPORTANT THING TO NOTE: The changed php settings take about 10 min to take effect as I'm supposing they are part of a cgi process that restarts ever so often.

The memory limit seemed to be causing the error.

Not sure why this resize-class.php script would need that much memory to resize a 1mb photo.