Yvan, I know you have no crystal ball. I am using a Mac mini 2020 to test on this morning, that has a fresh 10.15 install (2 weeks ago) and the latest update to 10.15.4.
There are non what so ever exotic adjustments on it. Zero. There are no applications running on it that are not Mac Native and of those only a few. It is my blind server and mainly used for backup storage and sending out automatic mails via the native app Mail.
I switched to the MM as I have been testing so far on an external HD running 10.15.4 on my MBP. I thought this might influence stuff negatively.
Could the error be in the fact that I run an Englisch OS version and you a French?
The script doesn’t rely upon localized features.
What I know is that Catalina requires some specific settings to be able do achieve some tasks.
As I can’t install this system, I am unable to list those settings. I just know that they mainly are supposed to give some permissions to the scripts.
Back to the applet which you sent me.
I really don’t understand how you were able to create such a mess.
Your package contain three copies of the script.
It’s normal for a droplet created with Script Debugger.
What is odd is that these versions don’t match.
What appears when we ask Script Editor to open the script is the content of the embedded file named “main.rtf” but, what is executed in the content of the embedded file named “main.scpt” (which is identical to what is in the embedded file named “main.recover.rtf”).
Please, open your applet in Script Editor
select all
create a new empty script
paste in it
save as “4Yvan.app”
then drag and drop a jpeg upon it.
With this clean app you will see that what I wrote is the normal behavior.
As I can’t explain what you did to build the foolish applet I think that the only thing to do is to trash it and quickly empty the trash.
If somebody may describe the settings required by Catalina, maybe you will solve your problem.
I apologize but for me, GAME OVER.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 25 mai 2020 13:46:21
So Yvan sent me a copy of the script. The explanation is that the script you saved is not commented out, but the version that Script Editor auto-saved was made after the script was commented out. So when you opened the script again you saw the last auto-saved version, but the document was still dirty (a black dot in the red button in the title bar). However, that version isn’t the version that runs when you double-click.I suspect that somehow something has got damaged along the line after that.
The moral of the story: always save, never rely on auto-save.
on open draggedItems
repeat with currentFile in draggedItems
-- change targetBytes value to max file size in bytes
(my resizedJpegFromPath:(POSIX path of currentFile) maxHeightOrWidth:800 targetBytes:100000)
end repeat
end open
Change that 100000 to however many bytes is your limit.
Yes, I know this and here I am complete sure all is well. All my other scripts run flawlessly and all permissions in ‘Privacy’ tab are given.
Neither do I but I think Shane expained how it possibly could have happened.
I did that, and hate to say it does not work.
I think my settings are correct in the system. However should anybody have a tip as to what to check I love to hear.
I sincerely apologise if I upset you. I might not be the best AS scripter (I know I am not) but at no time did I intently try to upset the system. I am enormously grateful for the help you and others gave and have given me in the past solving AS challenges. Once again very sorry for the mess.
on open draggedItems
repeat with currentFile in draggedItems
-- change targetBytes value to max file size in bytes
(my resizedJpegFromPath:(POSIX path of currentFile) maxHeightOrWidth:800 targetBytes:100000)
end repeat
end open
use scripting additions
use framework "Foundation"
use framework "AppKit"
on resizedJpegFromPath:imagePath maxHeightOrWidth:maxDim targetBytes:maxBytes
set imagePath to current application's NSString's stringWithString:imagePath
set outPath to (imagePath's stringByDeletingPathExtension()'s stringByAppendingString:"-out")
set outPath to outPath's stringByAppendingPathExtension:"jpg"
-- Get the contents of the passed picture
set theImageRep to current application's NSBitmapImageRep's imageRepWithContentsOfFile:imagePath -- load the file
set theClip to current application's NSPasteboard's generalPasteboard()
-- Extract its original size
set oldHeight to theImageRep's pixelsHigh()
set oldWidth to theImageRep's pixelsWide()
if oldWidth > oldHeight then
set theWidth to maxDim
set theHeight to oldHeight * maxDim / oldWidth
else
set theHeight to maxDim
set theWidth to oldWidth * maxDim / oldHeight
end if
set newRep to (current application's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:theWidth pixelsHigh:theHeight bitsPerSample:8 samplesPerPixel:4 hasAlpha:yes isPlanar:false colorSpaceName:(current application's NSDeviceRGBColorSpace) bytesPerRow:0 bitsPerPixel:32)
-- store the existing graphics context
current application's NSGraphicsContext's saveGraphicsState()
-- set graphics context to new context based on the new bitmapImageRep
current application's NSGraphicsContext's setCurrentContext:(current application's NSGraphicsContext's graphicsContextWithBitmapImageRep:newRep)
theImageRep's drawInRect:{origin:{x:0, y:0}, |size|:{width:theWidth, height:theHeight}} fromRect:(current application's NSZeroRect) operation:(current application's NSCompositeSourceOver) fraction:1.0 respectFlipped:false hints:(missing value)
-- restore state
current application's NSGraphicsContext's restoreGraphicsState()
set compFactor to 0.8 -- starting compression value
set compMax to 0.2 -- compression limit
repeat
set theData to newRep's representationUsingType:(current application's NSJPEGFileType) |properties|:{NSImageCompressionFactor:compFactor}
if compFactor > compMax and theData's |length|() > maxBytes then
-- too big, so try with more compression
set compFactor to compFactor * 0.9
else -- give up
exit repeat
end if
end repeat
theData's writeToFile:outPath atomically:true
end resizedJpegFromPath:maxHeightOrWidth:targetBytes:
set anImage to choose file of type {"public.png", "public.tiff", "public.jpeg"}
my resizedJpegFromPath:(POSIX path of anImage) maxHeightOrWidth:800 targetBytes:100000
in your post you said to chance the 100000 to change the output size of the file.
Is this in this line (top)?
(my resizedJpegFromPath:(POSIX path of currentFile) maxHeightOrWidth:800 targetBytes:100000)
Or this line (bottom)?
my resizedJpegFromPath:(POSIX path of anImage) maxHeightOrWidth:800 targetBytes:100000
Or both?
I ask as any changes made in each of these lines or in both at the same time, make no difference. The output is always a 48KB file. For example I tried 1000000000 and 100 no difference.
Or did I not understand you correctly?
PS
I make a new AS doc and paste the whole text in every time. Next save is as an application. No save as or duplicate.
I hate to write that it’s the kind of sentence which really doesn’t help.
Are you writing about the applet with every instructions disabled ?
If it’s that, what’s the meaning of your statement ?
I will deliberately shout. YOU WERE WARNED SEVERAL TIMES THAT WHEN IT’S SAVED CORRECTLY, SUCH SCRIPT DOES ABSOLUTELY NOTHING.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 25 mai 2020 16:04:54
It sounds like you’ve modified the document, but not saved it. Also, extreme values are a bad test; it will give up before it gets anywhere near 100, and it will start off under 100000000 anyway.
Must I understand that, at last, you were able to get the scripts vents to do what they are supposed to achieve or that you just got the script using ASObjC doing the job ?
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 26 mai 2020 15:17:31
Yvan not sure what you are asking here. And not sure about it using ASObjC, I Googled it and I do not think we are using this here. I surely never installed it.
hopefully this answers your question, what I did is I used the script Shane wrote and combined that without any changes - post number 66 and 56. That shrinks the images I drop on it in 10.15.4.
It is a tick different in the end result compared to my old script results, but one can live with that.
May you retry my scripts using Image Events after applying what Shane urged yo to do in its message #67 ?
Before doing what Shane wrote, you wrote that its script didn’t worked.
I assume that doing the same for mines will give good results too.
When we work with applet/droplet we must apply Save, never rely upon the AutoSave feature.
When I face a problem with an applet or a droplet, every time I solve it with the same boring protocol: open the applet/droplet in the Script Editor
copy all the content of the script window
delete the offending applet/droplet
paste in a new blank script window
save as an application.
To be sure, I asked peavine and he confirmed that on its side, my scripts work flawlessly under Catalina.
So they must do the same on your machine which, I assume, was not made for you with a special design.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 26 mai 2020 17:46:21
I did not know this, I suppose it is proof of my ‘expertise’ in AS.
OK happy to do so.
To prevent misunderstanding, and me taking the wrong one, please be so kind and tell me what the number of the post is it is in. Alternatively, if that is easier for you, post it again.
As I learned from you guys, it was my way of saving/copying the stuff that might have caused the problems.
I too know that now. It now also explains why I have had problems in the past. So one is never too old to learn!