Tuesday, July 14, 2020

#1 2020-05-20 09:53:51 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

I have a script to shrink pictures that stopped working under 10.15.

I have the following script.


Applescript:

tell application "Image Events"
   launch
end tell

on open draggeditems
   repeat with currentFile in draggeditems
       tell application "Image Events"
           set openedFile to open (currentFile as alias)
           
           set fileLocation to the location of openedFile
           set fileName to the name of openedFile
           
           scale openedFile to size 800
           save openedFile with icon
           close openedFile
       end tell
       
       tell application "Finder"
           set the name of file fileName of fileLocation to ¬
               (fileName)
       end tell
   end repeat
end open

It worked fine under 10.13 but now that I moved to 10.15 it does not.  See pic for error. 

https://pasteboard.co/J9gwh9B.png


Any idea as to how to fix?

Offline

 

#2 2020-05-20 10:34:30 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 544

Re: I have a script to shrink pictures that stopped working under 10.15.

Image Events, like System Events, no longer works reliably with aliases, and that could be the cause of the issue you are experiencing. For more information on this issue, and some workarounds, see:

https://macscripter.net/viewtopic.php?pid=199787

The following worked for me:

Applescript:

tell application "Image Events"
   launch
end tell

on open draggeditems
   repeat with currentFile in draggeditems
       tell application "Image Events"
           set theFile to currentFile as text
           set openedFile to open file theFile
           
           set fileLocation to the location of openedFile
           set fileName to the name of openedFile
           
           scale openedFile to size 800
           save openedFile with icon
           close openedFile
       end tell
       
       tell application "Finder"
           set the name of file fileName of fileLocation to ¬
               (fileName)
       end tell
   end repeat
end open

Last edited by peavine (2020-05-20 10:43:22 am)


2018 Mac mini - macOS Catalina

Offline

 

#3 2020-05-20 10:51:58 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

As a starting point, run this script:

Applescript:

set currentfile to choose file of type {"public.jpeg"}

tell application "Image Events"
   set openedFile to open (currentfile as alias) --> image "20190304_205111+.jpg"
   set fileLocation to the location of openedFile --> folder "SSD 1000:Users:**********:Desktop:images:"
   set fileName to the name of openedFile --> "20190304_205111+.jpg"
end tell

The comments show what is returned in 10.13.6

Your screenshot let me think that under Catalina you get:

Applescript:

set fileLocation to the location of openedFile --> missing value

Now, I will try to describe what you really do.

Applescript:

tell application "Finder"
set refToFile to file fileName of fileLocation -- which is just an other way to point to currentfile
set name of refToFile to (fileName)
end tell

If, as I guess, "Image Events" returns missing value for fileLocation,
your code is logically unable to build a reference to the original file but what need to rebuild what you already know ?

Applescript:

tell application "Finder"
set name of currentfile to (fileName)
end tell

or

Applescript:

tell application "Finder"
set name of (currentfile as alias) to (fileName)
end tell

would do the job.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 20 mai 2020 18:51:07

Offline

 

#4 2020-05-20 11:13:10 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: I have a script to shrink pictures that stopped working under 10.15.

Thanks peavine and Yvan

I am away from the 10.15 machine (now on 10.13), so as soon as I am back there I will give it a go.

Offline

 

#5 2020-05-21 08:14:03 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: I have a script to shrink pictures that stopped working under 10.15.

peavine thanks.

just tested and it does not shrink the image.  however it does not return an error.

Offline

 

#6 2020-05-21 08:20:50 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: I have a script to shrink pictures that stopped working under 10.15.

Yvan, I am testing your post and at the first script you suggest I get, see pic.

I am also not sure I understand the rest, but wanted to report as I figured I might get it as I move along.



https://ibb.co/7R2hQ6T

Offline

 

#7 2020-05-21 08:50:57 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 544

Re: I have a script to shrink pictures that stopped working under 10.15.

ChangeAgent. The following is a slightly revised version of my script--it simplifies the coercion of alias to text and eliminates the save-with-icon option.

Applescript:

tell application "Image Events"
   launch
end tell

on open draggeditems
   repeat with currentFile in draggeditems
       tell application "Image Events"
           set openedFile to open file (currentFile as text)
           
           set fileLocation to the location of openedFile
           set fileName to the name of openedFile
           
           scale openedFile to size 800
           save openedFile
           close openedFile
       end tell
       
       tell application "Finder"
           set the name of file fileName of fileLocation to (fileName)
       end tell
   end repeat
end open

As a test, I saved the script to the desktop as an application. I then dragged a 3.9-MB JPEG file from a Finder window onto the application icon. The 3.9-MB JPEG file now showed a file size of 126 KB, and the  Preview app showed the image dimensions as 800 pixels wide. Are you seeing something different?

Last edited by peavine (2020-05-21 09:08:28 am)


2018 Mac mini - macOS Catalina

Offline

 

#8 2020-05-21 09:15:03 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: I have a script to shrink pictures that stopped working under 10.15.

mmm, peavine.

It runs fine but does not change the size.  Odd.  I tried with a 1.8 MB jpeg and a 3.2MB png.

I do not understand this, do you?  I use OS 10.15.4 and Script Editor Version 2.11 (208)

Offline

 

#9 2020-05-21 09:43:09 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

ChangeAgent wrote:

Yvan, I am testing your post and at the first script you suggest I get, see pic.

I am also not sure I understand the rest, but wanted to report as I figured I might get it as I move along.



https://ibb.co/7R2hQ6T


Thank you,
it's worse than what I guessed,
the instruction

Applescript:

set openedFile to open (currentfile as alias)

set the variable openedFile to missing value and it's what is reported and is perfectly described in the right pane of Script Debugger.

peavine which may run Catalina gave you the syntax required by this system but he missed what I tried to explain.

What he posted may be re-phrased as:

Applescript:

tell application "Image Events"
   launch
end tell

on open draggeditems
   repeat with currentFile in draggeditems -- here currentFile IS an alias
       tell application "Image Events"
           set openedFile to open file (currentFile as text)

           -- set fileLocation to the location of openedFile    -- DISABLED        
           set fileName to the name of openedFile
           
           scale openedFile to size 800
           save openedFile
           close openedFile
       end tell
       
       tell application "Finder"
           set the name of currentFile to (fileName) -- EDITED
       end tell
   end repeat
end open

And with this new spelling, it appears clearly that what you ask to the Finder is perfectly useless.

The script may be reduced to:

Applescript:

tell application "Image Events"
   launch
end tell

on open draggeditems
   repeat with currentFile in draggeditems -- here currentFile IS an alias
       tell application "Image Events"
           set openedFile to open file (currentFile as text)
           
           set fileName to the name of openedFile
           
           scale openedFile to size 800
           save openedFile
           close openedFile
       end tell
   end repeat
end open

Running 10.13.6, I applied this script to a file whose size was 1746 x 3104 pixels and the treated file is now a 450 x 800 pixels one. Of course I don't know what is achieved under 10.15.4.

To be honest, I think tha the instructions

Applescript:

tell application "Image Events"
   launch
end tell

may be removed too.

My understanding is tha peavine misunderstood your question.
With its code, you resize the file so that its greater dimension becomes 800 pixels.
So if you pass a file whose size was 1280 x 720 you will get a 800 x 450 pixels one which as I read your question is not what you wanted.
I understood that you wanted it to be a 1422 x 800 one.

In fact peavine understood what you posted, not what you had in mind.
On my side, I mixed the contents of two threads, this one and <https://macscripter.net/viewtopic.php?id=47670> so by chance I thought to what you had in mind.


Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 21 mai 2020 17:21:47

Last edited by Yvan Koenig (2020-05-21 10:11:25 am)

Offline

 

#10 2020-05-21 10:21:21 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 544

Re: I have a script to shrink pictures that stopped working under 10.15.

Yvan. I just tried to get the OP's script to work on my Catalina computer. I didn't carefully review what you wrote--sorry.

I agree that the Finder code does nothing. My knowledge of scripts of this sort is very limited but I would write the script as follows:

Applescript:

on open draggeditems
   tell application "Image Events"
       launch
       
       repeat with currentFile in draggeditems -- here currentFile IS an alias
           set openedFile to open file (currentFile as text)
           scale openedFile to size 800
           save openedFile
           close openedFile
       end repeat
       
   end tell
end open

This script works on my test JPEG file but not on a PNG file. I'm not sure of the reason for that but will look into this matter later.

As regards the size of the resized image, I don't know if the OP wants to reduce the longer or the shorter side of the original image to 800 pixels. That seems a peripheral issue right now, as the OP can't get the script to do anything. However, FWIW, my test image was 4032 by 3024 and became 800 by 600 after running it through my script.

Last edited by peavine (2020-05-21 10:29:22 am)


2018 Mac mini - macOS Catalina

Offline

 

#11 2020-05-21 10:50:34 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

peavine wrote:


As regards the size of the resized image, I don't know if the OP wants to reduce the longer or the shorter side of the original image to 800 pixels. That seems a peripheral issue right now, as the OP can't get the script to do anything. However, FWIW, my test image was 4032 by 3024 and became 800 by 600 after running it through my script.




It seems that you missed that the OP wrote:

As a test, I saved the script to the desktop as an application. I then dragged a 3.9-MB JPEG file from a Finder window onto the application icon. The 3.9-MB JPEG file now showed a file size of 126 KB, and the  Preview app showed the image dimensions as 800 pixels wide. Are you seeing something different?


I'm quite sure that Preview states that the image is 450 pixels high for a width of 800 pixels when he hoped to get a 800 pixels height for a 1422 pixels width.
With your example it means that 4032 (width) x 3024 (height) would become 1067 width) x 800 (height).
For sure, it's not what the original script would have returned under High Sierra.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 21 mai 2020 18:49:16

Offline

 

#12 2020-05-21 11:04:52 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: I have a script to shrink pictures that stopped working under 10.15.

Yvan thanks.

I ran your script, and nothing happens.  The pic is by the way 3024 × 4032, 1.8 MB

My aim, and this is what the original script did, is to shrink the image in size.  So, to about 100 mb.  It is what in 10.13 the quart filters do.  But they too seem to have disappeared in 10.15.

Offline

 

#13 2020-05-21 11:09:04 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 544

Re: I have a script to shrink pictures that stopped working under 10.15.

Yvan Koenig wrote:

It seems that you missed that the OP wrote:

As a test, I saved the script to the desktop as an application. I then dragged a 3.9-MB JPEG file from a Finder window onto the application icon. The 3.9-MB JPEG file now showed a file size of 126 KB, and the  Preview app showed the image dimensions as 800 pixels wide. Are you seeing something different?



Yvan. I think I wrote that not the OP. Anyways, the OP might try the following, which worked with both JPEG and PNG files on my computer. The option resampleHeightWidthMax can be changed to resampleHeight or resampleWidth if desired.

Applescript:

on open draggeditems
   
   repeat with aFile in draggeditems
       set contents of aFile to quoted form of POSIX path of aFile & space
   end repeat
   
   do shell script "sips --resampleHeightWidthMax 800 " & draggeditems
   
end open

Last edited by peavine (2020-05-21 05:18:10 pm)


2018 Mac mini - macOS Catalina

Offline

 

#14 2020-05-21 11:32:39 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

peavine wrote:
Yvan Koenig wrote:

It seems that you missed that the OP wrote:

As a test, I saved the script to the desktop as an application. I then dragged a 3.9-MB JPEG file from a Finder window onto the application icon. The 3.9-MB JPEG file now showed a file size of 126 KB, and the  Preview app showed the image dimensions as 800 pixels wide. Are you seeing something different?



Yvan. I think I wrote that not the OP. Anyways, the OP might try the following, which worked with both JPEG and PNG files.




Oops, it seems that I am tired.

What is returned by this script under Catalina ?

Applescript:

set theFile to choose file of type {"public.png", "public.jpeg"}

tell application "Image Events"
   set openedFile to open file (theFile as string)
   properties of openedFile

   scale openedFile to size 800
   save openedFile with icon
   close openedFile
   
   set openedFile to open file (theFile as string) -- with Catalina
   properties of openedFile
end tell

Here I got :

Applescript:


Don't click that, it's a log history

(case 1 .png)
tell application "Script Editor"
   choose file of type {"public.png", "public.jpeg"}
       --> alias "SSD 1000:Users:**********:Desktop:##29381 copie.png"
end tell
tell application "Image Events"
   open file "SSD 1000:Users:**********:Desktop:##29381 copie.png"
       --> image "##29381 copie.png"
   get properties of image "##29381 copie.png"
       --> {color space:RGB, image file:file "SSD 1000:Users:**********:Desktop:##29381 copie.png", bit depth:millions of colors, dimensions:{1023, 658}, location:folder "SSD 1000:Users:**********:Desktop:", embedded profile:profile "iMac" of image "##29381 copie.png", file type:PNG, class:image, name:"##29381 copie.png", resolution:{72.0, 72.0}}
   scale image "##29381 copie.png" to size 800
   save image "##29381 copie.png" with icon
       --> file "SSD 1000:Users:**********:Desktop:##29381 copie.png"
   close image "##29381 copie.png"
   open file "SSD 1000:Users:**********:Desktop:##29381 copie.png"
       --> image "##29381 copie.png"
   get properties of image "##29381 copie.png"
       --> {color space:RGB, image file:file "SSD 1000:Users:**********:Desktop:##29381 copie.png", bit depth:millions of colors, dimensions:{800, 514}, location:folder "SSD 1000:Users:**********:Desktop:", embedded profile:profile "iMac" of image "##29381 copie.png", file type:PNG, class:image, name:"##29381 copie.png", resolution:{72.0, 72.0}}
end tell

#-----------

(case 2 .jpg)
tell application "Script Editor"
   choose file of type {"public.png", "public.jpeg"}
       --> alias "SSD 1000:Users:**********:Desktop:##29378.jpg"
end tell
tell application "Image Events"
   open file "SSD 1000:Users:**********:Desktop:##29378.jpg"
       --> image "##29378.jpg"
   get properties of image "##29378.jpg"
       --> {color space:RGB, image file:file "SSD 1000:Users:**********:Desktop:##29378.jpg", bit depth:millions of colors, dimensions:{1200, 1600}, location:folder "SSD 1000:Users:**********:Desktop:", embedded profile:missing value, file type:JPEG, class:image, name:"##29378.jpg", resolution:{72.0, 72.0}}
   scale image "##29378.jpg" to size 800
   save image "##29378.jpg" with icon
       --> file "SSD 1000:Users:**********:Desktop:##29378.jpg"
   close image "##29378.jpg"
   open file "SSD 1000:Users:**********:Desktop:##29378.jpg"
       --> image "##29378.jpg"
   get properties of image "##29378.jpg"
       --> {color space:RGB, image file:file "SSD 1000:Users:**********:Desktop:##29378.jpg", bit depth:millions of colors, dimensions:{600, 800}, location:folder "SSD 1000:Users:**********:Desktop:", embedded profile:profile "sRGB IEC61966-2.1" of image "##29378.jpg", file type:JPEG, class:image, name:"##29378.jpg", resolution:{72.0, 72.0}}
end tell

Offline

 

#15 2020-05-21 12:46:01 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

Under 10.13.6, Image Events works well with «class furl» objects. Is it the same under Catalina ?

Applescript:

set theFile to choose file of type {"public.png", "public.jpeg"}
set theFile to theFile as «class furl»
tell application "Image Events"
   set openedFile to open theFile
   
   properties of openedFile
   scale openedFile to size 800
   save openedFile with icon
   close openedFile
   
   set openedFile to open theFile
   properties of openedFile
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 21 mai 2020 20:45:53

Offline

 

#16 2020-05-21 03:20:28 pm

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 544

Re: I have a script to shrink pictures that stopped working under 10.15.

Yvan Koenig wrote:

What is returned by this script under Catalina ?



Yvan. Your scripts in post 14 and 15 work on image files on my boot drive but not an external drive, where they return:

{color space:missing value, image file:file "Save:Screenshot 1028.png" of application "Image Events", bit depth:missing value, dimensions:{}, location:folder "Save:" of application "Image Events", embedded profile:missing value, file type:missing value, class:image, name:"Screenshot 1028.png", resolution:{}}



The following is the only script that worked on the external drive:

Applescript:

set theFile to choose file of type {"public.png", "public.jpeg"}
set theFile to quoted form of POSIX path of theFile

do shell script "sips --resampleHeightWidthMax 800 " & theFile

Last edited by peavine (2020-05-21 07:06:41 pm)


2018 Mac mini - macOS Catalina

Offline

 

#17 2020-05-21 07:49:19 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

Thank you.

Maybe it's because insomnia strikes but I am surprised because, in www.mac.osxautomation.com I may read :
The Image Events application is used by AppleScript to control the SIPS architecture. It has no visual interface and presents no menus, windows, or dialogs for user interaction. It is intended to run invisibly as a background process, only accessible via AppleScript commands.

So I always thought that Image Events was able to do what SIPS does.

Here the script below grabs the size infos from a file stored on an external device using Image Events as well as extracting metadatas with ASObjC.

Applescript:

----------------------------------------------------------------
use AppleScript version "2.5" -- (10.11) or later
use framework "Foundation"
use scripting additions
----------------------------------------------------------------

set theFile to choose file of type {"public.png", "public.jpeg"}

set theFile to theFile as «class furl»

set POSIXPath to POSIX path of theFile
log POSIXPath -- to check that it's on an external device
tell application "Image Events"
   try
       set openedFile to open theFile -- a «class furl» object
       properties of openedFile
       close openedFile
   end try
   try
       set openedFile2 to open POSIXPath -- a POSIX Path
       properties of openedFile2
       close openedFile2
   end try
end tell

set thisNSURL to current application's NSURL's fileURLWithPath:POSIXPath
set nsMetaItem to current application's NSMetadataItem's alloc()'s initWithURL:thisNSURL
# Build a list of every available metadatas
set theMetadata to nsMetaItem's valuesForAttributes:(nsMetaItem's attributes())
return theMetadata as list

Here, under 10.13.6, the log history is :

Applescript:

tell application "Script Editor"
   choose file of type {"public.png", "public.jpeg"}
       --> alias "Aluice_250:Users:**********:DiskSpeedTest.png"
end tell
(*/Volumes/Aluice_250/Users/**********/DiskSpeedTest.png*)
tell application "Image Events"
   open file "Aluice_250:Users:**********:DiskSpeedTest.png"
       --> image "DiskSpeedTest.png"
   get properties of image "DiskSpeedTest.png"
       --> {color space:RGB, image file:file "Aluice_250:Users:**********:DiskSpeedTest.png", bit depth:millions of colors,

dimensions:{825, 850},

location:folder "Aluice_250:Users:**********:", embedded profile:missing value, file type:PNG, class:image, name:"DiskSpeedTest.png", resolution:{72.0, 72.0}}
   close image "DiskSpeedTest.png"
   open "/Volumes/Aluice_250/Users/**********/DiskSpeedTest.png"
       --> image "DiskSpeedTest.png"
   get properties of image "DiskSpeedTest.png"
       --> {color space:RGB, image file:file "Aluice_250:Users:**********:DiskSpeedTest.png", bit depth:millions of colors,

dimensions:{825, 850},

location:folder "Aluice_250:Users:**********:", embedded profile:missing value, file type:PNG, class:image, name:"DiskSpeedTest.png", resolution:{72.0, 72.0}}
   close image "DiskSpeedTest.png"
end tell
Résultat :
{{kMDItemFSContentChangeDate:date "lundi 11 avril 2011 à 22:57:31", kMDItemDateAdded_Ranking:date "mardi 9 décembre 2014 à 01:00:00", kMDItemFSTypeCode:0,

kMDItemPixelHeight:850,

kMDItemDisplayName:"DiskSpeedTest.png", kMDItemFSIsExtensionHidden:false, kMDItemFSLabel:0, kMDItemContentCreationDate:date "lundi 11 avril 2011 à 22:57:31", kMDItemContentTypeTree:{"public.png", "public.image", "public.data", "public.item", "public.content"}, kMDItemBitsPerSample:40, kMDItemInterestingDate_Ranking:date "lundi 11 avril 2011 à 02:00:00", kMDItemFSFinderFlags:0, kMDItemPixelCount:701250, kMDItemHasAlphaChannel:true, kMDItemResolutionHeightDPI:72, kMDItemFSSize:364246, kMDItemColorSpace:"RGB", kMDItemFSName:"DiskSpeedTest.png", kMDItemDateAdded:date "mardi 9 décembre 2014 à 20:16:50", kMDItemResolutionWidthDPI:72, kMDItemPhysicalSize:364544, kMDItemFSCreationDate:date "lundi 11 avril 2011 à 22:57:31", kMDItemContentCreationDate_Ranking:date "lundi 11 avril 2011 à 02:00:00", kMDItemFSCreatorCode:0, kMDItemInterestingDate_RankingRepaired:true, kMDItemOrientation:1, kMDItemFSInvisible:false, kMDItemKind:"Image PNG (Portable Network Graphics)",

kMDItemPixelWidth:825,

kMDItemFSOwnerUserID:501, kMDItemContentModificationDate:date "lundi 11 avril 2011 à 22:57:31", kMDItemContentType:"public.png", kMDItemLogicalSize:364246, kMDItemFSOwnerGroupID:20}}

I was aware that under Catalina, Image Events has problem with alias objects but not that it's failing with files stored on external devices.

If it's confirmed, it seems that it's not a feature but an annoying bug.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 22 mai 2020 03:49:13

Offline

 

#18 2020-05-21 08:53:07 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6404

Re: I have a script to shrink pictures that stopped working under 10.15.

peavine wrote:

Your scripts in post 14 and 15 work on image files on my boot drive but not an external drive



Have you granted Image Events Full Disk Access?


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Online

 

#19 2020-05-21 09:14:07 pm

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 544

Re: I have a script to shrink pictures that stopped working under 10.15.

Thanks Shane. That was the problem.

Giving Image Events full disk access is not very straightforward:

https://darjeelingsteve.com/articles/Fi … alina.html

For Yvan, the output from your script in post 15 with a PNG file on the external drive:

{color space:RGB, image file:file "Save:Screenshots:Screenshot 1001.png" of application "Image Events", bit depth:millions of colors, dimensions:{655, 800}, location:folder "Save:Screenshots:" of application "Image Events", embedded profile:profile "DELL P2415Q" of image "Screenshot 1001.png" of application "Image Events", file type:PNG, class:image, name:"Screenshot 1001.png", resolution:{144.0, 144.0}}


2018 Mac mini - macOS Catalina

Offline

 

#20 2020-05-21 09:27:51 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6404

Re: I have a script to shrink pictures that stopped working under 10.15.

Yvan Koenig wrote:

in www.mac.osxautomation.com I may read :
The Image Events application is used by AppleScript to control the SIPS architecture.[...]

So I always thought that Image Events was able to do what SIPS does.



I think you're perhaps taking it a bit too literally. SIPS and Image Events appeared at the same time, and took advantage of the same underlying framework -- I think that underlying framework is what is meant by the rather loose term "SIPS architecture" here. And it doesn't mean each exposes all the same functionality, just that they both have access to it.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Online

 

#21 2020-05-21 10:26:48 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

Thank you Shane.
If Image Events is able to apply to external devices when it's granted Full Disk Access, the problem is solved.
At least if the info is available for every user.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 22 mai 2020 06:26:35

Offline

 

#22 2020-05-22 06:22:55 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: I have a script to shrink pictures that stopped working under 10.15.

Image Events is the magic word.

It works, even my original script works again.

Thanks to everybody for chipping in!  I really appreciate it I do not think (well I know) I would not have gotten there on my own.

Offline

 

#23 2020-05-22 07:13:41 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

ChangeAgent wrote:

Image Events is the magic word.

It works, even my original script works again.

Thanks to everybody for chipping in!  I really appreciate it I do not think (well I know) I would not have gotten there on my own.



Thank you for this feedback.

May you explain what is this group of instructions supposed to achieve ?

Applescript:

tell application "Finder"
set the name of file fileName of fileLocation to (fileName)
end tell

At first look, it seems to be useless but maybe I missed something.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 22 mai 2020 15:12:20

Offline

 

#24 2020-05-22 09:34:31 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: I have a script to shrink pictures that stopped working under 10.15.

Yvan, I had to fire up the test setting again and tested the script one more time and it stopped working.  I have no idea as to why!  Frustrating to say the least.

Here is what I did.  I tested the script in new testing setup while we were ticking back and forth.  Made it into an application and it worked.  I still have these, and they still work. 

I than made new ones for the folder where I normally keep them and did not test.  Now because of your question I had a look and discovered that they do not work.  If I paste the script directly in to a new window and save it as a App.  It does not work.

Wow, I am stumped.  Any ideas?

BTW Image Events still has full disk access. 

Here some pics.

https://ibb.co/Vv71wmj

https://ibb.co/RCcScCG

Offline

 

#25 2020-05-22 10:17:40 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4553

Re: I have a script to shrink pictures that stopped working under 10.15.

In your screenshot I can't see what is certainly the culprit.

Applescript:

on open draggeditems
repeat with currentFile in draggeditems
tell application "Image Events"
set openedFile to open (currentFile as alias) --<<<< I don't see the end of this instruction

set fileLocation to the location of openedFile
set fileName to the name of openedFile

If you are using (currentFile as alias) it's not surprising that it fail.

Peavine carefully urged you to use

Applescript:

set openedFile to open file (currentFile as string)

because under Catalina, Image Events is unable to work with aliases.

I wish to add that, even if it worked in the past, the original syntax was bad too

draggeditems is a list of aliases
currentFile is an alias so, coercing it into an alias make no real sense.
In old times the correct syntax was : set openedFile to open currentFile

This version must work

Applescript:

on open draggeditems
   tell application "Image Events" to launch
   repeat with currentFile in draggeditems
       tell application "Image Events"
           set openedFile to open file (currentFile as string)
           
           set fileLocation to the location of openedFile
           set fileName to the name of openedFile
           
           scale openedFile to size 800
           save openedFile with icon
           close openedFile
       end tell
       (*
       tell application "Finder"
           set the name of file fileName of fileLocation to ¬
               (fileName)
       end tell
       *)

   end repeat
end open

I guess that the two alternate versions listed below work too but I can't test them under Catalina.

Applescript:

on open draggeditems
   repeat with currentFile in draggeditems
       tell application "Image Events" to launch
       set POSIXPath to POSIX path of currentFile
       tell application "Image Events"
           set openedFile to open POSIXPath
           
           set fileLocation to the location of openedFile
           set fileName to the name of openedFile
           
           scale openedFile to size 800
           save openedFile with icon
           close openedFile
       end tell
       (*
       tell application "Finder"
           set the name of file fileName of fileLocation to ¬
               (fileName)
       end tell
       *)

   end repeat
end open

Applescript:

on open draggeditems
   tell application "Image Events" to launch
   repeat with currentFile in draggeditems
       set theFile to currentFile as «class furl»
       tell application "Image Events"
           set openedFile to open theFile
           
           set fileLocation to the location of openedFile
           set fileName to the name of openedFile
           
           scale openedFile to size 800
           save openedFile with icon
           close openedFile
       end tell
       (*
       tell application "Finder"
           set the name of file fileName of fileLocation to ¬
               (fileName)
       end tell
       *)

   end repeat
end open

If it prove to work, the late one is my preferred choice because «class furl» is the class of object which is used now by most tools.
And of course, I'm always waiting your explanations about the three instructions which I deliberately disabled.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 22 mai 2020 18:15:37

Last edited by Yvan Koenig (2020-05-22 10:18:35 am)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)