Image help

Discussion in 'PHP' started by cynical_tear, Nov 2, 2009.

  1. #1
    I have an image uploading website... have a look at this PAGE...

    I want to place this picture in such a way that it appears inside a border,,

    I tried using width and height attribute in img tag but by doing so the images whose dimensions are small are expanded to fit the table...

    Is there any way that i can get the dimensions (width and height) of a image and according to it manipulate the width and height of image in table...

    Hope you get what I am trying to say???

     
    cynical_tear, Nov 2, 2009 IP
  2. cynical_tear

    cynical_tear Peon

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Any one there to help me??
     
    cynical_tear, Nov 2, 2009 IP
  3. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    put a div around image and give width and height to that div. then place image with margin: auto. and don't use image tag rather use style attribute and set image as background to center it vertically as well :)
     
    mastermunj, Nov 2, 2009 IP
  4. cynical_tear

    cynical_tear Peon

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hmmm... just a litle problem.... dnt know how to use div tag....
     
    cynical_tear, Nov 2, 2009 IP
  5. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #5
    it should be something like this.. html and css both are provided..

    
    <div class="image_preview" style="background-image:url(res/img/thumb_2.jpg);"></div>
    
    .image_preview
    {
    	float: left;
    	width: 200px;
    	height: 200px;
    	margin: 0px 0px 10px 10px;
    	border: 1px solid #000000;
    	background-repeat: no-repeat;
    	background-position: center;
    }
    
    HTML:
     
    mastermunj, Nov 2, 2009 IP
  6. cynical_tear

    cynical_tear Peon

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I don't use DIV tag so I have no idea how to use it... i just want to ask that there;s something like ABSOLUTE and RELATIVE in div... can you please tell me what are these to things??? Again if I use this DIV tag then wont it will be placed at different positions on browser on resizing the browser???
     
    cynical_tear, Nov 2, 2009 IP
  7. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    you need to resize it..
    like you calculate the width and height of that image..

    //getting dimintions of picture
    $image = "blabla.jpg";
    list($imgwidth, $imgheight) = @getimagesize("$image");
    
    //now resize pic
    if($imgheight>550)
    {
    $height=500;
    echo "<img src=$image height=$height border=1>";
    }
    
    else
    echo "<img src=$image border=1>";
    PHP:
     
    xenon2010, Nov 2, 2009 IP