Applescript ridimensiona immagine

Come utilizzare gli script. Automatizzare gli archivi. Utilizzo dei pulsanti

Moderatore: Moderatori

Rispondi
Avatar utente
jelux
Messaggi: 30
Iscritto il: giovedì 14 luglio 2016, 9:44
Versione FileMaker: 18
Sistema operativo: 10.14.6
Contatta:

Applescript ridimensiona immagine

Messaggio da jelux » domenica 6 maggio 2018, 13:18

Ciao a tutto un piccolo aiuto per uno script applescript e filemaker. Sto costruendo questo script :


imposta variabile [ $$CoverNome; Valore: W001_LAVORI::Codice lavoro ]
imposta variabile [ $$SelectImage; Valore: BE_SelectFile ( "Inserire cover lavoro" ; Get ( PercorsoDesktop ) ) ]
imposta variabile [ $$theImageFile; Valore: "Volumes" & CercaeSost ( $$SelectImage ; "/" ; ":" ) ]

Esegui applescript [
" set theImageFile to " & "\”" & $$theImageFile & "\” of type \” public.image \" with prompt \"\" ¶¶

set theOutputFolder to (path to desktop folder as string) ¶¶

set scaleByPercentage to true ¶¶

tell application \” Image Events \”¶¶

launch ¶¶


set theImage to open theImageFile ¶
tell theImage¶¶


set theName to name ¶
set theSaveName to " & "\”" & $$CoverNome & "\” & theName ¶¶


if scaleByPercentage = true then ¶
scale by factor 0.5 ¶¶


else ¶¶

scale to size 100 ¶¶

end if ¶


save as JPEG in (theOutputFolder & theSaveName ) ¶¶


close ¶
end tell ¶
end tell¶
"
]

per ridimensionare una immagine usato due variabili $$theImageFile per definire il file da convertire e uso BE_SelectFile


ma mi da sempre errore a livello di applescript credo, mi dice:

Un prompt:true non può andare dopo questo Volumes:Users:WorkStationJelux:Desktop:B&V Divani.png.

e poi

Errore sconosciuto: -2740.

secondo voi dive sbaglio?

Grazie mille

in allegato lo script di applescript
Non hai i permessi necessari per visualizzare i file allegati in questo messaggio.
Jelux s.r.l. DigitalWorks
and DoubleArt
Via XXV Aprile 116 - 25020 Flero (Brescia) Italy
Fax: +39 030 3581399
web: www.jelux.it
info mail: info@jelux.it

Avatar utente
fabio.beri
Messaggi: 1958
Iscritto il: sabato 4 ottobre 2014, 16:24
Versione FileMaker: 2023
Sistema operativo: Win/Mac

Re: Applescript ridimensiona immagine

Messaggio da fabio.beri » lunedì 7 maggio 2018, 8:49

Nel percorso c'è una E commerciale ? Eviterei.

Comunque un consiglio è di testare lo script (di Applescript) fuori da FileMaker, eseguendolo come stand-alone, così da poter rilevare l'errore.
Fabio Beri
Moderatore FMPro.it
Sviluppatore OmniaGest 5 - FileMaker 15/16/17/18/19

Omnia Studio

-----------------------------------------
http://tinyurl.com/omniagest2024

Avatar utente
jelux
Messaggi: 30
Iscritto il: giovedì 14 luglio 2016, 9:44
Versione FileMaker: 18
Sistema operativo: 10.14.6
Contatta:

Re: Applescript ridimensiona immagine

Messaggio da jelux » martedì 8 maggio 2018, 18:21

Ciao scusa se rispondo in ritardo.

Cosa intendi per Nel percorso c'è una E commerciale ? Eviterei.

intendi la riga = set theSaveName to " & "\”" & $$CoverNome & "\” & theName ¶¶ ?

La & fa parte dello script originale che usato con applescript o anche automator funziona bene , io ho solo sostituito questa siringa
-- Prompt for an image
set theImageFile to choose file of type "public.image" with prompt ""


con una variabile
imposta variabile [ $$SelectImage; Valore: BE_SelectFile ( "Inserire cover lavoro" ; Get ( PercorsoDesktop ) ) ]

lo script di base è il seguente,

Codice: Seleziona tutto

-- Prompt for an image
set theImageFile to choose file of type "public.image" with prompt ""

-- Locate an output folder
set theOutputFolder to (path to desktop folder as string)

-- To scale by percentage, set this value to true. To scale to a specific size, set it to false.
set scaleByPercentage to true

-- Launch Image Events
tell application "Image Events"
	launch
	
	-- Open the image
	set theImage to open theImageFile
	tell theImage
		
		-- Determine a save name for the image
		set theName to name
		set theSaveName to "cover-" & theName
		
		-- Scale the image by 50%
		if scaleByPercentage = true then
			scale by factor 0.5
			
			-- Scale the image to 100px on its longese side
		else
			scale to size 100
		end if
		
		-- Save the image as a .jpg
		save as JPEG in (theOutputFolder & theSaveName)
		
		-- Close the image
		close
	end tell
end tell

grazie mille
Jelux s.r.l. DigitalWorks
and DoubleArt
Via XXV Aprile 116 - 25020 Flero (Brescia) Italy
Fax: +39 030 3581399
web: www.jelux.it
info mail: info@jelux.it

Rispondi