Hey guys, Ive got the following subroutine designed to convert any files fed to it into PNG.
the problem is, the files get saved in the correct folder (/private/tmp/) with the correct file name, but they are not of the type I specified (PNG)
Also, I was trying to get the properties of the file so I could determine the file type to see -if- it even needed conversion, but I just could not get that to work, as getting the properties always returned an error (hence why they are commented out). The application I feed the files to can only accept files of JPEG or PNG type, so I want to convert any non-supported files to png.
on convertImage(tempImage)
tell application "Image Events"
--open the original image
set theImage to open tempImage
--copy the properties of theImage to imageProperties
--if the image isnt jpg or png, convert it to png
--if imageExtension is not in {"JPEG", "PNG"} then
--change the extension to .png
set previousDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set fileSplits to text items of tempImage
set last item of fileSplits to "png"
set newTempImage to fileSplits as string
set AppleScript's text item delimiters to previousDelimiter
--get just the file name, and put it in the tmp folder
set previousDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set fileSplits to text items of newTempImage
set newFile to the last item of fileSplits
set AppleScript's text item delimiters to previousDelimiter
set newTempImage to "/private/tmp/" & newFile
--save the image as a png file
save theImage as PNG in file newTempImage
--end if
close theImage
end tell
return newTempImage