deprecate the contents of getImageSrc since it is now in Event.php

This commit is contained in:
Isaac Connor 2016-10-20 11:52:01 -04:00
parent fc540786a5
commit 5ee8a1c0a7
1 changed files with 1 additions and 97 deletions

View File

@ -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<br>";
$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<br>";
$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='&amp;' ) {