GD Library Help

Discussion in 'Programming' started by mcmuney, Feb 16, 2008.

  1. #1
    I have a image upload script that uploads images and renames all files and give it a .jpg extension. I'm using GD Library, which creates thumbnails. For the most part, it works. The problem arises when an animated GIF is uploaded. The image uploads fine and the file is renamed with .jpg extension and you can view the file as normal. The issue comes into play when the thumbnail is generated, it creates 1-200 thumbnails. Here's an example:

    THIS IS THE NORMAL PROCESS:
    Actual Image File Uploaded: abc.jpg
    Renamed by Script and Stored on Server: 1.jpg
    Thumb Create by GD Library: 1-85x66-filled-enlarged.jpg

    PROBLEM AREA:
    Actual Image File Uploaded: abcD.gif
    Renamed by Script and Stored on Server: 2.jpg
    Thumb Create by GD Library: (this will result in the following thumbs anywhere from 1-200 thumbs)
    2-85x66-filled-enlarged-0.jpg
    2-85x66-filled-enlarged-1.jpg
    2-85x66-filled-enlarged-2.jpg
    2-85x66-filled-enlarged-3.jpg
    2-85x66-filled-enlarged-4.jpg

    But it doesn't create 2-85x66-filled-enlarged.jpg, this is the file the script looks to display. Any ideas on why this happens and how to correct it?
     
    mcmuney, Feb 16, 2008 IP
  2. HiTEC

    HiTEC Well-Known Member

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    The script i think create 1 thumb for each gif anim frame?

    am i right?
     
    HiTEC, Feb 16, 2008 IP
  3. mcmuney

    mcmuney Well-Known Member

    Messages:
    834
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    128
    As Seller:
    100% - 0
    As Buyer:
    100% - 3
    #3
    Hmmm, that didn't occur to me, but you might be right. That would explain why it would create somewhere between 1-200 thumbs. Any way to fix that?

    Good catch!!!

     
    mcmuney, Feb 17, 2008 IP
  4. dotcomguy

    dotcomguy Peon

    Messages:
    824
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Yeh, I think HiTec is correct each frame within the gif going through the process.

    use the GIFEncoder class in GD
     
    dotcomguy, Feb 17, 2008 IP
  5. mcmuney

    mcmuney Well-Known Member

    Messages:
    834
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    128
    As Seller:
    100% - 0
    As Buyer:
    100% - 3
    #5
    I'm not familiar with the GIFEncoder class, can someone modify my gd script?
     
    mcmuney, Feb 18, 2008 IP
  6. Sygon

    Sygon Peon

    Messages:
    439
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Well when you convert an animated GIF to a JPEG, your not expecting for it to be animated still are you?
     
    Sygon, Feb 19, 2008 IP