Splitting a file at a marker
Posted: Fri Jan 22, 2016 9:13 pm
Hi,
Another thing I’m thinking about is taking an MPO file and extracting the two images. An MPO file is a file that contained a number of JPEG files. In this case, it’s a Fuji stereoscopic camera where you get a left and right image in the MPO file.
I know that each JPEG starts with a marker, so I assumed that if I can somehow split the data at those points, I can get the left and right images. I’ve not been able to find any information on how to achieve what I’m thinking about. I have a little code in my stack, which looks like this:
So the MPO file is opened, and the binary data is read in. I am assuming that I can split the binary data using the variable jpegMarker, putting each image’s binary data into an array.
Another thing I’m thinking about is taking an MPO file and extracting the two images. An MPO file is a file that contained a number of JPEG files. In this case, it’s a Fuji stereoscopic camera where you get a left and right image in the MPO file.
I know that each JPEG starts with a marker, so I assumed that if I can somehow split the data at those points, I can get the left and right images. I’ve not been able to find any information on how to achieve what I’m thinking about. I have a little code in my stack, which looks like this:
Code: Select all
command processMPO thisFile
# Open the file
put URL ("binfile:" & thisFile) into theBinaryData
answer length(theBinaryData) -- Returns the size of the file
# look for the JPEG markers - FFD8FFE1
put binaryEncode("H*", "FFD8FFE1") into jpegMarker
answer jpegMarker
split theBinaryData by jpegMarker
answer length(theBinaryData[0]) -- Currently returns 0
answer length(theBinaryData[1]) -- Currently returns 0
end processMPO