Why isn't this image being displayed with TimThumb? - image

I am using TimThumb at http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/.
I have adjusted the memory_limit to "5000MB" in my php.ini file and in the TimThumb code I adjusted the code to the following:
define ('MEMORY_LIMIT', '30M'); // set PHP memory limit
define ('MAX_FILE_SIZE', 7000000000); // file size limit to prevent possible DOS attacks (roughly 1.5 megabytes)
The picture itself is only 2.23 MB, the last time I checked that wasn't that big lol.

You need to use ini_set(), not a define() to change php settings:
ini_set('memory_limit','64M');
edit: noticed the memory it reports is 30M, so maybe the thumbnail script uses the defined value. Either way, just increase your memory limit until it works.

Related

How to upload large size image by Intervention Image in Laravel 5

I'm using Image Intervention in my project.
My application working smoothly while uploading small size images. But when I try to upload large size image(>2mb), my application stops working!
Even It shows no proper errors. Sometimes It shows Token mismatch error & sometimes the url not redirects.
How to fix it? I've no idea.
Here is my code:
$post->new Post();
if($request->hasFile('image')){
$image=$request->file('image');
$filename=Auth::user()->id.'_'.time().'.'.$image->getClientOriginalExtension();
$location=public_path('images/'.$filename);
Image::make($image)->save($location);
$post->image=$filename;
}
$post->save();
I'm using Image intervention for uploading images. But you can suggest alternative of it as well.
Thanks!
Actually this is the issue from server side setting variable values into php.ini file. if you upload more then your server's post_max_size setting the input will be empty, you will get Token mismatch error.
change upload_max_filesize , post_max_size value as per you required and restart the server.
It turns out this is a memory issue. If you check the error log you with see that the server ran out of memory. You will see something like
PHP Fatal error: Allowed memory size of XXXXXXXX bytes exhausted (tried to allocate XXXXX bytes) in ...
Because Intervention Image reads the whole image pixel by pixel keeping the data in memory, seemingly small images like 2MB can end up requiring dozens of MB of memory to process.
You may need to set your memory limit to the highest available and check the file size before it is opened because a site that breaks without error messages is embarrassing. Use something like
if( $request->hasFile('image') && $request->file('image')->getClientSize() < 2097152 ){
$image=$request->file('image');
$filename=Auth::user()->id.'_'.time().'.'.$image->getClientOriginalExtension();
$location=public_path('images/'.$filename);
Image::make($image)->save($location);
$post->image=$filename;
}

How to compile kernel with bigge page size

I tried to mount a parition with block size larger than 4kb.
the operation failed with the following error:
Function not implemented
(I tried enabling Huge Pages, got the same error).
After some research I found that this is probably due to the blocksize being larger than the os page size.
As I understand the page size is determined at compile time,
so I'd like to try compile a kernel with different page size.
You can use these kernel configurations from make menuconfig and change the page size.
CONFIG_<ARCH>_4K_PAGES
CONFIG_<ARCH>_16K_PAGES
CONFIG_<ARCH>_64K_PAGES

Allowed memory size exhausted on Laravel Ardent

I got this error when saving with a file on input. The file is uploaded but I got this in saving process.
Allowed memory size of 134217728 bytes exhausted (tried to allocate 94 bytes) in ...vendor/laravelbook/ardent/src/LaravelBook/Ardent/Ardent.php
The size of the file is just 24kb. And the code is just a typical eloquent fill. The process is the following:
Get the file from the input, moved to storage location and make an insert for its file path in the database.
Update the file id of the target eloquent model.
I'm using:
"laravelbook/ardent": "v2.4.2"
Your script is eating all of the memory that PHP process can use, in your case it's 128 MB.
You can do 2 things:
Optimize your code and figure out which part of the code is the problem.
Set higher memory_limit with changing php.ini value of memory_limit to 256M for example, or by calling ini_set('memory_limit','256M');
It caused by the "php artisan optimize --force". When I removed the bootstrap/compiled.php it works again. :) Btw, how is that? is it a bug for "php artisan optimize --force" of Laravel?

Memory Size Errors When Running Magento's cron.sh

We have set the nginx user to run the following command at 5 minute intervals.
sh /var/www/magento/cron.sh
This was executed fairly successfully for some time. Within the last month or so, it has begun to error out each time due to memory limit. I've increased the memory limit but that's only caused a higher limit that gets reached. It seems that there must be a bigger problem. The error is consistently as follows.
Fatal error: Allowed memory size of 262144 bytes exhausted
(tried to allocate 7680 bytes) in /var/www/magento/app/Mage.php on line 589
Below are the crons that magento has set to run every five minutes:
job: xmlconnect_notification_send_all
model: xmlconnect/observer::scheduledSend
file: /var/www/magento/app/code/core/Mage/XmlConnect/etc/config.xml
job: newsletter_send_all
model: newsletter/observer::scheduledSend
file: /var/www/magento/app/code/core/Mage/Newsletter/etc/config.xml
job: enterprise_staging_automates
model: enterprise_staging/observer::automates
file: /var/www/magento/app/code/core/Enterprise/Staging/etc/config.xml
Your error message has all the answers
Allowed memory size of 262144 bytes exhausted
While 262144 bytes seems like a big number, it's only 256KB, or around .25 MB
I believe the Magento documents recommend a memory limit of 256MB, with 512MB being a far more common in the wild. You'll need make sure your command PHP version (or the command line PHP launched by cron.sh) has it's memory_limit ini set correctly. One common pitfall here is to omit the M, or to use MB
; Will not do what you want it to
memory_limit=256
memory_limit=256MB
So make sure your configuration file is set something like this
memory_limit=256M
This is a server setup issue. Your php CLI memory_limit is set too low.
Bounce it up to 256M.
If you're not running your own server, then you need to contact your hosting provider.

Cakephp 2x using debug($this) inside a action

Hi i am new to cakephp and i want to use "debug" in order to have a better view about the framework structure.
If i use var_dump($this) , inside a action, the page takes a long time to load and end up with a non structured data on screen.
I found that "debug" function shows a more elegant structure, but if i use debug($this) inside the action i end up with the well known php stack overflow :) " Allowed memory size of 268435456 bytes exhausted (tried to allocate 113621911 bytes) "
How can i work around this ?
I've made a more specific debug and it worked just fine.

Resources