Solved

Parsing An Image File

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

829 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