/**
  * Create a new stacktrace instance from a backtrace.
  *
  * @param Bugsnag_Configuration $config    the configuration instance
  * @param array                 $backtrace the associated backtrace
  * @param int                   $topFile   the top file to use
  * @param int                   $topLine   the top line to use
  *
  * @return self
  */
 public static function fromBacktrace($config, $backtrace, $topFile, $topLine)
 {
     $stacktrace = new self($config);
     // PHP backtrace's are misaligned, we need to shift the file/line down a frame
     foreach ($backtrace as $frame) {
         if (!self::frameInsideBugsnag($frame)) {
             $stacktrace->addFrame($topFile, $topLine, isset($frame['function']) ? $frame['function'] : null, isset($frame['class']) ? $frame['class'] : null);
         }
         if (isset($frame['file']) && isset($frame['line'])) {
             $topFile = $frame['file'];
             $topLine = $frame['line'];
         } else {
             $topFile = '[internal]';
             $topLine = 0;
         }
     }
     // Add a final stackframe for the "main" method
     $stacktrace->addFrame($topFile, $topLine, '[main]');
     return $stacktrace;
 }
Example #2
0
 public static function initFromDecoded(Decoded $decoded)
 {
     $container = new self();
     $container->setLoops($decoded->getLoops());
     // create empty canvas
     $driver = new Driver();
     $canvas = $driver->newImage($decoded->getCanvasWidth(), $decoded->getCanvasHeight())->getCore();
     foreach ($decoded->getFrames() as $key => $frame) {
         // create resource from frame
         $encoder = new GifEncoder();
         $encoder->setFromDecoded($decoded, $key);
         $frame_resource = imagecreatefromstring($encoder->encode());
         // insert frame image data into canvas
         imagecopy($canvas, $frame_resource, $frame->getOffset()->left, $frame->getOffset()->top, 0, 0, $frame->getSize()->width, $frame->getSize()->height);
         // destory frame resource
         imagedestroy($frame_resource);
         // add frame to container
         $container->addFrame(new \Intervention\Image\Frame($canvas, $frame->getDelay()));
         // prepare next canvas
         $canvas = Helper::cloneResource($canvas);
     }
     return $container;
 }
Example #3
0
 /**
  * Creates a new animated gif object from a selection of files.
  *
  * @access public
  * @author Oliver Lillie
  * @param string $file_paths 
  * @param string $frame_delay 
  * @param string $loop_count 
  * @return mixed Returns an AnimatedGif object on success, otherwise returns false.
  */
 public static function createFrom(array $image_object_array, $frame_delay, $loop_count = self::UNLIMITED_LOOPS, Config $config = null)
 {
     if (empty($image_object_array) === true) {
         throw new Exception('At least one file path must be specified when creating an animated gif from AnimatedGif::createFrom.');
     }
     if ($frame_delay <= 0) {
         throw new Exception('The frame delay must be greater than 0.');
     }
     //			create a new gif and add all the frames.
     $gif = new self(null, $config);
     foreach ($image_object_array as $key => $image) {
         if (is_object($image) === false || get_class($image) !== 'PHPVideoToolkit\\Image') {
             throw new Exception('The image at key ' . $key . ' is not an \\PHPVideoToolkit\\Image object. Each frame must be an Image object.');
         }
         $gif->addFrame($image, $frame_delay);
     }
     //			set the loop count
     $gif->setLoopCount($loop_count);
     return $gif;
 }