From 5ee8a1c0a7a6d30f3cd39d70c803ca2c6fb45350 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 Oct 2016 11:52:01 -0400 Subject: [PATCH] deprecate the contents of getImageSrc since it is now in Event.php --- web/includes/functions.php | 98 +------------------------------------- 1 file changed, 1 insertion(+), 97 deletions(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index 729b59482..9a510b6a6 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -984,104 +984,8 @@ function zmaCheck( $monitor ) { } function getImageSrc( $event, $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) { - $Storage = new Storage( $event['StorageId'] ); $Event = new Event( $event ); - $eventPath = $Event->Path(); - - if ( !is_array($frame) ) - $frame = array( 'FrameId'=>$frame, 'Type'=>'' ); - - if ( file_exists( $eventPath.'/snapshot.jpg' ) ) { - $captImage = "snapshot.jpg"; - } else { - $captImage = sprintf( "%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", $frame['FrameId'] ); - if ( ! file_exists( $eventPath.'/'.$captImage ) ) { -# Generate the frame JPG - if ( $Event->DefaultVideo() ) { - $command ='ffmpeg -v 0 -i '.$eventPath.'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$frame['FrameId'].'),setpts=PTS-STARTPTS" '.$eventPath.'/'.$captImage; - Debug( "Running $command" ); - $output = array(); - $retval = 0; - exec( $command, $output, $retval ); - Debug("Retval: $retval, output: " . implode("\n", $output)); - } else { - Error("Can't create frame images from video becuase there is no video file for this event (".$Event->DefaultVideo() ); - } - } - } - - $captPath = $eventPath.'/'.$captImage; - if ( ! file_exists( $captPath ) ) { - Error( "Capture file does not exist at $captPath" ); - return ''; - } - $thumbCaptPath = ZM_DIR_IMAGES.'/'.$event['Id'].'-'.$captImage; - - //echo "CI:$captImage, CP:$captPath, TCP:$thumbCaptPath
"; - - $analImage = sprintf( "%0".ZM_EVENT_IMAGE_DIGITS."d-analyse.jpg", $frame['FrameId'] ); - $analPath = $eventPath.'/'.$analImage; - - $thumbAnalPath = ZM_DIR_IMAGES.'/'.$event['Id'].'-'.$analImage; - //echo "AI:$analImage, AP:$analPath, TAP:$thumbAnalPath
"; - - $alarmFrame = $frame['Type']=='Alarm'; - - $hasAnalImage = $alarmFrame && file_exists( $analPath ) && filesize( $analPath ); - $isAnalImage = $hasAnalImage && !$captureOnly; - - if ( !ZM_WEB_SCALE_THUMBS || $scale >= SCALE_BASE || !function_exists( 'imagecreatefromjpeg' ) ) { - $imagePath = $thumbPath = $isAnalImage?$analPath:$captPath; - $imageFile = $imagePath; - $thumbFile = $thumbPath; - } else { - if ( version_compare( phpversion(), "4.3.10", ">=") ) - $fraction = sprintf( "%.3F", $scale/SCALE_BASE ); - else - $fraction = sprintf( "%.3f", $scale/SCALE_BASE ); - $scale = (int)round( $scale ); - - $thumbCaptPath = preg_replace( "/\.jpg$/", "-$scale.jpg", $thumbCaptPath ); - $thumbAnalPath = preg_replace( "/\.jpg$/", "-$scale.jpg", $thumbAnalPath ); - - if ( $isAnalImage ) { - $imagePath = $analPath; - $thumbPath = $thumbAnalPath; - } else { - $imagePath = $captPath; - $thumbPath = $thumbCaptPath; - } - - $thumbFile = $thumbPath; - if ( $overwrite || !file_exists( $thumbFile ) || !filesize( $thumbFile ) ) - { - // Get new dimensions - list( $imageWidth, $imageHeight ) = getimagesize( $imagePath ); - $thumbWidth = $imageWidth * $fraction; - $thumbHeight = $imageHeight * $fraction; - - // Resample - $thumbImage = imagecreatetruecolor( $thumbWidth, $thumbHeight ); - $image = imagecreatefromjpeg( $imagePath ); - imagecopyresampled( $thumbImage, $image, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imageWidth, $imageHeight ); - - if ( !imagejpeg( $thumbImage, $thumbPath ) ) - Error( "Can't create thumbnail '$thumbPath'" ); - } - } - - $imageData = array( - 'eventPath' => $eventPath, - 'imagePath' => $imagePath, - 'thumbPath' => $thumbPath, - 'imageFile' => $imagePath, - 'thumbFile' => $thumbFile, - 'imageClass' => $alarmFrame?"alarm":"normal", - 'isAnalImage' => $isAnalImage, - 'hasAnalImage' => $hasAnalImage, - ); - - return( $imageData ); + return $Event->getImageSrc( $frame, $scale, $captureOnly, $overwrite ); } function viewImagePath( $path, $querySep='&' ) {