Solved

Parsing An Image File

Posted on 2002-05-08
8
229 Views
Last Modified: 2012-05-04
I'm trying to get the photo cutline, photo author and extra information from an .eps file created from photoshop. Does anybody know a way to get just that text and at all turn the eps into different sized jpg's and gif's?
0
Comment
Question by:mattsobo
  • 4
8 Comments
 
LVL 2

Accepted Solution

by:
jpoesen earned 100 total points
ID: 6997544
and you want to use php for that? Shouldn't you start with downloading the photoshop SDK and reading the docs ?

Second step would be to use VC++ and the SDK to interact with PS.

Third step would be to make a COM component and talk to it using the PHP COM support functions...

0
 
LVL 32

Assisted Solution

by:Batalf
Batalf earned 100 total points
ID: 6997993
I'm not sure if ImageMagick gives you this information, but it's worth a shot. ImageMagick is a package of software to convert and identify images. It's free at www.imagemagick.org

Convertion:
For converting, you use the tool "convert". It supports convertion of eps to almost any format.

Identifying:
Here's some code I used earlier(for identifying):

         $textFile = "parameters.txt";
         $imageData = exec("identify -verbose 'MyFile.eps' >$textFile");
         $imageDataArray2 = file($textFile);
         for($no=0;$no<count($imageDataArray2);$no++)
         {
                 echo $imageDataArray2[$no]."<br>";
         }

---------------------------------------------------
This gave me an array like this:

         0 - Image: MyFile.eps
         1 - Format: PS (Adobe PostScript)
         2 - Geometry: 210x150
         3 - Class: DirectClass
         4 - Type: true color
         5 - Depth: 8 bits per pixel component
         6 - Colors: 23053
         7 - Filesize: 92kb
         8 - Interlace: None
         9 - Background Color: white
         10 - Border Color: #dfdfdf
         11 - Matte Color: grey74
         12 - Iterations: 0
         13 - Compression:
         14 - comment: Image generated by GNU Ghostscript (device=pnmraw)
         15 -
         16 - signature: 85f2bcbf52437b12c891355c9b4c75719febd2e1bffa32143c75304cbdaf9b7e
         17 - Tainted: False
         18 - User Time: 0.0u
         19 - Elapsed Time: 0:01

Batalf
0
 
LVL 32

Expert Comment

by:Batalf
ID: 6997999
And here's some code for convertion:

exec("convert -geometry 50% MyFile.eps output.jpg");

You may need to add the relative path to the "convert" file as a suffix to convert here.

This code creates output.jpg as a jpg of 50% of the original MyFile.eps.

ps! I'm not sure, but I don't think you could use these kind of tools to get information about the author.

Batalf

0
 
LVL 32

Expert Comment

by:Batalf
ID: 6998019
I tried to create an eps in photoshop now, and the only information I could read from the eps-file when I saved it was this:

%%Creator: Adobe Photoshop Version 6.0
%%Title: test.eps
%%CreationDate: Thu May 09 2002 05:25:52
%%BoundingBox: 0 0 20 20
%%HiResBoundingBox: 0 0 20 20
%%SuppressDotGainCompensation
%%EndComments
%%BeginProlog
%%EndProlog
%%BeginSetup
%%EndSetup
%ImageData: 20 20 8 3 1 20 1 "beginimage"
%BeginPhotoshop: 1542

The information about authour(File->document info) is saved on the first line, but it doesn't seem to be any logic where on the line. So that information is tricky to retreve.

But the other information here seems to be collectable. But if it's a clever idea to let php parse big eps'files is an other thing:-)

Batalf

0
 
LVL 32

Expert Comment

by:Batalf
ID: 6998022
ps! I was able to read the information above when I opened the eps-file in textpad.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question