Script to resize a pdf, jpg, png to create outlook thumbnail

I have tried using a service in automator
that receives pdfs files to scale them and added cut to clipboard step but I can’t seem to have it working for me.
I don’t know how to access the script itself and my mac simply tells me there’s an error.
I’d like to click on a pdf, jpg, png, etc and have it scaled to thumbnail size to insert it in Outlook.

Can someone point me to a good resource?
I am pretty handy with bash, js and applescript.

Thanks

Would be useful to know the content of your failing script.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 29 avril 2020 18:29:37

FreddieMac. I do not completely understand what your are requesting, but the script contained below reduces the pixel size of an image file. As written, it reduces the greater of the width or height of the image file to the specified targetImageSize. The sips man page details other resize options. I tested this with JPG, PNG, and PDF image files and it worked as expected.

set targetImageSize to 100

set sourceFile to POSIX path of (choose file)

-- Alternative that works on file selected in the Finder
-- tell application "Finder" to set sourceFile to selection as alias
-- set sourceFile to POSIX path of sourceFile

set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set filePath to text 1 thru text item -2 of sourceFile & "/"
set fileName to text item -1 of sourceFile
set AppleScript's text item delimiters to TID

set targetFile to filePath & "ThumbNail - " & fileName

do shell script "sips --resampleHeightWidthMax " & targetImageSize & " " & quoted form of sourceFile & " --out " & quoted form of targetFile

This does work wonderful, except I would like to retain the original files.
My idea is to context-menu mouse-click on the image(pdf, jpg, tiff, etc). Have it create a lowres version. Send it to the clipboard in order to paste into an outlook email as a thumbnail.
I know I can probably patch it up here and there. I just thought someone may have inquired on this already?

Thanks!

FreddieMac. In my testing, the script retains the original file and creates a new thumbnail file in the same folder. Under what circumstances is the original file overwritten?

Alternative workaround. You can play with clipboard yourself. I don’t understand completely what you need, because I uninstalled Outlook from my Mac:


-- set aFile to (the clipboard as «class furl»)
set aFile to (choose file of type "public.image") as «class furl»
set newFile to (choose file name)

tell application "Image Events"
	set anImage to open aFile
	scale anImage to size 100
	save anImage as TIFF in newFile with icon
end tell
-- set the clipboard to anImage

NOTE: full disk access required for the Image Events.app. So, give it.

Thanks All,

I’ll cobble it up best I can.
I’m sure I am doing something wrong.
Thank you for this wonderful forum.
I appreciate the contributions made for us newbies to learn.
I love applescript. :slight_smile:
I love macscripter! :slight_smile: