AppleScript: Alternative zu ImageEvents

Anstatt die ImageEvents via AppleScript anzusteuern, kann man auch über ein Shell Script (das dürfte vielleicht schneller sein) auch sips (scriptable image processing system) aufrufen. Damit kann man sogar die Auflösung von Grafiken in PDFs verändern: sips -s format pdf -s dpiHeight 72 -s dpiWidth 72 -s formatOptions low /path/to/pdf.pdf --out /path/to/converted/pdf.pdfSo ist z.B. auch eine deutlich schlankere Version von diesem Skripte (Bilder klein rechnen mit AppleScript) möglich:
Code zum markieren einmal anklicken Code im Skript-Editor öffnen

on open some_items

tell me to activate

display dialog "Längste Seite" default answer "1024"

set mh to (text returned of the result) as integer

repeat with this_item in some_items

rescale_and_save(this_item, mh)

end repeat

end open

to rescale_and_save(this_item, max_length)

set this_item to quoted form of (POSIX path of this_item)

set scaled_dir_path to (do shell script "dirname " & this_item) & "/_scaled/"

do shell script "mkdir -p '" & scaled_dir_path & "';sips -Z " & max_length & " " & this_item & " --out '" & scaled_dir_path & quoted form of (do shell script "basename " & this_item) & "'"

end rescale_and_save

This entry was posted in scripting and tagged , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA:


9 − = eight

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Niklas: Vielen Vielen Dank! So klappt es!
    • hubi: Servus Niklas, ich habe mir den Quellcode noch einmal angesehen und habe nun unter 10.7.3 einen Weg gefunden...
    • Niklas: Klingt super das Script. Leider bekomm ich immer folgende Fehlermeldung: error “„Mail“ hat einen Fehler...
    • Jürgen: Hallo Hubi, beim Abfragen von Kennworten gibt es noch eine böse Falle: Das Format, in dem security antwortet,...
    • hubi: Am einfachsten Du öffnest im AppleScript-Editor mal das Funktionsverzeichnis (unter Ablage) von iTunes. Ein...