• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting info from file without opening it
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting info from file without opening it


  • Subject: Re: Getting info from file without opening it
  • From: "Steven D. Majewski" <email@hidden>
  • Date: Sat, 13 Jan 2007 19:58:42 -0500


Do sips and Image Events handle eps files ? ( I don't know and I don't have one on hand to test at the moment. ) If not, I would take a look at the files: Postscript is text, and usually info like that would be in a Postscript comment ( which you could pull out with 'grep' once you knew what you were looking for. )

The thing about Postscript is, that since it's an image represented
as a program, you don't really know what the result is unless you
open the file and execute the program to produce output. That's why
there are standard comments for things like marking pages in PS :
there's really no way to know how many pages the program will produce
without executing it, so, by convention, comments are used to indicate
pages. This is also one of the reasons for PDF, which (like Quartz) is
the Postscript imaging model without the programming part ( loops,
conditionals, recursion, etc. ).

EPS is Postscript with a few additional conventions to indicate size
of the resulting image (and probably the other info you're looking for).

I don't know what Photoshop's conventions are, but if the info is in
the file, it's probably in a comment near the top of the file.

-- Steve.


On Jan 13, 2007, at 10:05 AM, Gary (Lists) wrote:

"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 (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
40virginia.edu
Archives: http://lists.apple.com/mailman//archives/applescript-users


This email sent to email@hidden

_______________________________________________ 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
References: 
 >Re: Getting info from file without opening it (From: "Gary (Lists)" <email@hidden>)

  • Prev by Date: Returning default pdf reader (was: Returning default browser)
  • Next by Date: Re: Problem accessing Mail
  • Previous by thread: Re: Getting info from file without opening it
  • Next by thread: Returning default browser
  • Index(es):
    • Date
    • Thread