how do I copy a lot of images onto a canvas in PHP? -


i have witten function copies images onto canvas , saves file. code @ bottom of post.

the code works fine when try copy 15 image onto canvas, when try copy 30 stops. no errors or exceptions...

i hope 1 of can me out :)

    $img        = imagecreatefromjpeg( $image );     $imgwidth   = imagesx($img);     $imgheight  = imagesy($img);      // create canvas , fill white     $canvas     = imagecreatetruecolor( $guidelines['canvasw'] * $dpi, $guidelines['canvash'] * $dpi );     $color      = imagecolorallocate( $canvas, 255, 255, 255 );     imagefill( $canvas, 0, 0, $color );      // copy images onto canvas     foreach( $guidelines['imageguide'] $guide ):          $bestfit    = bestfit( $imgwidth, $imgheight, $guide['w'] * $dpi, $guide['h'] * $dpi );         if( $bestfit['rotate'] ) {             $output = imagerotate($img, 90, 0);         } else {             $output = imagerotate($img, 0, 0);         }         imagecopyresampled($canvas, $output, $guide['x'] * $dpi, $guide['y'] * $dpi, 0, 0, $bestfit['x'], $bestfit['y'], imagesx($output), imagesy($output));          imagedestroy($output);     endforeach; 

$guidelines array. here example copy 16 images onto canvas

    $guidelines = array(    'canvasw' => 20,             'canvash' => 30,             'imageguide' => array(                         array('w' => 18,    'h' => 13,  'x' => 1,   'y' => 1.5),                          array('w' => 3.5,   'h' => 4.5, 'x' => 1.25,    'y' => 15),                         array('w' => 3.5,   'h' => 4.5, 'x' => 4.75,    'y' => 15),                         array('w' => 3.5,   'h' => 4.5, 'x' => 8.25,    'y' => 15),                         array('w' => 3.5,   'h' => 4.5, 'x' => 11.75,   'y' => 15),                         array('w' => 3.5,   'h' => 4.5, 'x' => 15.25,   'y' => 15),                          array('w' => 3.5,   'h' => 4.5, 'x' => 1.25,    'y' => 19.5),                         array('w' => 3.5,   'h' => 4.5, 'x' => 4.75,    'y' => 19.5),                         array('w' => 3.5,   'h' => 4.5, 'x' => 8.25,    'y' => 19.5),                         array('w' => 3.5,   'h' => 4.5, 'x' => 11.75,   'y' => 19.5),                         array('w' => 3.5,   'h' => 4.5, 'x' => 15.25,   'y' => 19.5),                          array('w' => 3.5,   'h' => 4.5, 'x' => 1.25,    'y' => 24),                         array('w' => 3.5,   'h' => 4.5, 'x' => 4.75,    'y' => 24),                         array('w' => 3.5,   'h' => 4.5, 'x' => 8.25,    'y' => 24),                         array('w' => 3.5,   'h' => 4.5, 'x' => 11.75,   'y' => 24),                         array('w' => 3.5,   'h' => 4.5, 'x' => 15.25,   'y' => 24),                     ),                 ); 

i'm going guess using ram job. imagecopyresampled has write lot ram job have, , images can take lot of memory. check memory_limit in php.ini file, try increasing , see if can through more/all of images being written canvas. luck!


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -