AppleTouch Icon Droplet

Das ist ein einfaches Skript, das sips nutzt um alles passenden Größen der Apple-Touch-Icons für eine Website anzulegen. Einfach als Droplet abspeichern, PNG draufziehen und als Ergebnis erhält man die entsprechend benannten Touch-Icons in der entsprechende Größe.

on open these
  set allowedExtensions to {".png", ".jpg", ".pdf", ".gif", ".tif", "tiff"}
  if (count of these) is 1 then
    set this to item 1 of these
    tell application "Finder" to set thisname to name of this
    set this_posix to quoted form of POSIX path of this
    set this_posix_folder to quoted form of (do shell script "dirname " & this_posix)
    set myextension to (characters -4 through -1 of thisname) as text
    if myextension is not in allowedExtensions then
      error "This script does not work with " & myextension & "-files."
    else
      set imagewidth to last word of (do shell script "sips -g pixelWidth " & this_posix) as integer
      set imageheigth to last word of (do shell script "sips -g pixelHeight " & this_posix) as integer
      if imagewidth ≠ imageheigth then
        error "The Image file should have the values for width and height. (" & imagewidth & "x" & imageheigth & ")"
      else
        if imagewidth < 144 then
          display dialog "This Image is smaller than 144x144 pixel… well I will scale those blurry pixels" buttons {"OK"} default button {"OK"}
        end if
        do shell script "sips -s format png -Z 144 " & this_posix & " --out " & this_posix_folder & "/apple-touch-icon-144x144-precomposed.png"
        (do shell script "sips -s format png -Z 144 " & this_posix & " --out " & this_posix_folder & "/apple-touch-icon-144x144-precomposed.png")
        (do shell script "sips -s format png -Z 114 " & this_posix & " --out " & this_posix_folder & "/apple-touch-icon-114x114-precomposed.png")
        (do shell script "sips -s format png -Z 72 " & this_posix & " --out " & this_posix_folder & "/apple-touch-icon-72x72-precomposed.png")
        (do shell script "sips -s format png -Z 57 " & this_posix & " --out " & this_posix_folder & "/apple-touch-icon-57x57-precomposed.png")
        (do shell script "sips -s format png -Z 57 " & this_posix & " --out " & this_posix_folder & "/apple-touch-icon-precomposed.png")
        (do shell script "sips -s format png -Z 57 " & this_posix & " --out " & this_posix_folder & "/apple-touch-icon.png")
        
      end if
    end if
  else
    error "This script only works with on input file"
  end if
end open

									

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

One Trackback

  1. By Weekend Reader Woche 35 | fime on January 3, 2014 at 1:59 am

    […] Apple Touch Icons für Webseiten […]

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:


seven × 2 =

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Roger: Thank you for that droplet. Exactly what I was looking for, to see on windows computer which were corrupted...
    • Dieter: Servus Hubi! Zur Info: mit der neuen Mail Version 7.3 (1878.2) in OS X 10.9.3 gibt es KEINE Probleme,...
    • Hubi: Hallo Steffen, Danke Dir für den Code. Ich lasse das jetzt mal so stehen. AppleScript ist aktuell nicht mehr so...
    • Steffen: Okay, das Kommentar war etwas zu voreilig. Ich habe online diesen Code gefunden, der bei mir wunderbar...
    • Steffen: Hallo, gerade habe ich mich über das von dir beschriebe Script gefreut, doch leider komme ich es nicht zu...