views:

44

answers:

2

I'm trying to do crop animated gif on VDS with this configuration:

~800MHz and 256 RAM

And it's not working. It just eats memory and processor and after a ~minute returns no responce.

http://i192.photobucket.com/albums/z228/Somebi/no-responce.jpg

http://imm.io/1OID

On local machine i'v created a virtual machine with 256 RAM. Everything works fine, but a bit slow i must admit... But i have Duo Core 7400 on local machine.

I have tried to limit memory usage on VDS with these settings:

$gif = new Imagick($s['src']);

set_time_limit(0);
$gif->setResourceLimit(Imagick::RESOURCETYPE_MEMORY,32);
$gif->setResourceLimit(Imagick::RESOURCETYPE_MAP,64);

// echo $gif->getResourceLimit(Imagick::RESOURCETYPE_MEMORY);
// echo $gif->getResourceLimit(Imagick::RESOURCETYPE_MAP);
// echo $gif->getResourceLimit(Imagick::RESOURCETYPE_FILE);
// echo $gif->getResourceLimit(Imagick::RESOURCETYPE_DISK);
// echo $gif->getResourceLimit(Imagick::RESOURCETYPE_AREA);
// exit;

$gif = $gif->coalesceImages();

foreach($gif as $frame){
    $frame->cropImage($s['params']['w'], $s['params']['h'], $s['params']['x'], $s['params']['y']);      
    $frame->setImagePage($s['params']['w'], $s['params']['h'], 0, 0);
}   

$gif->writeImages($s['dest_path'] .'/'. $fullname,true);

But can i limit processor usage?

And is there any solution for slow VDS? :|

Thanks everyone!

update:

   print_r(getimagesize($s['src']));
   exit;

   $gif = new Imagick($s['src']);
   etc...

    Array
(
    [0] => 530
    [1] => 150
    [2] => 1
    [3] => width="530" height="150"
    [bits] => 8
    [channels] => 3
    [mime] => image/gif
)

update2:

pathinfo($s['src'])

(
    [dirname] => images/tmp
    [basename] => 43138a0723d6ae0799564bd6acb8c7b83c8df483.gif
    [extension] => gif
    [filename] => 43138a0723d6ae0799564bd6acb8c7b83c8df483
)

update3: How to debug imagick extension? :(

Have found this package: http://fr2.rpmfind.net/linux/RPM/fedora/updates/testing/13/i386/debug/php-pecl-imagick-debuginfo-3.0.0-5.fc13.i686.html

Have anyone tried it?

A: 

You could increase php's maximum execution time, i believe it defaults to 60 seconds.

At runtime with set_time_limit, or ini config with max_execution_time.

ok, scratch that, i see your already doing it. Doh!

Sam
A: 

I'm going to speculate that $s['src'] contains a remote URL.

That could mean that your real trouble is fetching the remote image. The firewall or something else could be causing the script to time out.

Try it with a local image instead first. I would bet half a beer that it works fine then. In that case, experiment with fetching the remote file using file_get_contents() instead. I think I read something somewhere that IMagick's constructor has trouble with URLs.

Pekka
I'm uploading it first :)
Beck
@Beck okay, then this is not it! I owe you half a beer :)
Pekka