Register

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 8 of 8
  1. #1
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Is it possible to include user entered data from a form in a image which PHP creates?

    I read http://builder.com.com/5100-6371-5092227.html so creating is okay but can what I ask be done?

    Also if possible could you link me or include 1 line of code so I can replicate this to include multiple values?

  2.  

  3. #2
    Senior Member Fallout's Avatar
    Join Date
    Aug 2003
    Location
    Richmond, Virginia
    Posts
    543
    Member #
    2748
    Try looking up the various GD functions for text like imagettftext().

  4. #3
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    It's part of the embedded EXIF data.

    I've tried all the READ functions in PHP's exif support, but never tried to WRITE Exif data.

    Check this out:
    http://pel.sourceforge.net/


    EDIT:
    Maybe I misread your post.
    I thought you wanted to include some metadata bundled with the image (like digital cameras include exposure time, date, cameramodel, thumbnail, etc).
    Do you mean text as part of the presented image?
    S. Rosland

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Sorry for the bump, but yes

  6. #5
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    I posted a code like that some time ago.

    Found it:
    PHP Code:
    <?php
    //Guess you can replace the $string with some POST variable. 
        
    header("Content-type: image/jpeg"); 
        
    $string "Some Test Text"
        
    $im     imagecreatefromjpeg("images/subfolder/somePicture.jpg"); 
        
    $green  imagecolorallocate($im9022060); 
        
    $px     = (imagesx($im) - 7.5 strlen($string)) / 2
        
    imagestring($im3$px9$string$green); 
        
    imagejpeg($im); 
        
    imagedestroy($im); 
    ?>
    From this thread:
    http://www.webdesignforums.net/php_a...help_9923.html


    EDIT:
    The script has a binary output, meaning you would have to reference it from another page enclosed in image tags, if you want to combine it with some regular HTML output as well.

    I.e.
    <img src="theImageScript.php">
    S. Rosland

  7. #6
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Thanks, I have got that part working.

    In this case I have a standard image (call it a template) from which I can write text onto.

    Though, once that processing is done and the image is displayed, if I point my browser to defaultfile.jpg the standard image is displayed, the text I entered previously is not (obviously because I do not have code for that).

    So is there a way to take the generated file (which is made up of the standard file and the text, basically the outputted image) and save this as newfile.jpg?

  8. #7
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    If you want to save the image, instead of outputting a stream (displaying it), you can add a filename argument to the imagejpeg() function.

    imagejpeg ( resource image [, string filename [, int quality]] )

    [phpfunction]imagejpeg[/phpfunction]

    ---------

    However, I'm not sure I understand your problem. If you have a page A that displays an image created on the fly from page B, then you can pass the text variable (as in you case) like this:

    Page A
    Code:
    <img src="imageTextScript.php?text=SomeText">
    
    or if you want the text to be dynamic:
    
    <img src="imageTextScript.php?text=<?php echo $text; ?>">
    Page B
    PHP Code:
    $text $_GET['text'];
    //image producing code here 
    S. Rosland

  9. #8
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Thanks I will try the extra argument.

    What I mean is, instead of the image existing purely as a stream (outputting) the image is created and stays resident on my webspace.


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
  •  
All times are GMT -6. The time now is 08:51 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com