Hi Bob, > Am 31.10.2019 um 20:03 schrieb Bob Sneidar via use-livecode > <use-livecode@lists.runrev.com>: > > OK New version with error checking, and also addresses the issue where Klaus > could not compile: > > on exportScaledImage pSourceFile, pDestFile, pScaleFactor, pFormat > -- Validate parameters > -- pSourceFile > if not there is a file pSourceFile then \ > answer error "Source file does not exist!" as sheet ; exit > exportScaledImage > set the itemDelimiter to "/" > > -- pDestFile > if not there is a folder (item 1 to -2 of pDestFile) then \ > answer error "Destination folder does not exist!" as sheet ; exit > exportScaledImage > > -- pScaleFactor > if not (pScaleFactor is a number) or not(pScaleFactor <1) then \ > answer error "Scale factor must be a percentage > 0!" as sheet ; exit > exportScaledImage > > -- pFormat > if not (pFormat is among the items of "JPEG/BMP/PNG") then \ > answer error "Valid formats are: JPEG, BMP or PNG." as sheet ; exit > exportScaledImage > > -- set the source file as the template image and get dimensions > set the filename of the templateimage to pSourceFile > put the formattedwidth of the templateimage into tFW > put the formattedheight of the templateimage into tFH > > -- scale the image to a round value > set the width of the templateimage to round(tFW * (pScaleFactor /100)) > set the height of the templateimage to round(tFH * (pScaleFactor /100))
## Just tested with DO, this does work WITHOUT switch 8-) put "export the templateimage to file " & quote & pDestFile & quote & " as" && pFormat into tCommand > do tCommand > -- reset > reset the templateimage > end exportScaledImage Best Klaus -- Klaus Major https://www.major-k.de kl...@major-k.de _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode