14 Replies - 1890 Views - Last Post: 28 February 2011 - 10:31 AM Rate Topic: -----

#1 ccorlett7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 12-January 10

PHP to extract information from JPEG files

Posted 24 February 2011 - 09:16 AM

Hi everyone,

I'm working on a project at the minute, with the intention to be able to extract information from JPG files and then write this information to .kml files. Is it possible, using PHP, to extract information stored in the EXIF data at specific offsets?

For example, the information I want may be at offset 20 and 8 bits long....is there a way I can use PHP to get this information, parse is out and copy it to a new file?

Also, can PHP be used to create desktop based, .exe applications?

Cheers for your help!
Chris

Is This A Good Question/Topic? 0
  • +

Replies To: PHP to extract information from JPEG files

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 09:26 AM

Quote

For example, the information I want may be at offset 20 and 8 bits long....is there a way I can use PHP to get this information, parse is out and copy it to a new file?


Don't see why not. PHP has a full set of filesystem-related functions.

Quote

lso, can PHP be used to create desktop based, .exe applications?


PHP is not a compiled language. There may exist some PHP-to-EXE compiler, but I am not aware of one.
Was This Post Helpful? 0
  • +
  • -

#3 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 09:28 AM

PHP - exif_read_data

Try implementing that
Was This Post Helpful? 0
  • +
  • -

#4 ccorlett7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 12-January 10

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 09:31 AM

cheers guys!

I've not even started the programming yet, I'm creating Class Diagrams in order to try and visualise the system I am creating.

I am very much stuck!!

Would it be easier, better, more effective to do this kind of program in Java or C?
Was This Post Helpful? 0
  • +
  • -

#5 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 09:39 AM

Like JackOfAllTrades said, I don't think PHP can be a single program on a computer.

If you wanted something like that you would need to install PHP and a Web Server onto the computer that has the php program and then you could run the PHP Pages on the Local Web Server

This post has been edited by VolcomMky: 24 February 2011 - 09:44 AM

Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 09:45 AM

You can run PHP on the command line, you don't need to run a webserver (trust me, I'm doing that right now as I work).
Was This Post Helpful? 0
  • +
  • -

#7 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3717
  • View blog
  • Posts: 5,979
  • Joined: 08-June 10

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 09:47 AM

View Postccorlett7, on 24 February 2011 - 05:16 PM, said:

Also, can PHP be used to create desktop based, .exe applications?

You could try YouTube's HipHop. Converts PHP into C++, which you should then be able to compile into .EXE files.

VolcomMky said:

Like JackOfAllTrades said, I don't think PHP can be a single program on a computer.

If you wanted something like that you would need to install PHP and a Web Server onto the computer that has the program installed and then you could run the PHP Pages on the Local Web Server

Yes it can. PHP is a fully capable interpreted programming language. You can run your PHP code directly using the PHP interpreter and it will run just like any other program on your PC. There are even desktop GUI extension specifically made to allow us to create desktop apps. (Like PHP-GTK)
See Command line usage in the manual for examples.
Was This Post Helpful? 0
  • +
  • -

#8 ccorlett7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 12-January 10

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 09:51 AM

so I could make this application in PHP to be web based as well as having the potential to be turned into a .exe desktop application?

This sounds useful, cheers guys!!

Anyone have an idea as to the best way to start off programming this?
Was This Post Helpful? 0
  • +
  • -

#9 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 09:51 AM

It is true that you can run it from the command line.

I never do, I get confused and lost to easily.
Honestly not even sure what it does or is capable of....
Advantages?
Disadvantages?
Was This Post Helpful? 0
  • +
  • -

#10 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3717
  • View blog
  • Posts: 5,979
  • Joined: 08-June 10

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 10:12 AM

View Postccorlett7, on 24 February 2011 - 05:51 PM, said:

so I could make this application in PHP to be web based as well as having the potential to be turned into a .exe desktop application?

You usually have to design the two a bit differently, but I suppose you could do that if you designed it right. (Code separation; use OOP and a good design pattern so you can easily swap out the generated output.)



View PostVolcomMky, on 24 February 2011 - 05:51 PM, said:

Honestly not even sure what it does or is capable of....
Advantages?
Disadvantages?

It's capable of (almost) everything web-based PHP apps are, and a few additional things.
You could do everything from writing simple maintainance scripts to creating complex desktop apps. You could probably even write 3D games and stuff like that. - It's just another programming language. And a pretty powerful one at that.

A disadvantage would be that it is interpreted, so it's (generally) slower to execute than compiled or managed apps, like C/C++ or .NET. Less than ideal for resource-intensive apps.

An advantage is that the PHP interpreter is pretty simple to use, and you can ship it with your apps so you don't need any runtime libraries or virtual machines, like is the case with .NET and Java. (For example.)
Was This Post Helpful? 0
  • +
  • -

#11 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 10:28 AM

Okay, so another question, I programmed a processing page as a cron job because the time it takes to complete the process, would it timeout or complete the job no matter how long it took IF I ran it from the command line?
Was This Post Helpful? 0
  • +
  • -

#12 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3717
  • View blog
  • Posts: 5,979
  • Joined: 08-June 10

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 10:34 AM

If you put set_time_limit(0); at the top of the script, the process will finish no matter how long it takes.

I don't know if this is possible on Windows, but on Linux (and Unix, so I suppose Macs are included) you can append & to the end of the command to make it spawn a separate process for the PHP script, thus returning you to the CLI and leaving the PHP script to work in the background. Like
$ php my_script.php &

This post has been edited by Atli: 24 February 2011 - 10:34 AM

Was This Post Helpful? 1
  • +
  • -

#13 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: PHP to extract information from JPEG files

Posted 24 February 2011 - 10:41 AM

makes sense to me, thanks!
Was This Post Helpful? 0
  • +
  • -

#14 ccorlett7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 12-January 10

Re: PHP to extract information from JPEG files

Posted 28 February 2011 - 06:52 AM

View PostVolcomMky, on 24 February 2011 - 09:28 AM, said:

PHP - exif_read_data

Try implementing that


cheers, i've had a read of that, looks useful.

however, there doesnt seem to be an option that allows you to specify an offset to start from and a length in order to retrieve specific data. I am looking at retrieving geotag information from the EXIF data, which is stored at certain locations depending on the make and model of the device.
Was This Post Helpful? 0
  • +
  • -

#15 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: PHP to extract information from JPEG files

Posted 28 February 2011 - 10:31 AM

Are you trying to find what the make and model is?
I tested this and it worked for me, I am not sure what you are trying to find but what I found seemed to be working for me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1