Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: resizing image

  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    resizing image

    hey guys i got my upload code

    PHP Code:
    <?php
        
    if(isset($_POST['uploaded'])){
        
    /**
         * PROCESS FORM
         */

        // %% debugging info
        
    dbg_out($_SESSION);
        
    dbg_out($_FILES);
          
    // Input
        
    $s_image $_GET['image']; // Image url set in the URL. ex: thumbit.php?image=URL
        
    $e_image "error.jpg"// If there is a problem using the file extension then load an error JPG.
        
    $max_width 100// Max thumbnail width.
        
    $max_height 250// Max thumbnail height.
           
    $quality 100// Do not change this if you plan on using PNG images.

        // Resizing and Output : Do not edit below this line unless you know what your doing.

        
    if (preg_match("/.jpg/i""$s_image"))  {

        
    header('Content-type: image/jpeg');
          list(
    $width$height) = getimagesize($s_image);
        
    $ratio = ($width $height) ? $max_width/$width $max_height/$height
        if(
    $width $max_width || $height $max_height) { 
        
    $new_width $width $ratio
        
    $new_height $height $ratio
        } else {
        
    $new_width $width
        
    $new_height $height;
        } 
          
    $image_p imagecreatetruecolor($new_width$new_height);
        
    $image imagecreatefromjpeg($s_image); 
        
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height);
        
    imagejpeg($image_pnull$quality); 
        
    imagedestroy($image_p); 

        }
           elseif (
    preg_match("/.png/i""$s_image"))  {

        
    header('Content-type: image/png');
          list(
    $width$height) = getimagesize($s_image);
        
    $ratio = ($width $height) ? $max_width/$width $max_height/$height
        if(
    $width $max_width || $height $max_height) { 
        
    $new_width $width $ratio
        
    $new_height $height $ratio
        } else {
        
    $new_width $width
        
    $new_height $height;
        } 
        
    $image_p imagecreatetruecolor($new_width$new_height);
        
    $image imagecreatefrompng($s_image); 
        
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height);
        
    imagepng($image_pnull$quality); 
        
    imagedestroy($image_p); 

        }
           elseif (
    preg_match("/.gif/i""$s_image"))  {

        
    header('Content-type: image/gif');
          list(
    $width$height) = getimagesize($s_image);
        
    $ratio = ($width $height) ? $max_width/$width $max_height/$height
        if(
    $width $max_width || $height $max_height) { 
        
    $new_width $width $ratio
        
    $new_height $height $ratio
        } else {
        
    $new_width $width
        
    $new_height $height;
        } 
        
    $image_p imagecreatetruecolor($new_width$new_height);
        
    $image imagecreatefromgif($s_image); 
        
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height);
        
    imagegif($image_pnull$quality);
        
    imagedestroy($image_p); 

        }
           else {

        
    // Show the error JPG.
        
    header('Content-type: image/jpeg');
        
    imagejpeg($e_imagenull$quality); 
        
    imagedestroy($e_image); 

        } 
        
        
    // First line of error checking, make sure upload successful
        
    if($_FILES['image']['error'] !== UPLOAD_ERR_OK){
          echo 
    'Error: There was an error with your upload.';
          exit();
        }

        
    // Now we know we have an uploaded file, let's check the type
        
    $image_size getimagesize($_FILES['image']['tmp_name']);
        if(
    $image_size === FALSE){
          echo 
    'Error: getimagesize() has failed.';
          exit();
        }

        
    // Debug print the mime type that was found
        
    dbg_out($image_size['mime']);
        
    $img_arr explode('/'$image_size['mime']);
        if(
    count($img_arr) != 2){
          echo 
    'Error: Problem with image type';
          exit();
        }
        
    $type $img_arr[0];         // mime type
        
    $ext $img_arr[1];          // file extension
        
    if(strlen($type) == || strlen($ext) == 0){
          
    // Neither of those vars can be zero length
          
    echo 'Error: No type or extension found';
          exit();
        }
        if(
    $type != 'image'){
          
    // Not an image!
          
    echo 'Error: Uploaded file was not an image';
          exit();
        }

        
    //get users ID
        
    $id $_SESSION['user_id'];

        
    //don't continue if an image hasn't been uploaded
        
    if(is_uploaded_file($_FILES['image']['tmp_name'])){
            
    // set destination directory
            
    $dst realpath(dirname(__FILE__) . '/images') . '/' $id
                    
    '.' $ext;
            
    dbg_out($dst); // %%
            
    if(move_uploaded_file($_FILES['image']['tmp_name'], $dst)){
              
    // Success, file has been moved and renamed
              // now do whatever else is necessary
              
    dbg_out('SUCCESS!'); // %%
              
    $Clean = Array();
              
    $Clean['user_id'] = "'"
                                
    mysql_real_escape_string($id
                                . 
    "'";
              
    $Clean['ext'] = "'" 
                            
    mysql_real_escape_string($ext
                            . 
    "'";
     
    $sql "DELETE FROM `user_images` WHERE `user_id`={$Clean['user_id']}";
              
    $q mysql_query($sql);
              if(
    $q === FALSE){
                
    dbg_out('ERROR: ' mysql_error());
              }else{
                
    dbg_out('Database delete successful');
              }
              
    $sql "
                INSERT INTO `user_images` 
                  (`user_id`, `ext`, `created`, `modified`)
                VALUES (
                  {$Clean['user_id']}, {$Clean['ext']}, NOW(), NOW()
                )
              "
    ;
              
    $q mysql_query($sql);
              if(
    $q === FALSE){
                
    dbg_out('ERROR: ' mysql_error());
              }else{
                
    dbg_out('Database insert successful');
              }          }
            }
          }
        
    /* Everything else you had is irrelevant at this point */
      

      /**
       * remove this function later and all calls to it
       */
      
    function dbg_out($msg){
        if(
    is_bool($msg)){
          
    $msg $msg '[TRUE]' '[FALSE]';
        }else if(
    is_null($msg)){
          
    $msg '[NULL]';
        }else if(
    is_string($msg) && strlen($msg) == 0){
          
    $msg '[EMPTY STRING]';
        }
        echo 
    '<pre style="text-align: left;">'
           
    print_r($msgtrue)
           . 
    '</pre>';
      }

      
    session_start();
      require_once 
    '../settings.php';

        
    /**
         * DISPLAY FORM
         */
    ?>
        <form action="" method="post" enctype="multipart/form-data">
          Upload:<br><br>
          <input type="file" name="image"><br><br>
          <input type="hidden" name="uploaded" value="1">
          <input type="submit" value="Upload">
        </form> ?>
    and i think i got the script that will resize the image

    PHP Code:
    <?php 
    function gdresizetofile($source,$dest,$type,$max_width=420,$max_height=500){
        
    // Get sizes
        
    list($width$height) = getimagesize($source);
        
    //width
        
    if($width>$max_width){
            
    $divide=$width/$max_width;
            
    $newwidth=$width/$divide;
            
    $newheight=$height/$divide;
            
            
    // Load
            
    $image imagecreatetruecolor($newwidth$newheight);
            switch(
    strtolower($type)){
            case 
    'jpg':
                
    $old_image imagecreatefromjpeg($source);
                break;
            case 
    'gif':
                
    $old_image imagecreatefromgif($source);
                break;
            case 
    'png':
                
    $old_image imagecreatefrompng($source);
                break;
            }
            
    // Resize
            
    imagecopyresized($image$old_image0000$newwidth$newheight$width$height);
        }else{
            switch(
    $type){
            case 
    'jpg':
                
    $image imagecreatefromjpeg($source);
                break;
            case 
    'gif':
                
    $image imagecreatefromgif($source);
                break;
            case 
    'png':
                
    $image imagecreatefrompng($source);
                break;
            }
        }
        
    // Output
        
    imagejpeg($image);


    }
    ?>
    but i cant seem to fit the two together any help guys
    Last edited by runnerjp; 01-19-2008 at 02:53 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    You don't need to squeeze them together, the resize script you have is written in a function call.
    All you need is your original image (uploaded), your destination image and some resizing information.
    The function call itself is kind of odd, it appears to require a destination but makes no use of it and doesn't return a result. If you change the destination paramater to be passed by reference, then you can use it in the imagecopyresized call and it will alter the original. Then you don't even need to output the result to an image jpeg.
    Does that help you at all? I really don't want to go through the first script of code if I can avoid it...
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    hey i thought i knew what you where on about but after looking at it and stuff i got no where so i need some more direction to go in lol


    rlly sorry

  • #4
    New Coder
    Join Date
    Jan 2008
    Location
    Portugal
    Posts
    17
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Hi,

    Your upload code already resizes the image.

    If you don't think it resizes well or, if by any reason you want to use the function (the second code you posted) you just have to copy-paste that second code bit and call that funcion in your upload file instead of the resize code you run on it.

    Let us know if you need further help.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Not a problem, lets take a look see at your code here. I will warn you its been awhile since I've created an image with PHP, but I should still be able to help.

    Ok, your function (thats the second block of code you created), you need to make a decision. My recommendation is to either take a reference to a destination variable, or to return the result as an image resource instead of displaying it. It is up to you of course, but logically this function is to create the new image it does not seem right to me to actually display the image.
    In fact, I would recommend instead creating sub functions and chain them to this function so that you can basically ignore the 'type' requirement.
    IE:
    PHP Code:
    function imageResizeJPG(...);
    function 
    imageResizeGIF(...); 
    for example, and in those methods call the method you have created already:
    PHP Code:
    function imageResizeJPG($source, &$dest$width 420$height 500)
    {
        
    // I will just call the function, as my idea uses the 'referenced' $dest variable, so that one will actually be changed:
        
    gdresizetofile($source$dest'jpg'$width$height);

    And your function code would remain the same (except with my example you would reference the $dest variable).
    Your function itself will probably need some simple modifications to the actual size calculations - what if I give it a size of 400 x 10000, it will still take it and 'squish' it into fit. That is aesthetic and I'll leave that to you for determination.

    Now, your primary script.
    Ah, ok there are some more calculations for the sizes. Change those and place them into the actual function, they do not belong in the primary script anymore.
    We will pull out the original type of an image from the mime associated with it. This is retrievable from the getimagesize() function. You have a lot of other stuff, error checking (good, keep it in there) in your script that I will ignore. So, we end up with code something like this:
    Note, I misintrepreted what your $type had been used for - I was under the impression that it was used for saving to a different format. I won't change my post above, but will alter for this. With this in mind, returning the result is probably the best option.
    PHP Code:
    function imageResize($source$maxWidth 420$maxHeight 500)
    {
        
    $bNeedsResize false;
        list (
    $width$height$type) = getimagesize($source);
        
    $oWidth $width;
        
    $oHeight $height;

        if (
    $width <= || $height <= 0):
            throw new 
    Exception('Cannot generate image from no height / width!');
        endif;

        
    // Err, these equations 'look' right, but I can't test them atm to be sure
        
    if ($width $maxWidth):
            
    // Calculate an appropriate width:
            
    $ratio $maxWidth $width;
            
    $width ceil($width $ratio);
            
    $height ceil($height $ratio);
            
    $bNeedsResize true;
        endif;
        if (
    $height $maxHeight):
            
    $ratio $maxHeight $height;
            
    $width ceil($width $ratio);
            
    $height ceil($height $ratio);
            
    $bNeedsResize true;
        endif;
        
    // Ok, that will resize it to keep it in preportion for both height/width
        
    $image imagecreatetruecolor($width$height);
        
    $imageFrom null;
        switch(
    $type):
            case 
    'jpg':
                
    $imageFrom = @imagecreatefromjpeg($source);
                break;
            case 
    'gif':
                
    $imageFrom = @imagecreatefromgif($source);
                break;
            case 
    'png':
                
    $imageFrom = @imagecreatefrompng($source);
                break;
        endswitch;
        
        
    // Ok, we got ourself an new image.  Looks like it will require a JPG output,
        // but lets see if we need to resize it first:
        
    if ($bNeedsResize):
            if (!
    imagecopyresized($image$imageFrom0000$width$height$oWidth$oHeight)):
                throw new 
    Exception('Could not resize image!');
            endif;
        else:
            
    // Ok, we don't need to resize it:
            
    $image $imageFrom;
        endif;
        
        
    header('Content-type: image/jpeg');
        
    imagejpeg($image);
        
    imagedestroy($image);

    mmkay, that looks sorta right, can't test it atm, so don't replace it until you've tested it! Note though that this will NOT resize an image to the specified size, rather it will force it to be within the bounds (if I did my calculations correctly lol). So if you give it an image that is say, 500x1000, it will take the width down to 420, and the height to 840 in the first step, then it will take the height down to 250 and the width down to 500. This will keep it proportional.
    Now all you should have to do is feed in the uploaded image to the script along with (optional) width and size proportions. You don't need to implement the extra stuff in the primary script. Since we're throwing exceptions from the function, you can try/catch it to determine if there is an error in the generation for it.

    Does this answer your question well enough, or do you need a little more info?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #6
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    well tried to get it workin messed around with it but i still dont think im there so more help would be gr8

  • #7
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    could i not add a function so as the image gets uploaded it resizes it there and then>?

  • #8
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    ok i got image resize working ...
    Code:
    PHP Code:
    <?php


    //load the config file
    include("config.php");
    require_once 
    '../settings.php';


    //if the for has submittedd
    if (isset($_POST['upForm'])){

           
    $file_type $_FILES['imgfile']['type'];
           
    $file_name $_FILES['imgfile']['name'];
           
    $file_size $_FILES['imgfile']['size'];
           
    $file_tmp $_FILES['imgfile']['tmp_name'];

           
    //check if you have selected a file.
           
    if(!is_uploaded_file($file_tmp)){
              echo 
    "Error: Please select a file to upload!. <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";
              exit(); 
    //exit the script and don't do anything else.
           
    }
           
    //check file extension
           
    $ext strrchr($file_name,'.');
           
    $ext strtolower($ext);
           if ((
    $extlimit == "yes") && (!in_array($ext,$limitedext))) {
              echo 
    "Wrong file extension.  <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";
              exit();
           }
           
    //get the file extension.
           
    $getExt explode ('.'$file_name);
           
    $file_ext $getExt[count($getExt)-1];

    //get users ID
        
    $id $_SESSION['user_id'];
        
          
          
    //get the new width variable.
           
    $ThumbWidth $img_thumb_width;

           
    //keep image type
           
    if($file_size){
              if(
    $file_type == "image/pjpeg" || $file_type == "image/jpeg"){
                   
    $new_img imagecreatefromjpeg($file_tmp);
               }elseif(
    $file_type == "image/x-png" || $file_type == "image/png"){
                   
    $new_img imagecreatefrompng($file_tmp);
               }elseif(
    $file_type == "image/gif"){
                   
    $new_img imagecreatefromgif($file_tmp);
               }
               
    //list width and height and keep height ratio.
               
    list($width$height) = getimagesize($file_tmp);
               
    $imgratio=$width/$height;
               if (
    $imgratio>1){
                  
    $newwidth $ThumbWidth;
                  
    $newheight $ThumbWidth/$imgratio;
               }else{
                     
    $newheight $ThumbWidth;
                     
    $newwidth $ThumbWidth*$imgratio;
               }
               
    //function for resize image.
               
    if (function_exists(imagecreatetruecolor)){
               
    $resized_img imagecreatetruecolor($newwidth,$newheight);
               }else{
                     die(
    "Error: Please make sure you have GD library ver 2+");
               }
               
    imagecopyresized($resized_img$new_img0000$newwidth$newheight$width$height);
               
    //save image
               
    ImageJpeg ($resized_img,"$path_thumbs/$id.$file_ext");
               
    ImageDestroy ($resized_img);
               
    ImageDestroy ($new_img);
               
    //print message
               
    echo "<br>Image Thumb: <a href=\"$path_thumbs/$id.$file_ext\">$path_thumbs/$id.$file_ext</a>";
            }

            
    //upload the big image
            
    move_uploaded_file ($file_tmp"$path_big/$id.$file_ext");

            echo 
    "<br>Image Big: <a href=\"$path_big/$id.$file_ext\">$path_big/$id.$file_ext</a>";

            echo 
    "<br><br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";

    }else{ 
    //if the form hasn't been submitted.

          //print the form
          
    echo "<script>
          function view_img(img_name){
             document[img_name].src = upForm.imgfile.value;
                document[img_name].width = 150;
          }
          </script>\n\n
          <br><h3>:: Browse an Image to Upload:</h3>\n
          <form method=\"post\" name=\"upForm\" enctype=\"multipart/form-data\" action=\"$_SERVER[PHP_SELF]\">\n
          <input type=\"file\" name=\"imgfile\" onchange=\"javascript:view_img('img_vv');\"> <img src='' name='img_vv' width='0'><br>\n
          Image width will resize to <b>$img_thumb_width</b> with height ratio.
          <br><input type=\"Submit\" name=\"upForm\" value=\"Upload & Resize\">\n
          </form>
          <a href=\"view_gallery.php\">View Images</a>"
    ;

    }


    ?>
    but it wont rename the image to user id Huh $id = $_SESSION['user_id'];

    that got through going to require_once '../settings.php'; which then directs you to require ( 'functions.php' ); then in that it has


    Code:
    PHP Code:

     
    function checkLogin $levels )
        {
            
    session_start ();
            global 
    $db;
            
    $kt split ' '$levels );
            
            if ( ! 
    $_SESSION['logged_in'] ) {
            
                
    $access FALSE;
                
                if ( isset ( 
    $_COOKIE['cookie_id'] ) ) {//if we have a cookie
                
                    
    $query =  'SELECT * FROM ' DBPREFIX 'users WHERE ID = ' $db->qstr $_COOKIE['cookie_id'] );

                    if ( 
    $db->RecordCount $query ) == ) {//only one user can match that query
                        
    $row $db->getRow $query );
                        
                        
    //let's see if we pass the validation, no monkey business
                        
    if ( $_COOKIE['authenticate'] == md5 getIP () . $row->Password $_SERVER['USER_AGENT'] ) ) {
                            
    //we set the sessions so we don't repeat this step over and over again
                            
    $_SESSION['user_id'] = $row->ID;                
                            
    $_SESSION['logged_in'] = TRUE;
                            
                            
    //now we check the level access, we might not have the permission
                            
    if ( in_array get_level_access $_SESSION['user_id'] ), $kt ) ) {
                                
    //we do?! horray!
                                
    $access TRUE;
                            }
                        }
                    }
                }
            }
            else {            
                
    $access FALSE;
                
                if ( 
    in_array get_level_access $_SESSION['user_id'] ), $kt ) ) {
                    
    $access TRUE;
                }
            }
            
            if ( 
    $access == FALSE ) {
                
    header('Location: http://runningprofiles.com/members/index.php');
            }        
        } 

    but all i get is Image Thumb: images/thumbs/.jpg were is users id?

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Hmm, must have missed your previous posting, glad you got some headway though!
    Its likely due to the 'concept' of the file uploading - mainly the move_uploaded_file (i think thats what its called, you can see its been awhile ). If you are trying to do that with an image created through PHP (ie, imagejpeg/gif/png, etc), that won't do the trick. The difference is, the moving of the file is referring to the file in the temporary storage on the server's filesystem, and you are moving it to a more persistent location.
    Imagejpeg is one of the few image commands that allow direct dump to a file if I'm not mistaken. Instead of trying to move it, try to store it:
    PHP Code:
    // I'm going to call the 'created' image $image
    header('Content-type: image/jpeg');
    imageJPEG($image'/path/to/my/file/storage/IMAGENAME.jpeg');
    imageDestroy($image); 
    Edit:
    Know what, I completely missed the point, and I see you are already doing this, lol.
    The problem is that _SESSION doesn't exist. You can remedy this by ensuring that session_start() is placed at the beginning of this file, the config.php file, or the settings.php file. That should fix that up for you! This assumes that the _SESSION does exist however, so I'd recommend running against an appended sort of option, change the name to something like:
    'image' . $id . '.jpeg'
    Clean out that $id as well, replace any special characters with htmlspecialchars or htmlentities.
    Good luck, looks like you almost have it!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #10
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    well tried adding session start and i belive i allready have it as Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/runningp/public_html/members/uploader.php:6) in /home/runningp/public_html/members/uploader.php on line 3

    shows

    PHP Code:
    <?php

    session_start
    ();
    //load the config file
    include("config.php");
    require_once 
    '../settings.php';

    its wierd as it actually works with this but still displays error Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/runningp/public_html/members/uploader.php:6) in /home/runningp/public_html/members/uploader.php on line 3

    so session start is the key but if it works why do i get the warning error?

  • #11
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    also is there away to convert all the diff images into say .jpeg so i dont have to store data in db

    so uploaded me.gif would be turned into 1.jpeg

  • #12
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Yep, as long as your using the imageJPEG function it stores the image it created as a jpeg - the input image source type is irrelivant as long as you can create off of it.
    The warning you are recieving is because there is already output to the browser at some location before the session_start is being called. The session itself I do believe works correctly, but I don't think it can set cookies as long as you are receiving that. This is generally caused by characters before your <?php in the script - make sure there are not any spaces, newlines, null bytes (from word if you use it), or anything before the start of the language call. This is generally the case. Oh, and anywhere you use a header() as well, make sure that you have no previous output to the browser.
    A cheap way of getting around this is to enable your output buffering, which you likely have disabled (don't worry, its common to be disabled). To do that, you go like so:
    PHP Code:
    <?php
    // Must make sure that you have NO Characters of any kind before the <?php
    ob_start();
    session_start();

    // All of your script here
    // the output buffer should flush at the end anyway, but I like to do my own.
    // I like the way the commands sound :D
    ob_end_flush();
    ?>
    You will get more familiar with output buffering if you decide to use a different image format. As I mentioned, most of them don't have auto saving features, so you need to do something like the following to save to a file:
    PHP Code:
    ...
    ob_start();
    header("Content-type: image/gif");
    imagegif($image);
    $binImage ob_get_contents();
    ob_end_clean();
    // now just write the $binImage to a file / db.  I won't do this though, 
    // as file handling and db insertions are extremely easy. 
    Let me know if you have any other problems!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #13
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    smashing it works great.... im still having trouble with the renaming an exe file to a jpg ??

    thnakyou for taking the time at writing clear startements it is really a huge help indeed

  • #14
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    NP mate. I'm also learning to support users better myself, as I tend to be too technical at times lol.
    Not sure why you need to rename an exe as a jpg, it won't execute without the correct extensions unless the user authorizes it. If you just need to rename it, look at using the rename() command.
    Best of luck in the future for you
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #15
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    well i was tryin to aviode putting it all into a db when i call it because i call it likeeee echo "<img src='http://www.runningprofiles.com/members/images/". $pid . "." . $row['ext'] . "'";

    but i wanna do it so a db is not used so can call /images/". $pid . " .jpeg


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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