Thumb Image in Eventlist

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
malvo
Posts: 6
Joined: Wed Apr 14, 2004 6:38 pm
Location: GER,Brunsvik

Thumb Image in Eventlist

Post by malvo »

I added a thumb view to the list of events, have not yet tested it over a slow connection

here's a diff:

Code: Select all

diff zm_html_view_events.php /usr/local/src/zm-1.19.1/web/zm_html_view_events.php

< $events_sql = "select E.Id,E.MonitorId,M.Name As MonitorName,M.Width,M.Height,E.Name,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived,E.LearnState from Monitors as M inner join Events as E on (M.Id = E.MonitorId) where";
---
> $events_sql = "select E.Id,E.MonitorId,M.Name As MonitorName,E.Name,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived,E.LearnState from Monitors as M inner join Events as E on (M.Id = E.MonitorId) where";
295,335d294
< <?php
< 	$scale = IMAGE_SCALING;
< 	$fraction = sprintf( "%.2f", 1/$scale );
< 	$thumb_width = $event['Width']/4;
< 	$thumb_height = $event['Height']/4;
< 	$event_path = ZM_DIR_EVENTS.'/'.$event['MonitorName'].'/'.$event['Id'];
< 	$frame_id = 11;#$lo_frame_id;
< 	$image_path = sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", $event_path, $frame_id );
< 
< 	$capt_image = $image_path;
< 	if ( $scale == 1 || !file_exists( ZM_PATH_NETPBM."/jpegtopnm" ) )
< 	{
< 		$anal_image = preg_replace( "/capture/", "analyse", $image_path );
< 
< 		if ( file_exists($anal_image) && filesize( $anal_image ) )
< 		{
< 			$thumb_image = $anal_image;
< 		}
< 		else
< 		{
< 			$thumb_image = $capt_image;
< 		}
< 	}
< 	else
< 	{
< 		$thumb_image = preg_replace( "/capture/", "thumb", $capt_image );
< 
< 		if ( !file_exists($thumb_image) || !filesize( $thumb_image ) )
< 		{
< 			$anal_image = preg_replace( "/capture/", "analyse", $capt_image );
< 			if ( file_exists( $anal_image ) )
< 				$command = ZM_PATH_NETPBM."/jpegtopnm -dct fast $anal_image | ".ZM_PATH_NETPBM."/pnmscalefixed $fraction | ".ZM_PATH_NETPBM."/ppmtojpeg --dct=fast > $thumb_image";
< 			else
< 				$command = ZM_PATH_NETPBM."/jpegtopnm -dct fast $capt_image | ".ZM_PATH_NETPBM."/pnmscalefixed $fraction | ".ZM_PATH_NETPBM."/ppmtojpeg --dct=fast > $thumb_image";
< 			#exec( escapeshellcmd( $command ) );
< 			exec( $command );
< 		}
< 	}
< 
< ?>
< <td align="center" class="text"><img src="<?= $thumb_image ?>" width="<?= $thumb_width ?>" height="<?= $thumb_height ?>" class="<?= $img_class ?>" alt="<?= $frame_id ?>/<?= $alarm_frame?$alarm_frame['Score']:0 ?>"></td>
Post Reply