The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Image::TestJPG - Test the validity of JPEG image streams.

SYNOPSIS

 use Image::TestJPG;

  # read data from a file
 open(JPEG, "<$file") or die "Can't open $file : $!\n";
 binmode JPEG;
 my $jpgData = do { local $/; <JPEG> };
 close(JPEG);
        
  # test the data
 $rv = Image::TestJPG::testJPG($jpgData, length($jpgData));

  # do something based on the return value
 if($rv) {
  ... jpeg data is valid ...
 }
 else {
  ... jpeg data contains errors ...
 }

DESCRIPTION

 This module provides a single function, testJPG, that will
 quickly decompress a JPEG stream.  If any errors are detected 
 during the decompression process the function returns 0, otherwise 
 it returns 1.

 Image::TestJPG::testJPG(<DATA>, <LENGTH OF DATA>);

 Typical uses of this module would include testing the validity
 of an uploaded jpg image, before storage.

EXPORT

 None by default.

AUTHOR

 Jason Hudgins <jasonlee@spy.net>

COPYRIGHT

 Copyright (c) 2007 Jason Hudgins.  All rights reserved.
 This program is free software; you can redistribute it
 and/or modify it under the same terms as Perl itself.