SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Viral's Avatar
    Join Date
    Nov 2001
    Location
    Washington DC
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Image size problem (headers?)

    Guys,

    I've pulled info out of a database and used the GD library to create a dynamic image using PHP. It's working perfectly, and if I go to the output file (image.png) it shows up exactly as it should. However, when I try to use it in a document (<img src="image.png">) it shows up as a dot. Basically, it seems as if it cannot determine the image size. Even if I force an image size using height and width tags, it seems to ignore these and just do whatever it wants (for example, my 580x388 img came out 580x10 or so).

    Is there any way, when creating an image with PHP, to send its dimensions as headers or something so the browser knows? If I right click and view properties, it shows blank entries for height and width.

    What am I doing wrong?
    thanks,
    --Viral
    A computer without Windows is like a chocolate cake without mustard.

  2. #2
    SitePoint Enthusiast xor's Avatar
    Join Date
    Jul 2001
    Location
    New Zealand
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if this will help, I'm just looking it up, I've not actually done any dynamic image generation yet. I hope it's not too far off track. Have a look at these functions, here is some code as an example...



    Code:
    $src = ImageCreateFromJPEG('img.jpg');
    $width = ImageSx($src);
    $height = ImageSx($src);
    So I'm not sure about your question to pass the size in the header, but you may be able to use these functions to dynamically obtain the size then set it in your image tag.

    I'd be interested to know if this helps, or if you otherwise manage to solve this problem.


  3. #3
    SitePoint Addict Viral's Avatar
    Join Date
    Nov 2001
    Location
    Washington DC
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Argh! I feel so stupid. After messing with this file for more than an hour, I tested a "normal" image in it and it had the same behavior. Further investigation revealed that I still had an IMG stylestheet set. I had somehow linked to an older version of my external stylesheet that controlled image height, which is why I wasn't able to override it. pointing back to the correct stylesheet fixed my problem. So everything is working correctly now. thanks for the input!

    --Viral
    A computer without Windows is like a chocolate cake without mustard.


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
  •