Re: [PanoToolsNG] incompletely uploaded jpeg and tiff in FTP - how to detect?
- If you can run programs then make a small program to read the header
of the image and see its length
On Thu, Apr 30, 2009 at 11:43 AM, Jeffrey Martin <360cities@...> wrote:
> We're trying to set up an FTP uploading system for images.
> The big issue so far is, how to tell if a file has been completely uploaded.
> For ZIP files, we've solved it.
> Is there a simple way to tell if a JPEG or TIFF file is completely uploaded
> or not?
> [Non-text portions of this message have been removed]
- Yeah, there are a number of ways, depending on the upload process -
1. If you control the uploader tool (probably don't) then you can calculate
a checksum and compare to the uploaded file's checksum... or even just a
2. Use one of a number of tools that will check the consistency of the
formatting - this won't necessarily prove the upload was incomplete... it
could have been damaged prior to upload - but is a good idea any time
you're accepting media files anyway.
exiftool - though not built for this, it's pretty good about error
libjpeg and libtiff both have a variety of tools which will report errors
on parsing those formats - likewise, many tools based on these libraries
(for instance, ImageMagick) will report errors back up to the user based on
parsing problems encountered in the library
jhove - a much more robust/complex tool, but designed for
validating/profiling a wide range of file formats
3. If you want something really simple:
for jpeg: check that the file ends with "FFD9" (in hex) - the only time
that sequence should appear in a JPEG is at the very end
for tiff: check that the file ends with "0000" (in hex) - it's not an "end
of file" marker technically, but, I believe, all TIFFs should end with it
IIRC; of course it's quite possible for a TIFF to contain "0000" elsewhere
in the file, so this isn't a guarantee - but if the file DOESN'T end with
0000 you can be sure it's incomplete.