print("None of TIFF (".bin2hex(START_TIFF).") or JP4/JPEG (".bin2hex(START_JP).") markers found in the first ".$chunksize." bytes of the file $path/$file\n");
return-1;
}
if($pos_jp===false){
$file_type=1;// tiff
}elseif(($pos_tiff!==false)&&($pos_tiff<$pos_jp)){// reducing probability of stray START_JP
printf("Wrong image length from Exif header: %d",$image_length);
$f=fopen("$path/$file","r");
exit(1);
}
$s=fread($f,$chunksize);
$dest_image="$path/$destination/$result_name";// $result_name may now include "/"
$pos_jp=strpos($s,START_JP);
$dest_set_dir=dirname($dest_image);
$pos_tiff=strpos($s,START_TIFF);
if(!is_dir($dest_set_dir)){
if(($pos_jp===false)&&($pos_tiff===false)){
mkdir($dest_set_dir,0777);
if(strlen($s)==$chunksize){
}
print("None of TIFF (".bin2hex(START_TIFF).") or JP4/JPEG (".bin2hex(START_JP).") markers found in the first ".$chunksize." bytes of the file $path/$file\n");
print("None of TIFF (".bin2hex(START_TIFF).") or JP4/JPEG (".bin2hex(START_JP).") markers found in the remaining ".strlen($s)." bytes of the file $path/$file\n");
}
return-1;
}
if($pos_jp===false){
$file_type=1;// tiff
}elseif(($pos_tiff!==false)&&($pos_tiff<$pos_jp)){// reducing probability of stray START_JP
$end_pos=strpos($s,END_JP,MIN_JP_LEN);// PHP Warning: strpos(): Offset not contained in string in /home/elphel/git/elphel-tools-x393/extract_images_tiff.php on line 254
}
if(!$end_pos&&$next_path){// try reading from the next file define('MAX_IMG_LEN', 0x1000000); // maximal image size (16M) to look for the end marker
$f1=fopen($next_path,"r");
$s.=fread($f1,MAX_IMG_LEN);// beginning of the next file
fclose($f1);
$end_pos=strpos($s,END_JP,MIN_JP_LEN);// PHP Warning: strpos(): Offset not contained in string in /home/elphel/git/elphel-tools-x393/extract_images_tiff.php on line 254
if($end_pos&&(DEBUG_LEVEL>=1)){
printf("Found image continued in the next file %s\n",$next_path);