If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Member #
    The use of GD library causes a lot of headaches for many PHP users (at least for us who are not in the same league as Transio, nsr81 and other gurus).

    I've come across some codesnippets that I've found useful. I thought I could post two of them here in case anybody else struggles with the same.

    The first one extracts embedded MIME data from digital photographs where they exist (typical photos taken with a digital camera) and displays the info as text in an unordered list.
    PHP Code:
    echo "<h3>Test1.jpg:</h3><br />\n"
    $exif exif_read_data ('images/subfolder/image.JPG','IFD0'); 
    $exif===false "No header data found.<br />\n" "Image contains headers<br />"
    $exif exif_read_data ('images/subfolder/pict.JPG',0,true); 
    "<h3>Test2.jpg:</h3><br />\n"
    $exif as $key=>$section) { 
    $section as $name=>$val) { 
    "$key.$name$val<br />\n"
    Most digital cameras also embed thumbnail versions of the full size pictures inside the original. To extract and display it, use the following code:
    PHP Code:

      if (
    header("Content-type: ".image_type_to_mime_type($type)); 
    // no thumbnail available, handle the error here 
    echo "No thumbnail available"
    Needless to say, yoy need the GD library installed and the php_exif.dll in order for them to work. these and others are quite a breeze to install on a windows system.

    I also have a code for extraxting image data and inserting it as blobs in a MySQL table, and a code for extracting and scaling them to your delight, before displaying them. It is not recommended though as it bloats the table with huge amounts of binary data that slows down the database considerably.

    The way I've done it, is to let Photoshop generate a slideshow of a folder containing images I want to upload. I then throw away all the Photoshop generated HTML, and upload the folder containing the downsized original images and the folder containing the thumbnails. This way the whole process is automated versus rescaling the images one by one.
    Does anybody by the way, know how to manipulate the way Photoshop downsizes the originals? In other words is it possible to make the originals downscale less/more than the Photoshop default?

    I've then made a script that reads all the imagefiles in the uploaded folders and writes these filenames to the table containing references to the images. In the same prosess I let PHP add IMG tags along with the filenames so that each row contains a description of the image + the imagereference. The image reference in the table looks like this:
    <input type="hidden" name="picture" value="someImage.jpg">
    <input name="submit" type="image" src="images/thumbnails/someImage.jpg">
    When I extraxt data from this table, I let PHP generate a formfield around each row in the displayed table.The table contains some text and category info plus a thumbnail image. The thumbnail image also functions as submit button that will send you to another page containing the big picture with more detailed comments, when clicked on.

    I guess a more easy way would be to find a PHP code that would resize the big pictures on the fly and present them, but I haven't figured out a way to do this. The before mentioned code that extracts blobs and present them rescaled, only alows to send the images. By that I mean the datastream needs to be sent with image headers and hence effectivly blocking any other information you want to display on the same page.

    There's supposed to be a way to let PHP write the image data stream to a temporary file that again can be called forward by the use of ordinary <img src=""> tags. I haven't figured out how to do this yet. If anybody knows how, please let me know.

    If anybody's interested in the send-to-BLOB, retrieve and rescale from BLOB codes, I can post them as well. I started thinking this post is long enough as it is.
    S. Rosland


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search tags for this page

php gd library exif

Click on a term to search for related topics.
All times are GMT -6. The time now is 09:29 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: