conversion of a PNG file/image to a JPEG file/image with AppleScript
So I'm trying to convert a screenshot (PGN) on my desktop to a JPEG file. I'm using the save command from the Image Event application. I always run into the error -1700: unable to make type reference. Even when I execute the example from the developers.apple.com:
[Mac Automation Scripting Guide: Manipulating Images]
I also tried converting the alias object to a file object (set imagefile to theImage as «class furl»), but to no avail:
-- Prompt for an image
set theImageFile to choose file of type "public.image" with prompt ""
set theOutputFolder to (path to desktop folder as string)
-- Launch Image Events and open the image
do shell script "> $HOME'/Desktop/temp-01.jpg'"
tell application "Image Events"
launch
open theImageFile
set theImage to theImageFile
set target to "Macintosh HD:Users:siemhuijsman:Desktop:temp-01.jpg"
set imagefile to theImage as «class furl»
save imagefile as JPEG in target
close
log theImageFile
end tell
I would be much helped if somebody can explain the error that occurs and perhaps a way to get the job done.
Thank you in advance,
Siem Huijsman
MacBook Pro 16″, macOS 14.0