Invalid Image File / Original Image Size
phil at pdslabs.net
Mon Feb 17 16:57:52 EST 2020
Certainly Klaus's approach will work. Here is another that works.
As you know, image files have "signatures" in their headers to identify
what kind of files they are:
(the "ISO 8859-1" column)
Once you know the signatures of the image file types you want to allow,
you could do something like this:
answer file "Pick an image file:"
if it is empty then exit to top
function isSupportedImage pPath
# Allow JPG, PNG and GIF images.
put byte 1 to 12 of url ("binfile:" & pPath) into tHeader
case "JFIF" is in tHeader
case "PNG" is in tHeader
case "GIF" is in tHeader
I have used this approach in projects before and it seems to work reliably.
On 2/17/20 1:08 PM, Ralph DiMola via use-livecode wrote:
> What's the best way to know if I set the filename of an image control and
> the file is either not an image or in an unsupported format? I'm getting
> https links to unknown images so I check images before app deployment.
> After resizing an image is there a way to know the original dimensions? Just
> wondering? I now save the original x/y sizes in properties so I know them
> after a resize.
> Ralph DiMola
> IT Director
> Evergreen Information Services
> rdimola at evergreeninfo.net
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode