Thursday, October 6, 2022

#1 2005-10-13 03:15:05 pm

From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

How can I get/set the resolution/size/format/etc of this image?

Since the release of Panther and AppleScript 1.9.2, you can use the built-in scriptable application "Image Events" (located within your "/System/Library/CoreServices" folder).

Just browse its dictionary and pick what you need. With this tool you can rotate, flip or crop images. Here is a sample to get the properties of an image:


tell application "Image Events"
   set theImg to open alias "path:to:image.jpg"
   set imgInfo to properties of theImg
   close theImg
end tell

imgInfo --> {bit depth:millions of colors, file type:JPEG, image file:file "path:to:image.jpg" of application "Image Events", location:folder "path:to:" of application "Image Events", resolution:{72.0, 72.0}, class:image, dimensions:{981.0, 922.0}, name:"image.jpg", color space:RGB}

For more samples, under Jaguar, search in your disk for items starting with "Image - ", and you will find some folder action samples using Image Events.

You can also access this tool from shell scripts. Just type "sips -h" and "sips -H" in a Terminal window.

If you are not still in Panther or you need more power, you can try scripting some powerful scriptable applications, such as GraphicConverter, Photoshop, or the command-line tool called ImageMagick.

Filed under: image



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)