Solved

Parsing An Image File

Posted on 2002-05-08
8
231 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

726 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