Re: HI Can u help me
On Sun, 6 Oct 2002 14:18:53 -0300, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: Hello Is there a function to test if a given.jpg file is a valid jpg file? thanks You can use the ping method of Image:Majick and test whether it gives an error. ## #!/usr/bin/perl -w use Image::Magick; my $x = $ARGV[0]; my $image; $image = Image::Magick-new; ($width, $height, $size, $format) = $image-Ping($x); print $width,\n, $height,\n ,$size,\n, $format,\n; # -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: HI Can u help me
[EMAIL PROTECTED] wrote: Hello Is there a function to test if a given.jpg file is a valid jpg file? thanks if you don't want to install/load another module, try: #!/usr/bin/perl -w use strict; if(is_jpeg('your file')){ print it's a valie jpeg\n; }else{ print doesn't look like a jpeg\n; } sub is_jpeg{ my $jpeg_file = shift; my $id = undef; open(JPEG,$jpeg_file) || croak(Unable to open $jpeg_file: $!); sysread(JPEG,$id,6); sysread(JPEG,$id,5); my($j,$p,$e,$g,$z) = unpack(C,$id); close(JPEG); return $j == 74 $p == 70 $e == 73 $g == 70 $z == 0; } __END__ david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
HI Can u help me
Hello Is there a function to test if a given.jpg file is a valid jpg file? thanks