Web Analytics Made Easy -
StatCounter Modify Images on the fly? - CodingForum

Announcement

Collapse
No announcement yet.

Modify Images on the fly?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Modify Images on the fly?

    Hello,
    I want to be able to modify images on the fly for an image gallery,
    and i'm just wondering what the best and simplest way to do this would be?

    I've looked into ImageMagick a little, and i'm just not sure if this is the best program to use,, also i looked on php.net and couldn't find anything about it on the functions list.

    any ideas?

    thanks in advance for your time!
    -Ken

  • #2
    did you look at this part of the manual?

    Comment


    • #3
      umm, ok, is that for imageMagick,, looks like it's for something else,
      also how do i do a simple resize of an image with that??

      thanks again for your time!
      -Ken

      Comment


      • #4
        did you bother looking at that list fucntions? did you look at the imagecopyresized function?

        Comment


        • #5
          ok, kool, that worked!

          but could you maybe help me with one other thing?
          just using that script, with my script.
          i'm getting a parse error:
          Parse error: parse error in Gallery.php on line 273

          which is:
          PHP Code:
          <? echo resizepics('images/$sub_value['PicName']''120''80'); ?>" border=0>

          any help would be great!

          thanks in advance for your time!
          -Ken
          Last edited by angst; Jul 29, 2005, 02:08 PM.

          Comment


          • #6
            ok, think i'm a little closer to whats going on here,,
            for some reason, if I use any html in the page before i call the function, i get that header already sent error,

            why is this? is there something wrong with this script??

            PHP Code:
            <?
            $ImageName 
            "Bikini006.jpg";

            echo 
            '<img src='.resizepics('images/' $ImageName '''120''80').'>';
            echo 
            "<br /><br />";
            #//Error
            #die( "<font color=\"#FF0066\"><center><b>File not exists :(<b></center></FONT>");
            //Funcion resizepics
            function resizepics($pics$newwidth$newheight){
                 if(
            preg_match("/.jpg/i""$pics")){
                       
            header('Content-type: image/jpeg');
                 }
                 if (
            preg_match("/.gif/i""$pics")){
                       
            header('Content-type: image/gif');
                 }
                 list(
            $width$height) = getimagesize($pics);
                 if(
            $width $height && $newheight $height){
                   
            $newheight $height / ($width $newwidth);
                 } else if (
            $width $height && $newwidth $width) {
                   
            $newwidth $width / ($height $newheight);
                 } else {
                   
            $newwidth $width;
                   
            $newheight $height;
               }
               if(
            preg_match("/.jpg/i""$pics")){
               
            $source imagecreatefromjpeg($pics);
               }
               if(
            preg_match("/.jpeg/i""$pics")){
               
            $source imagecreatefromjpeg($pics);
               }
               if(
            preg_match("/.jpeg/i""$pics")){
               
            $source Imagecreatefromjpeg($pics);
               }
               if(
            preg_match("/.png/i""$pics")){
               
            $source imagecreatefrompng($pics);
               }
               if(
            preg_match("/.gif/i""$pics")){
               
            $source imagecreatefromgif($pics);
               }
               
            $thumb imagecreatetruecolor($newwidth$newheight);
               
            imagecopyresized($thumb$source0000$newwidth$newheight$width$height);
               return 
            imagejpeg($thumb);
               if(
            preg_match("/.jpg/i""$pics")){
               return 
            imagejpeg($thumb);
               }
               if(
            preg_match("/.jpeg/i""$pics")){
               return 
            imagejpeg($thumb);
               }
               if(
            preg_match("/.jpeg/i""$pics")){
               return 
            imagejpeg($thumb);
               }
               if(
            preg_match("/.png/i""$pics")){
               return 
            imagepng($thumb);
               }
               if(
            preg_match("/.gif/i""$pics")){
               return 
            imagegif($thumb);
               }
             }
            ?>
            I put the <br /><br /> in there just to test, if u move it above the echo, two things happen, i get that error, and the image comes out as code, like a bunch of junk. if i move it down, it's runs fine.. whats going on here?


            thanks again for your time!

            Comment


            • #7
              if your getting a header error then most of the time its cause some information is already been sent to the browser then you try to edit the information and it dont like that. make sure there is nothing before this script, i mean nothing, not a blank line not a space...nothing

              Comment

              Working...
              X