Write Exif Data into Image

Hello guys, Any other way to write exif data into image, i search all over the web but nothing give the right one, most of them are just read exif. I tried Php Exif Library but it doesn’t work for me, i didn’t know what my mistake. I actually trying to set gps (lat and lon) into image. Please help me to seek for the solution. Appreciate your help :smile:

I know you can write some basic text on an image… Been awhile but it’s something like this.

$my_img = imagecreatefrompng("../images/blank.png");
$text_color = imagecolorallocate( $my_img, 0, 0, 0 );
imagestring( $my_img, 2, 30, 74, $lat, $text_color );
imagestring( $my_img, 2, 32, 92, $lon, $text_color );
$Newfilename = "../images/newimage.png";
if(!file_exists($Newfilename)){
    imagepng($my_img, $Newfilename);
}

Are you in a position to write the EXIF data into the file before it gets uploaded? If so, there are numerous products that can add to what the file comes with; Photoshop is the obvious one, but the software supplied with the camera can usually do it to.

It would help but the instruction given to me is not to use any third party software. This will just coded purely in PHP. :slight_smile:

Thank you for you suggestion, but what i really need is to set the gps (latitude and longitude) of an image. Do you have any idea how to this? TIA :smile:

I know I’m asking basic questions here, but where is the GPS data coming from if it’s not already embedded within the images? Would I be right in thinking that (regardless of the write method to the file) someone is going to have to sit manually entering that data into an input screen for the system? If that’s the case, how many images are you dealing with? If it’s a lot, that sounds like a particularly laborious, and error prone, task.

Sorry if i let you confused, yah you are right, anyways how about only one photo? I’m only dealing with one photo every process.

Maybe my search terms were different, but I spotted this StackOverflow post that looks like it gets somewhere close to what you want:

http://stackoverflow.com/questions/5384962/writing-exif-data-in-php

Any use to you?

Just to make it clear: This is what i’m working, an api that responses xml.
http://ip/api/gps.php?img= photo/v1/sample.jpeg&gpslon=104.067923&gpslat=30.679943
originally the values are base64 encoded.
img= image full path – photo/v1/sample.jpeg
gpslon= decimal degree format – 104.067923
gpslat = decimal degree format – 30.679943
from the given path (img) there is a query parameter (gpslon and gpslat ) that will set or update the lon and lat of an image then save it from exif data of it. I tried so many ways but it doesn’t save. Thank you.

I tried IPTC already but only headers can but exif gps data can’t. They also provided some library such PHP Exif Library (PEL) but it doesnt work on my side. Have you ever tried PEL? Thank you for your help, i really appreciate.

I should just caveat my comments by saying that I’m not a developer of any sort, as much as I tinker (I’m a project manager by day, and only moonlight here). I’m just thinking out loud really, as to how I see the issue you’re trying to solve. I’ve done loads of photography though, so can see the issue from a content creation perspective.

TL:DR; I’ve about exhausted the level of knowledge I have on the subject

One other random thought - does the system have the necessary permissions to write into the image file? Are you seeing any error messages at all, either on screen or in the logs?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.