getEventPath($event); $zm_event_image_digits = Configure::read('ZM_EVENT_IMAGE_DIGITS'); $zm_dir_images = Configure::read('ZM_DIR_IMAGES'); $zm_dir_events = Configure::read('ZM_DIR_EVENTS'); $zm_web_scale_thumbs = Configure::read('ZM_WEB_SCALE_THUMBS'); if (!is_array($frame)) { $frame = array('FrameId' => $frame, 'Type' => ''); } // This is the path to the capture image $captImage = sprintf("%0".$zm_event_image_digits."d-capture.jpg", $frame['FrameId']); $captPath = $eventPath.'/'.$captImage; $thumbCaptPath = $zm_dir_images.'/'.$event['Id'].'-'.$captImage; // This is the path to the analysis image $analImage = sprintf("%0".$zm_event_image_digits."d-analyse.jpg", $frame['FrameId']); $analPath = $eventPath.'/'.$analImage; $analFile = $zm_dir_events.'/'.$analPath; $thumbAnalPath = $zm_dir_images.'/'.$event['Id'].'-'.$captImage; $alarmFrame = $frame['Type'] == 'Alarm'; $hasAnalImage = $alarmFrame && file_exists( $analFile ) && filesize( $analFile ); $isAnalImage = $hasAnalImage && !$captureOnly; if (!$zm_web_scale_thumbs || $scale >= $scale_base || !function_exists('imagecreatefromjpeg')) { $imagePath = $thumbPath = $isAnalImage ? $analPath : $captPath; $imageFile = $zm_dir_events.'/'.$imagePath; $thumbFile = $zm_dir_events.'/'.$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; } $imageFile = $zm_dir_events."/".$imagePath; $thumbFile = $thumbPath; if ( $overwrite || !file_exists( $thumbFile ) || !filesize( $thumbFile ) ) { // Get new dimentions list( $imageWidth, $imageHeight ) = getimagesize( $imageFile ); $thumbWidth = $imageWidth * $fraction; $thumbHeight = $imageHeight * $fraction; // Resample $thumbImage = imagecreatetruecolor( $thumbWidth, $thumbHeight ); $image = imagecreatefromjpeg( $imageFile ); imagecopyresampled( $thumbImage, $image, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imageWidth, $imageHeight ); if ( !imagejpeg( $thumbImage, $thumbFile ) ) { Error( "Can't create thumbnail '$thumbPath'" ); } } } $imageData = array( 'eventPath' => $eventPath, 'imagePath' => $imagePath, 'thumbPath' => $thumbPath, 'imageFile' => $imageFile, 'thumbFile' => $thumbFile, 'imageClass' => $alarmFrame?"alarm":"normal", 'isAnalImage' => $isAnalImage, 'hasAnalImage' => $hasAnalImage ); return($imageData); } }