Loading extract_images_tiff.php +17 −4 Original line number Original line Diff line number Diff line Loading @@ -32,9 +32,8 @@ Found problem - does not process files that start in one file and end in another define('MIN_JP_LEN', 0x500); // skip from jpeg looking for end marker define('MIN_JP_LEN', 0x500); // skip from jpeg looking for end marker define('MAX_IMG_LEN', 0x1000000); // maximal image size (16M) to look for the end marker define('MAX_IMG_LEN', 0x1000000); // maximal image size (16M) to look for the end marker define('REQUIRE_EXIF', 1); // JPEG/JP4 must have Exif (more filtering, less false positives) define('REQUIRE_EXIF', 1); // JPEG/JP4 must have Exif (more filtering, less false positives) //define('DEBUG_LEVEL', 3); // Generate debug output define('DEBUG_LEVEL', 0); //3); // Generate debug output //define('DEBUG_OUT_FILES',DEBUG_LEVEL? 1 : 0 ); // 1 to add sequence number to result image names (make all unique) //define('DEBUG_OUT_FILES',DEBUG_LEVEL? 1 : 0 ); // 1 to add sequence number to result image names (make all unique) define('DEBUG_LEVEL', 1); // Generate debug output define('DEBUG_OUT_FILES',DEBUG_LEVEL? 0 : 0 ); // 1 to add sequence number to result image names (make all unique) define('DEBUG_OUT_FILES',DEBUG_LEVEL? 0 : 0 ); // 1 to add sequence number to result image names (make all unique) //disable the default time limit for php scripts. //disable the default time limit for php scripts. set_time_limit(0); set_time_limit(0); Loading Loading @@ -270,6 +269,9 @@ function split_file($path, $file, $destination, $add_to_chn = - 1, $next_file = } } } } fseek($f, $markers[$i]); fseek($f, $markers[$i]); if ((DEBUG_LEVEL >= 1)) { printf("marker: %6d, position 0x%x\n",$i,$markers[$i]); } $s = fread($f, $markers[$i + 1] - $markers[$i]); $s = fread($f, $markers[$i + 1] - $markers[$i]); if ((DEBUG_LEVEL >= 2)) { if ((DEBUG_LEVEL >= 2)) { if (($i == (count($markers) - 2)) || ($i == 0)) { if (($i == (count($markers) - 2)) || ($i == 0)) { Loading Loading @@ -313,6 +315,17 @@ function split_file($path, $file, $destination, $add_to_chn = - 1, $next_file = } } } else if ($file_type == 1) { // Tiff } else if ($file_type == 1) { // Tiff // read continuation if needed //$s = fread($f, $markers[$i + 1] - $markers[$i]); if ((strlen($s) < $markers[$i + 1] - $markers[$i]) && $next_path) { $f1 = fopen($next_path, "r"); $s .= fread($f1, $markers[$i + 1] - $markers[$i] - strlen($s)); // beginning of the next file fclose($f1); if (DEBUG_LEVEL >= 0) { printf("Got continuation of the image from the next file %s\n", $next_path); } } // file_put_contents($tmp_name,$s); // file_put_contents($tmp_name,$s); file_put_contents($tmp_name, substr($s, 0, MAX_HEAD_LEN)); // only save beginning of the file file_put_contents($tmp_name, substr($s, 0, MAX_HEAD_LEN)); // only save beginning of the file // printf ("header length = %d\n", strlen(substr($s, 0, MAX_HEAD_LEN))); // printf ("header length = %d\n", strlen(substr($s, 0, MAX_HEAD_LEN))); Loading @@ -328,7 +341,7 @@ function split_file($path, $file, $destination, $add_to_chn = - 1, $next_file = } } // rename($tmp_name, $dest_image); // "$path/$destination/$result_name"); // rename($tmp_name, $dest_image); // "$path/$destination/$result_name"); file_put_contents($dest_image, substr($s, 0, $image_length)); file_put_contents($dest_image, substr($s, 0, $image_length)); if ((DEBUG_LEVEL >= 2)) { if (DEBUG_LEVEL >= 2) { if ($i == 0) { if ($i == 0) { file_put_contents($dest_image . ".test", substr($s, 0, $image_length)); file_put_contents($dest_image . ".test", substr($s, 0, $image_length)); printf("2.First image[%d] from img file - %s, length=0x%08x(%d), strlen(s)=%d (%d)\n", $i, $dest_image, $image_length, $image_length, strlen($s), strlen(substr($s, 0, $image_length))); printf("2.First image[%d] from img file - %s, length=0x%08x(%d), strlen(s)=%d (%d)\n", $i, $dest_image, $image_length, $image_length, strlen($s), strlen(substr($s, 0, $image_length))); Loading Loading
extract_images_tiff.php +17 −4 Original line number Original line Diff line number Diff line Loading @@ -32,9 +32,8 @@ Found problem - does not process files that start in one file and end in another define('MIN_JP_LEN', 0x500); // skip from jpeg looking for end marker define('MIN_JP_LEN', 0x500); // skip from jpeg looking for end marker define('MAX_IMG_LEN', 0x1000000); // maximal image size (16M) to look for the end marker define('MAX_IMG_LEN', 0x1000000); // maximal image size (16M) to look for the end marker define('REQUIRE_EXIF', 1); // JPEG/JP4 must have Exif (more filtering, less false positives) define('REQUIRE_EXIF', 1); // JPEG/JP4 must have Exif (more filtering, less false positives) //define('DEBUG_LEVEL', 3); // Generate debug output define('DEBUG_LEVEL', 0); //3); // Generate debug output //define('DEBUG_OUT_FILES',DEBUG_LEVEL? 1 : 0 ); // 1 to add sequence number to result image names (make all unique) //define('DEBUG_OUT_FILES',DEBUG_LEVEL? 1 : 0 ); // 1 to add sequence number to result image names (make all unique) define('DEBUG_LEVEL', 1); // Generate debug output define('DEBUG_OUT_FILES',DEBUG_LEVEL? 0 : 0 ); // 1 to add sequence number to result image names (make all unique) define('DEBUG_OUT_FILES',DEBUG_LEVEL? 0 : 0 ); // 1 to add sequence number to result image names (make all unique) //disable the default time limit for php scripts. //disable the default time limit for php scripts. set_time_limit(0); set_time_limit(0); Loading Loading @@ -270,6 +269,9 @@ function split_file($path, $file, $destination, $add_to_chn = - 1, $next_file = } } } } fseek($f, $markers[$i]); fseek($f, $markers[$i]); if ((DEBUG_LEVEL >= 1)) { printf("marker: %6d, position 0x%x\n",$i,$markers[$i]); } $s = fread($f, $markers[$i + 1] - $markers[$i]); $s = fread($f, $markers[$i + 1] - $markers[$i]); if ((DEBUG_LEVEL >= 2)) { if ((DEBUG_LEVEL >= 2)) { if (($i == (count($markers) - 2)) || ($i == 0)) { if (($i == (count($markers) - 2)) || ($i == 0)) { Loading Loading @@ -313,6 +315,17 @@ function split_file($path, $file, $destination, $add_to_chn = - 1, $next_file = } } } else if ($file_type == 1) { // Tiff } else if ($file_type == 1) { // Tiff // read continuation if needed //$s = fread($f, $markers[$i + 1] - $markers[$i]); if ((strlen($s) < $markers[$i + 1] - $markers[$i]) && $next_path) { $f1 = fopen($next_path, "r"); $s .= fread($f1, $markers[$i + 1] - $markers[$i] - strlen($s)); // beginning of the next file fclose($f1); if (DEBUG_LEVEL >= 0) { printf("Got continuation of the image from the next file %s\n", $next_path); } } // file_put_contents($tmp_name,$s); // file_put_contents($tmp_name,$s); file_put_contents($tmp_name, substr($s, 0, MAX_HEAD_LEN)); // only save beginning of the file file_put_contents($tmp_name, substr($s, 0, MAX_HEAD_LEN)); // only save beginning of the file // printf ("header length = %d\n", strlen(substr($s, 0, MAX_HEAD_LEN))); // printf ("header length = %d\n", strlen(substr($s, 0, MAX_HEAD_LEN))); Loading @@ -328,7 +341,7 @@ function split_file($path, $file, $destination, $add_to_chn = - 1, $next_file = } } // rename($tmp_name, $dest_image); // "$path/$destination/$result_name"); // rename($tmp_name, $dest_image); // "$path/$destination/$result_name"); file_put_contents($dest_image, substr($s, 0, $image_length)); file_put_contents($dest_image, substr($s, 0, $image_length)); if ((DEBUG_LEVEL >= 2)) { if (DEBUG_LEVEL >= 2) { if ($i == 0) { if ($i == 0) { file_put_contents($dest_image . ".test", substr($s, 0, $image_length)); file_put_contents($dest_image . ".test", substr($s, 0, $image_length)); printf("2.First image[%d] from img file - %s, length=0x%08x(%d), strlen(s)=%d (%d)\n", $i, $dest_image, $image_length, $image_length, strlen($s), strlen(substr($s, 0, $image_length))); printf("2.First image[%d] from img file - %s, length=0x%08x(%d), strlen(s)=%d (%d)\n", $i, $dest_image, $image_length, $image_length, strlen($s), strlen(substr($s, 0, $image_length))); Loading