Is a file an image?

Jim Bufalini jim at visitrieve.com
Wed Jan 27 07:15:18 EST 2010


I just love seeing solutions like this. ;-)

Aloha from Hawaii,

Jim Bufalini


Jan Schenkel wrote:
> 
> David Bovill wrote:
> > I've just dug out this very old and
> > pretty untested script for detecting
> > whether a file is an image. Seems to sort of work on OSX -
> > included here for
> > insiration :) Does anyone know a better way to do this?
> >
> 
> Why go through the trouble of checking the extension and the content of
> the file, when you can let Rev decide if it supports that particular
> file as a valid image? :-)
> 
> Make a new stack with a button with the following script:
> ##
> on mouseUp
>    answer file "Pick an image file"
>    if the result is "Cancel" then exit mouseUp
>    answer "Is a supported image format:" && IsAnImageFile(it)
> end mouseUp
> 
> function IsAnImageFile pFilePath
>    local tIsAnImageFile
>    --
>    lock screen
>    create image
>    set the filename of the last image to pFilePath
>    --> if the set fails, the result will tell you
>    put (the result is empty) into tIsAnImageFile
>    delete the last image
>    return tIsAnImageFile
> end IsAnImageFile
> ##
> 
> Click the button, select an image file, and it should be 'true' -
> select a Word document or something else that is definitely not an
> image, and yous should see 'false'.
> 
> Cheers,
> 
> Jan Schenkel
> =====
> Quartam Reports & PDF Library for Revolution
> <http://www.quartam.com>
> 
> =====
> "As we grow older, we grow both wiser and more foolish at the same
> time."  (La Rochefoucauld)
> 
> 
> 
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list