Apple's Automator: compression settings for jpg?

前端 未结 5 1844
滥情空心
滥情空心 2021-02-04 12:53

When I run Apple\'s Automator to simply cut a bunch of images in their size Automator will also reduce the quality of the files (jpg) and they get blurry.

How can I pr

5条回答
  •  无人共我
    2021-02-04 13:30

    Automator’s “Crop Images” and “Scale Images” actions have no quality settings – as is often the case with Automator, simplicity trumps configurability. However, there is another way to access CoreImage’s image manipulation facilities whithout resorting to Cocoa programming: the Scriptable Image Processing System, which makes image processing functions available to

    1. the shell via the sips utility. You can fiddle with the most minute settings using this, but as it is a bit arcane in handling, you might be better served with the second way,
    2. AppleScript via Image Events, a scriptable faceless background application provided by OS X. There are crop and scale commands, and the option of specifying a compression level when saving as a JPEG with

      save  as JPEG with compression level (low|medium|high)
      

      Use a “Run AppleScript” action instead of your “Crop” / “Scale” one and wrap the Image Events commands in a tell application "Image Events" block, and you should be set. For instance, to scale the image to half its size and save as a JPEG in best quality, overwriting the original:

      on run {input, parameters}
          set output to {}
          repeat with aPath in input
              tell application "Image Events"
                  set aPicture to open aPath
                  try
                      scale aPicture by factor 0.5
                      set end of output to save aPicture as JPEG with compression level low
                  on error errorMessage
                      log errorMessage
                  end try
                  close aPicture
              end tell
          end repeat
          return output -- next action processes edited files.
      end run
      

      – for other scales, adjust the factor accordingly (1 = 100 %, .5 = 50 %, .25 = 25 % etc.); for a crop, replace the scale aPicture by factor X by crop aPicture to {width, height}. Mac OS X Automation has good tutorials on the usage of both scale and crop.

提交回复
热议问题