Hi,
I had a Script which was perfectly working before the Update to Big Sur, now I get the Error “from missing value to specifer”
Anyone has that problem too?
Here is the Script I used:
property size : 1590
set originalImages to choose folder with prompt "Quellordner wählen"
set processfolder to choose folder with prompt "Zielordner angeben"
tell application "Finder"
set allimages to get every file of folder originalImages as alias list
end tell
repeat with i from 1 to number of items in allimages
set this_item to item i of allimages
my resizeiamge(this_item, size, processfolder)
end repeat
on resizeiamge(this_item, theResize, destfolder)
set theJPG to name of (info for this_item)
tell application "Image Events"
launch
set this_image to open this_item
scale this_image to size theResize
save this_image in file (destfolder & theJPG as string) as JPEG
close this_image
end tell
end resizeiamge
Would be happy if anyone can help
The support of Image Events for aliases is broken in new OS systems. It is known problem already. Try to use HFS paths with file keyword instead. The keyword size is reserved word, so it is better to wrap it with pipes:
property |size| : 1590
set originalImages to (choose folder with prompt "Quellordner wählen") as text
set processfolder to (choose folder with prompt "Zielordner angeben") as text
tell application "Finder" to set allimages to get every file of folder originalImages as alias list
tell application "Image Events" to launch
repeat with i from 1 to number of items in allimages
set theJPG to my getBaseName(POSIX path of (item i of allimages))
tell application "Image Events"
try -- added to avoid throwing error with no image files in the folder
set this_image to open file (item i of allimages as text) -- HFS path provided here
scale this_image to size |size|
save this_image in file (processfolder & theJPG & ".jpg") as JPEG
close this_image
end try
end tell
end repeat
on getBaseName(posixPath)
set {ATID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
if (posixPath ends with "/") then
set baseName to text item -2 of posixPath
else
set baseName to text item -1 of posixPath
end if
if (baseName contains ".") then
set AppleScript's text item delimiters to "."
set baseName to text 1 thru text item -2 of baseName
end if
set AppleScript's text item delimiters to ATID
return baseName
end getBaseName
Hi,
thank you for the help.
I get the result → error number -1708 now instead of the resized image
I can’t reproduce this error on Catalina. So, what code line throws it, and what is description of this error?
Here is my other hint to force Image Events to work directly with aliases. It uses a reference item i of aliases array:
property |size| : 1590
set originalImages to (choose folder with prompt "Quellordner wählen") as text
set processfolder to (choose folder with prompt "Zielordner angeben") as text
tell application "Finder" to set allimages to get every file of folder originalImages as alias list
tell application "Image Events" to launch
repeat with i from 1 to number of items in allimages
set theJPG to my getBaseName(POSIX path of (item i of allimages))
tell application "Image Events"
try -- added to avoid throwing error with no image files in the folder
set this_image to open item i of allimages -- THIS HINT
scale this_image to size |size|
save this_image in file (processfolder & theJPG & ".jpg") as JPEG
close this_image
end try
end tell
end repeat
on getBaseName(posixPath)
set {ATID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
if (posixPath ends with "/") then
set baseName to text item -2 of posixPath
else
set baseName to text item -1 of posixPath
end if
if (baseName contains ".") then
set AppleScript's text item delimiters to "."
set baseName to text 1 thru text item -2 of baseName
end if
set AppleScript's text item delimiters to ATID
return baseName
end getBaseName
Hi,
this is the Error I get:
error “„Image Events“ hat einen Fehler erhalten: image "Bildschirmfoto 2022-07-08 um 08.42.10 Kopie 2.jpg" versteht die Nachricht „save“ nicht.” number -1708 from image “Bildschirmfoto 2022-07-08 um 08.42.10 Kopie 2.jpg”
That is, as I understand it, the image-object of the Image Events application is not intended to respond to the save command on Big Sur? It’s very strange and without having Big Sur it’s hard for me to fix anything…
I was aware of a bug with aliases that was getting old with Catalina. I also showed a method of circumvention of it in 2 variants. Your description of the error leads me to the bad idea that since Big Sur, the Image Events application has acquired another serious bug.
The scripts above uses the save command from Standard Suite. Exists save command from Image Events Suite as well. Makes sense trying it this way:
property |size| : 1590
set originalImages to (choose folder with prompt "Quellordner wählen") as text
set processfolder to (choose folder with prompt "Zielordner angeben") as text
tell application "Finder" to set allimages to get every file of folder originalImages as alias list
tell application "Image Events" to launch
repeat with i from 1 to number of items in allimages
set theJPG to my getBaseName(POSIX path of (item i of allimages))
tell application "Image Events"
try -- added to avoid throwing error with no image files in the folder
set this_image to open item i of allimages -- THIS HINT
scale this_image to size |size|
save this_image as JPEG in (processfolder & theJPG & ".jpg") -- with compression level high (optional) with icon (optional)
close this_image
end try
end tell
end repeat
on getBaseName(posixPath)
set {ATID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
if (posixPath ends with "/") then
set baseName to text item -2 of posixPath
else
set baseName to text item -1 of posixPath
end if
if (baseName contains ".") then
set AppleScript's text item delimiters to "."
set baseName to text 1 thru text item -2 of baseName
end if
set AppleScript's text item delimiters to ATID
return baseName
end getBaseName
NOTE: As I checked, on Catalina this code works correctly. As well as 2 scripts provided by me above.
FWIW, I tested KniazidisR’s scripts from posts 2 and 7. They create resized images in the destination folder. However, the source image is a PNG and file in the destination folder has a PNG extension. I’m running Monterey.
It was wrong extensions provided by me (and by original script in post #1). I updated my scripts now to fix this mistake.
KniazidisR. I tested your revised scripts in posts 2 and 7. They worked as expected, but I first had to change destfolder to processfolder in the script in post 2.