ob_clcean and flush break outputting the image
parent
97e06bb0fd
commit
f4ddc0fe9b
|
|
@ -69,6 +69,7 @@ if ( empty($_REQUEST['path']) ) {
|
|||
}
|
||||
|
||||
if ( !empty($_REQUEST['eid']) ) {
|
||||
Logger::Debug("Loading by eid");
|
||||
$Event = Event::find_one(array('Id'=>$_REQUEST['eid']));
|
||||
if ( !$Event ) {
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
|
|
@ -119,6 +120,7 @@ Logger::Debug("Got virtual frame from Bulk Frames previous delta: " . $previousB
|
|||
}
|
||||
// Frame can be non-existent. We have Bulk frames. So now we should try to load the bulk frame
|
||||
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
||||
Logger::Debug("Path: $path");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -208,12 +210,14 @@ if ( !empty($_REQUEST['scale']) ) {
|
|||
|
||||
$width = 0;
|
||||
if ( !empty($_REQUEST['width']) ) {
|
||||
Logger::Debug("Setting width: " . $_REQUEST['width']);
|
||||
if ( is_numeric($_REQUEST['width']) ) {
|
||||
$x = $_REQUEST['width'];
|
||||
if ( $x >= 10 and $x <= 8000 )
|
||||
$width = $x;
|
||||
}
|
||||
}
|
||||
|
||||
$height = 0;
|
||||
if ( !empty($_REQUEST['height']) ) {
|
||||
if ( is_numeric($_REQUEST['height']) ) {
|
||||
|
|
@ -229,14 +233,12 @@ if ( $errorText ) {
|
|||
# Clears the output buffer. Not sure what is there, but have had troubles.
|
||||
ob_end_clean();
|
||||
header('Content-type: image/jpeg');
|
||||
if ( ( $scale==0 || $scale==100 ) && $width==0 && $height==0 ) {
|
||||
if ( ( $scale==0 || $scale==100 ) && ($width==0) && ($height==0) ) {
|
||||
# This is so that Save Image As give a useful filename
|
||||
if ( $Event ) {
|
||||
$filename = $Event->MonitorId().'_'.$Event->Id().'_'.$Frame->FrameId().'.jpg';
|
||||
header('Content-Disposition: inline; filename="' . $filename . '"');
|
||||
}
|
||||
ob_clean();
|
||||
flush();
|
||||
if ( !readfile($path) ) {
|
||||
Error('No bytes read from '. $path);
|
||||
}
|
||||
|
|
@ -254,6 +256,7 @@ if ( $errorText ) {
|
|||
$width = ($height * $oldWidth) / $oldHeight;
|
||||
} elseif ( $width != 0 && $height == 0 ) {
|
||||
$height = ($width * $oldHeight) / $oldWidth;
|
||||
Logger::Debug("Figuring out height using width: $height = ($width * $oldHeight) / $oldWidth");
|
||||
}
|
||||
if ( $width == $oldWidth && $height == $oldHeight ) {
|
||||
Warning('No change to width despite scaling.');
|
||||
|
|
@ -266,8 +269,6 @@ if ( $errorText ) {
|
|||
$filename = $Event->MonitorId().'_'.$Event->Id().'_'.$Frame->FrameId()."-${width}x${height}.jpg";
|
||||
header('Content-Disposition: inline; filename="' . $filename . '"');
|
||||
}
|
||||
//ob_clean();
|
||||
//flush();
|
||||
if ( !( file_exists($scaled_path) and readfile($scaled_path) ) ) {
|
||||
Logger::Debug("Cached scaled image does not exist at $scaled_path or is no good.. Creating it");
|
||||
ob_start();
|
||||
|
|
|
|||
Loading…
Reference in New Issue