Changed 100's to SCALE_BASE where appropriate

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2386 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2008-04-15 13:35:20 +00:00
parent 2549d98d1f
commit d2c3591925
3 changed files with 10 additions and 11 deletions

View File

@ -1005,16 +1005,16 @@ function getImageSrc( $event, $frame, $scale, $capture_only=false, $overwrite=fa
$has_anal_image = $alarm_frame && file_exists( $anal_path ) && filesize( $anal_path ); $has_anal_image = $alarm_frame && file_exists( $anal_path ) && filesize( $anal_path );
$is_anal_image = $has_anal_image && !$capture_only; $is_anal_image = $has_anal_image && !$capture_only;
if ( $scale >= 100 || !file_exists( ZM_PATH_NETPBM."/jpegtopnm" ) ) if ( $scale >= SCALE_BASE || !file_exists( ZM_PATH_NETPBM."/jpegtopnm" ) )
{ {
$image_path = $thumb_path = $is_anal_image?$anal_path:$capt_path; $image_path = $thumb_path = $is_anal_image?$anal_path:$capt_path;
} }
else else
{ {
if ( version_compare( phpversion(), "4.3.10", ">=") ) if ( version_compare( phpversion(), "4.3.10", ">=") )
$fraction = sprintf( "%.3F", $scale/100 ); $fraction = sprintf( "%.3F", $scale/SCALE_BASE );
else else
$fraction = sprintf( "%.3f", $scale/100 ); $fraction = sprintf( "%.3f", $scale/SCALE_BASE );
$scale = (int)round( $scale ); $scale = (int)round( $scale );
$thumb_capt_path = preg_replace( "/\.jpg$/", "-$scale.jpg", $thumb_capt_path ); $thumb_capt_path = preg_replace( "/\.jpg$/", "-$scale.jpg", $thumb_capt_path );
@ -1112,7 +1112,7 @@ function createImage( $monitor, $scale )
} }
chdir( ZM_DIR_IMAGES ); chdir( ZM_DIR_IMAGES );
$command = getZmuCommand( " -m $monitor -i" ); $command = getZmuCommand( " -m $monitor -i" );
if ( !empty($scale) && $scale < 100 ) if ( !empty($scale) && $scale < SCALE_BASE )
$command .= " -S $scale"; $command .= " -S $scale";
$status = exec( escapeshellcmd( $command ) ); $status = exec( escapeshellcmd( $command ) );
chdir( '..' ); chdir( '..' );

View File

@ -223,9 +223,9 @@ $scale = getDeviceScale( $event['Width'], $event['Height'], $frames_per_line );
$count = 0; $count = 0;
if ( version_compare( phpversion(), "4.3.10", ">=") ) if ( version_compare( phpversion(), "4.3.10", ">=") )
$fraction = sprintf( "%.2F", $scale/100 ); $fraction = sprintf( "%.2F", $scale/SCALE_BASE );
else else
$fraction = sprintf( "%.2f", $scale/100 ); $fraction = sprintf( "%.2f", $scale/SCALE_BASE );
$event_path = getEventPath( $event ); $event_path = getEventPath( $event );
for ( $frame_id = $lo_frame_id; $frame_id <= $hi_frame_id; $frame_id++, $count++ ) for ( $frame_id = $lo_frame_id; $frame_id <= $hi_frame_id; $frame_id++, $count++ )
{ {
@ -239,7 +239,7 @@ for ( $frame_id = $lo_frame_id; $frame_id <= $hi_frame_id; $frame_id++, $count++
$image_path = sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", $event_path, $frame_id ); $image_path = sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", $event_path, $frame_id );
$capt_image = $image_path; $capt_image = $image_path;
if ( $scale == 1 || !file_exists( ZM_PATH_NETPBM."/jpegtopnm" ) ) if ( $scale == SCALE_BASE || !file_exists( ZM_PATH_NETPBM."/jpegtopnm" ) )
{ {
$anal_image = preg_replace( "/capture/", "analyse", $image_path ); $anal_image = preg_replace( "/capture/", "analyse", $image_path );
@ -263,7 +263,6 @@ for ( $frame_id = $lo_frame_id; $frame_id <= $hi_frame_id; $frame_id++, $count++
$command = ZM_PATH_NETPBM."/jpegtopnm -dct fast $anal_image | ".ZM_PATH_NETPBM."/pnmscalefixed $fraction | ".ZM_PATH_NETPBM."/ppmtojpeg --dct=fast > $thumb_image"; $command = ZM_PATH_NETPBM."/jpegtopnm -dct fast $anal_image | ".ZM_PATH_NETPBM."/pnmscalefixed $fraction | ".ZM_PATH_NETPBM."/ppmtojpeg --dct=fast > $thumb_image";
else else
$command = ZM_PATH_NETPBM."/jpegtopnm -dct fast $capt_image | ".ZM_PATH_NETPBM."/pnmscalefixed $fraction | ".ZM_PATH_NETPBM."/ppmtojpeg --dct=fast > $thumb_image"; $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 ); exec( $command );
} }
} }

View File

@ -51,7 +51,7 @@ function getThumbnail( $event, $fid, $scale )
} }
$alarm_frame = $frame['Type']=='Alarm'; $alarm_frame = $frame['Type']=='Alarm';
if ( $scale == 100 || !file_exists( ZM_PATH_NETPBM."/jpegtopnm" ) ) if ( $scale == SCALE_BASE || !file_exists( ZM_PATH_NETPBM."/jpegtopnm" ) )
{ {
$thumb_image = $image_path; $thumb_image = $image_path;
} }
@ -62,9 +62,9 @@ function getThumbnail( $event, $fid, $scale )
if ( !file_exists($thumb_image) || !filesize( $thumb_image ) ) if ( !file_exists($thumb_image) || !filesize( $thumb_image ) )
{ {
if ( version_compare( phpversion(), "4.3.10", ">=") ) if ( version_compare( phpversion(), "4.3.10", ">=") )
$fraction = sprintf( "%.2F", $scale/100 ); $fraction = sprintf( "%.2F", $scale/SCALE_BASE );
else else
$fraction = sprintf( "%.2f", $scale/100 ); $fraction = sprintf( "%.2f", $scale/SCALE_BASE );
if ( file_exists( $image_path ) ) if ( file_exists( $image_path ) )
{ {
$command = ZM_PATH_NETPBM."/jpegtopnm -dct fast $image_path | ".ZM_PATH_NETPBM."/pnmscalefixed $fraction | ".ZM_PATH_NETPBM."/ppmtojpeg --dct=fast > $thumb_image"; $command = ZM_PATH_NETPBM."/jpegtopnm -dct fast $image_path | ".ZM_PATH_NETPBM."/pnmscalefixed $fraction | ".ZM_PATH_NETPBM."/ppmtojpeg --dct=fast > $thumb_image";