Re: Getting info from file without opening it
Re: Getting info from file without opening it
- Subject: Re: Getting info from file without opening it
- From: "Gary (Lists)" <email@hidden>
- Date: Sat, 13 Jan 2007 10:05:26 -0500
"Simon, Garry" wrote:
> Hello, does anyone know if it's possible to use a script to get information
> about an image file without opening the file? For instance, I would like to
> know if a Photoshop created eps is grayscale, RGB, CMYK, etc. Perhaps there is
> a shell script that can do it?
There are minimally two pieces of AppleScriptable software pre-installed and
useful for this sort of task. (I suppose there is arguably just one, and
the second is a kind of wrapper around the first.)
Check out the Image Events dictionary [it's a pre-installed scripting
addition] and the Unix tool 'sips' [which I think is the basis for Image
Events anyway].
For example, Image Events offers access to these kinds of data about an
on-disk image:
==================================================
image -- An image contained in a file
* Plural name:
o images
* Inherits from:
o item
* Properties:
o color space (r/o) Eight channel / Eight color / Five channel /
Five color / Seven channel / RGB / Lab / XYZ / Six channel / CMYK / Six
color / Seven color / Named / Gray -- color space of the image's color
representation
o resolution (r/o) list -- the pixel density of the image, in dots
per inch, as a pair of integers
o bit depth (r/o) sixteen colors / color / four grays / black &
white / thousands of colors / grayscale / two hundred fifty six grays / four
colors / sixteen grays / millions of colors / best / two hundred fifty six
colors / millions of colors plus -- bit depth of the image's color
representation
o name (r/o) Unicode text -- the name of the image
o dimensions (r/o) list -- the width and height of the image,
respectively, in pixels, as a pair of integers
o image file (r/o) file -- the file that contains the image
o file type (r/o) PICT / Photoshop / BMP / QuickTime Image / GIF /
JPEG / MacPaint / JPEG2 / SGI / PSD / TGA / Text / PDF / PNG / TIFF -- file
type of the image's file
o location (r/o) disk item -- the file location of the image
* Elements:
o metadata tag -- by name, index, relative, range, filter
==================================================
There are loads more classes, properties and commands for dealing with image
data, scaling, and the like.
The Unix tool 'sips' offers the same kind of data, but is available from the
command line or via a 'do shell script' call in AppleScript if you prefer to
use the tool that way.
Image Events is not very well advertised, since lots of folks ask about this
kind of thing.
In the drop-based tool that I wrote for my use, I ended up using 'sips'
calls just a bit more because I determined (not scientifically) that is was
a bit faster for my purposes. YMMV.
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden