SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast icky_thump's Avatar
    Join Date
    Nov 2007
    Location
    St. Louis, MO, USA
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    convert to jpg on upload

    Hi all,

    I hate asking such a vague question but I'm really stuck. I did not build this site and am struggling to figure it out.

    I have a page with thumbnails you can click to spring a lightbox which is capable of having a gif animate within it. (That first one pink ad should animate when you lightbox it)

    I have another page that uploads the animated gif but it will not allow the animation to play. (The loaded orange ad "3 new..." should be animating)

    I cannot figure out what the issue with that second page is. I just want the animations on the gif to play.
    Any feedback is greatly appreciated!
    Pandora can't go back into the box - he only comes out.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,016
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    I'm not sure if this helps much, but if you include the image in the page without piping it through the sample.php script, then it works as expected.
    Ergo, something in this script is causing it to break.

    Can you post the contents of sample.php?

  3. #3
    SitePoint Enthusiast icky_thump's Avatar
    Join Date
    Nov 2007
    Location
    St. Louis, MO, USA
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pullo, thanks a ton for looking at it. I'm realizing looking back at my post how bad it was. I started posted thinking it was one thing, then switched my thinking mid-post. A bit cornfusing, but you get it.

    Anyway, here is the code:

    PHP Code:
    <?php
    //$path = "http://images.templatemonster.com/screenshots/".$_GET["nm"]; //---Sample String for other's site data


    $path=$_GET["nm"];


    $string $_GET['text'];
    $jpeg fopen($path,"r");
    while (!
    feof($jpeg)) {
      
    $data .= fread($jpeg8192);
    }

    $mwidth=$_GET["mwidth"];
    $mheight=$_GET["mheight"];

    define(MAX_WIDTH$mwidth);
    define(MAX_HEIGHT$mheight);

    $img null;

    $img = @imagecreatefromstring($data);

    if (
    $img) {

        
    # Get image size and scale ratio
        
    $width imagesx($img);
        
    $height imagesy($img);
        
    $scale min(MAX_WIDTH/$widthMAX_HEIGHT/$height);

        
    # If the image is larger than the max shrink it
        
    if ($scale 1) {
            
    $new_width floor($scale*$width);
            
    $new_height floor($scale*$height);

            
    # Create a new temporary image
                    
            
    $tmp_img imagecreatetruecolor($new_width$new_height);

            
    $bgColor imagecolorallocate($tmp_img255,25,255);
            
    imagefill($tmp_img 0,$bgColor);

            
    # Copy and resize old image into new image
            
    imagecopyresampled($tmp_img$img0000,
                             
    $new_width$new_height$width$height);
                    
            
    imagedestroy($img);
            
    $img $tmp_img;
        }
    }

    # Create error image if necessary
    if (!$img) {
        
    $img imagecreate(MAX_WIDTHMAX_HEIGHT);
        
    imagecolorallocate($img,0,0,0);
        
    $c imagecolorallocate($img,70,70,70);
        
    imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2);
        
    imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2);
    }

    # Display the image
    header"Content-type: image/jpeg");
    $orange imagecolorallocate($img22021060);
    $px    = (imagesx($img) - 7.5 strlen($string)) / 2;
    imagestring($img3$px9$string$orange);
    imagejpeg($img);
    imagedestroy($img);
    imagedestroy($tmp_img); 
    ?>
    Pandora can't go back into the box - he only comes out.

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,016
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    No problem

    What happens if you change:

    PHP Code:
    header"Content-type: image/jpeg"); 
    to:

    PHP Code:
    header('Content-Type: image/gif'); 
    at the end of the file?

  5. #5
    SitePoint Enthusiast icky_thump's Avatar
    Join Date
    Nov 2007
    Location
    St. Louis, MO, USA
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was wondering the same thing but it seemed to have no affect.

    I made this change as well
    PHP Code:
    // imagejpeg($img);
    imagegif($img); 
    i deleted the gif and uploaded it again in the admin panel.
    still does not animate.
    Pandora can't go back into the box - he only comes out.

  6. #6
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,016
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Shame!

    I'v ejust been doing some Googling and it seems that manipulating gifs in this way, does tend to destroy the animation.

    So, let's come at it from a different angle.
    What do you want your PHP script to do?

  7. #7
    SitePoint Enthusiast icky_thump's Avatar
    Join Date
    Nov 2007
    Location
    St. Louis, MO, USA
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, i found the same thing just now googling around. i downsized the animation in fireworks so it still works, then uploaded it but it still was not animating.

    My goals is to have that page function just like it is.
    AND
    have the gifs animate.

    obviously something has to change with the page to get the animation but hopefully that change will only be in the code/scripting. if i have to have the page a bit different, then so be it.
    Pandora can't go back into the box - he only comes out.

  8. #8
    SitePoint Enthusiast icky_thump's Avatar
    Join Date
    Nov 2007
    Location
    St. Louis, MO, USA
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually the ideal would be what i just wrote AND be able to play videos too.
    but that might be a second discussion.
    Pandora can't go back into the box - he only comes out.

  9. #9
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,016
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by icky_thump View Post
    My goals is to have that page function just like it is.
    AND
    have the gifs animate.
    Yeah, but you're piping the images through the sample.php script before displaying them on your page.
    What should sample,php actually do?
    Should it check the size of the images and resize them if necessary?

    Quote Originally Posted by icky_thump View Post
    actually the ideal would be what i just wrote AND be able to play videos too.
    but that might be a second discussion.
    Yup
    One thing at a time.


Bookmarks

Posting Permissions

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