Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi,

I should retrieve meta-data from image (jpg) files programatically in PHP and display them on a web-form. I googled a bit but what I found doesn't make much sense to me. It says something about compiling PHP which is puzzling. I never had to do that.

 

I installed XAMPP in Windows XP that lets me use PHP and mySQL and everything goes smooth so far with the help of two of Larry's books. I never had to compile anything. However in the books there is no reference to EXIF. Does anybody have a link where to start? Or even a book, I wouldn't mind ordering it.

 

thanks in advance

Matt

 

Share this post


Link to post
Share on other sites

thanks Larry. Works like a charm.

For anybody else who might needs this info, here is the section of my php.ini file

 

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
;   extension=msql.dll

, make sure the 2 lines below are un-commented
;

extension=php_mbstring.dll
extension=php_exif.dll

Share this post


Link to post
Share on other sites

Now however I have a new problem. I want to display the thumbnail of the image and the EXIF data on one page. PHP doesn't like it.

 

I can EITHER show the thumbnail when it executes the header statement

header('Content-type: ' .image_type_to_mime_type($type));

but then it does not show any EXIF data

 

OR show the EXIF data by commenting out the header staement

but then it shows the thumbnail as a series of weird characters, like

 

1AQaq"2‘¡±B#ÁRÑð3$bár‚’CS

etc etc.

 

Any feedback appreciated!

thanks,

Matt

<?php
define('MYFILE', 'Avatars\Image17IR.jpg') ;

$width = 0;
$height = 0 ;
$type = '' ;
$imgdat = exif_thumbnail(MYFILE, $width, $height, $type);
if ($imgdat!==false) {
    
    // when the 2 lines below are executed, the thumbnail is shown, but nothing further
    // when the 2 lines below are commented out, the exif data is shown, but the thumbnail is output as garbage
    header('Content-type: ' .image_type_to_mime_type($type));
    echo $imgdat;

    $exif = exif_read_data(MYFILE, 0, true);
    print "<table border=\"1\"><tr><td>Key</td><td>Name</td><td>Value</td></tr><tr>" ;
    foreach ($exif as $key => $section) {
        foreach ($section as $name => $val) {
        print "<td>" . $key . "</td>" ;
        print "<td>" . $name . "</td>" ;
        print "<td>" . $val . "</td>" ;
        print "</tr>" ;    
        }
    }
    print "</table>" ;
   
    // shows garbage, not the image
     echo $imgdat ;
}
?>

Share this post


Link to post
Share on other sites

You can't have a script output both binary data (e.g., an image) and plain text (e.g., HTML). To do this, you'll want to generate HTML that includes an IMG tag that shows the image.

Share this post


Link to post
Share on other sites

Me again.... just a general question, I don't know where to start.

 

I need to display an image in full-screen size, plus add some simple slide-show features (next image, previous image, popup Exif-data when a link or button is pressed, and similar). Just a link or a reference to one of Larry's great books would help me get started.

 

thanks a lot

Matt

Share this post


Link to post
Share on other sites

Full-screening the image is done with simple CSS, and creating a slideshow is mostly JS.

While that topic specifically is not covered in Larry's JS book, you could still probably learn enough in the book to do it yourself.

You could also do some Googling for "JS slideshow", and probably get it done from there.

  • Upvote 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×