Solved

Parsing An Image File

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now