Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-tools-x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-tools-x393
Commits
b46a9a1d
Commit
b46a9a1d
authored
Jun 29, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trimming images according to exif lengths form the 0-padded raw data
parent
ff5ea51b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
extract_images_tiff.php
extract_images_tiff.php
+16
-8
No files found.
extract_images_tiff.php
View file @
b46a9a1d
...
@@ -25,6 +25,7 @@ Found problem - does not process files that start in one chunk and end in anothe
...
@@ -25,6 +25,7 @@ Found problem - does not process files that start in one chunk and end in anothe
*/
*/
define
(
'START_TIFF'
,
hex2bin
(
'4d4d002a'
));
// start of a TIFF, JP/JP4 also have this TIFF marker
define
(
'START_TIFF'
,
hex2bin
(
'4d4d002a'
));
// start of a TIFF, JP/JP4 also have this TIFF marker
define
(
'START_JP'
,
hex2bin
(
'ffd8ffe1'
));
// start of JPEG/JP4, TIFF usually does not have JPEG/JP4 markers
define
(
'START_JP'
,
hex2bin
(
'ffd8ffe1'
));
// start of JPEG/JP4, TIFF usually does not have JPEG/JP4 markers
define
(
'MAX_HEAD_LEN'
,
0x300
);
// maximal header length that includes complete header
//disable the default time limit for php scripts.
//disable the default time limit for php scripts.
set_time_limit
(
0
);
set_time_limit
(
0
);
...
@@ -205,16 +206,23 @@ function split_file($path,$file,$destination,$add_to_chn=-1){
...
@@ -205,16 +206,23 @@ function split_file($path,$file,$destination,$add_to_chn=-1){
fseek
(
$f
,
$markers
[
$i
]);
fseek
(
$f
,
$markers
[
$i
]);
$s
=
fread
(
$f
,
$markers
[
$i
+
1
]
-
$markers
[
$i
]);
$s
=
fread
(
$f
,
$markers
[
$i
+
1
]
-
$markers
[
$i
]);
$tmp_name
=
"
$path
/
$destination
/image.tmp"
;
$tmp_name
=
"
$path
/
$destination
/header.tmp"
;
// image.tmp";
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
$result_name
=
elphel_specific_result_name
(
$tmp_name
,
$add_to_chn
);
// printf ("header length = %d\n", strlen(substr($s, 0, MAX_HEAD_LEN)));
$image_length
=-
1
;
$result_name
=
elphel_specific_result_name
(
$tmp_name
,
$image_length
,
$add_to_chn
);
if
(
$image_length
<
0
){
printf
(
"Wrong image length from Exif header: %d"
,
$image_length
);
exit
(
1
);
}
$dest_image
=
"
$path
/
$destination
/
$result_name
"
;
// $result_name may now include "/"
$dest_image
=
"
$path
/
$destination
/
$result_name
"
;
// $result_name may now include "/"
$dest_set_dir
=
dirname
(
$dest_image
);
$dest_set_dir
=
dirname
(
$dest_image
);
if
(
!
is_dir
(
$dest_set_dir
)){
if
(
!
is_dir
(
$dest_set_dir
)){
mkdir
(
$dest_set_dir
,
0777
);
mkdir
(
$dest_set_dir
,
0777
);
}
}
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
));
}
}
return
0
;
return
0
;
...
@@ -224,8 +232,7 @@ function split_file($path,$file,$destination,$add_to_chn=-1){
...
@@ -224,8 +232,7 @@ function split_file($path,$file,$destination,$add_to_chn=-1){
}
}
function
elphel_specific_result_name
(
$file
,
$add_to_chn
=-
10
){
function
elphel_specific_result_name
(
$file
,
&
$image_length
,
$add_to_chn
=-
10
){
global
$forced_ext
;
global
$forced_ext
;
// $add_to_chn<0 - do not use it and do not use scene directories
// $add_to_chn<0 - do not use it and do not use scene directories
$use_scene_dirs
=
$add_to_chn
>=
0
;
$use_scene_dirs
=
$add_to_chn
>=
0
;
...
@@ -234,7 +241,8 @@ function elphel_specific_result_name($file,$add_to_chn=-10){
...
@@ -234,7 +241,8 @@ function elphel_specific_result_name($file,$add_to_chn=-10){
}
}
$exif
=
exif_read_data
(
$file
);
// gets false find, what is wrong
$exif
=
exif_read_data
(
$file
);
// gets false find, what is wrong
// image size = ([StripOffsets] => 557)+ ([StripByteCounts] => 656640)
$image_length
=
intval
(
$exif
[
'StripOffsets'
])
+
intval
(
$exif
[
'StripByteCounts'
]);
$ext
=
elphel_specific_result_ext
(
$exif
,
$forced_ext
);
$ext
=
elphel_specific_result_ext
(
$exif
,
$forced_ext
);
//converting GMT a local time GMT+7
//converting GMT a local time GMT+7
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment