53 users online (0 members and 53 guests)  


  Results 1 to 4 of 4

Related

  1. new question on CSS    Forum: CSS Forum
    Replies: 10
  2. Another Question    Forum: HTML Forum
    Replies: 2
  3. AnOtHeR QuEsTiOn    Forum: HTML Forum
    Replies: 1
  4. Question    Forum: HTML Forum
    Replies: 2
  5. another question...    Forum: HTML Forum
    Replies: 6
  1. #1
    cfbergh's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2004
    Posts
    2

    To scale or Not to scale? That is the img question.

    I am displaying two images side by side using

    <tr>
    <td>Before: <img src = "obfuscated jsp"></td>
    <td>After: <img src = "more obfuscation"></td>
    </tr>

    An image pair (before and after) are always the same size, but their size may be too large to view side by side. If relative sizing (say width = 40%) is used, then smaller images come out very tiny. If absolute sizing is used, then smaller images could be stretched - not allowed.

    Does anyone have any suggestions to determine the image size and dynamically set the display width?

  2. #2
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    This could easily be handled by PHP and a MySQL database. Take a look at the PHP scripts listed in our directory

    http://www.ahfb2000.com/php.php

    Tou can have your cells each at 50% and and have your image tags as such:
    PHP Code:
    <img src=source.gif height="x" width="x" alt="x"
    where X is whatever is declared by you for each individule image.

    Dave
    Last edited by HTML; 03-23-2009 at 04:28 PM.

  3. #3
    cfbergh's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2004
    Posts
    2
    Quote Originally Posted by Dave
    This could easily be handled by PHP and a MySQL database. Take a look at the PHP scripts listed in our directory

    thanks. I was looking for a lighter weight solution. Yes, I had thought about thumbnailing them originally, and now I think it is the way to go.

    thanks again
    -c

  4. #4
    mtjo's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    4
    Don't know if you still need this, but if you have PHP, this will auto resize your images according to the w:h ratio to a set thumbnail value. If the image is smaller than the thumbnail value, it displays the actual image dimensions.

    Copy this to a file and give it a name like image_scaler.php
    PHP Code:
    <?php

    class imageThumb
    {
        
    /** Process image url and return <img> with ratio'd values */
        
        
    function displayImage$image_url$thumbnail_size )
        {
            
    $imageSize getimagesize$image_url );
            
            
    $resizeImage  imageThumb::processImage$imageSize$thumbnail_size );
            
            return 
    '<img src="' $image_url '" width="' $resizeImage[0] . '" height="' $resizeImage[1] . '" alt="' $image_url '" title="' $image_url '" />'
        }
            
        
    /** Process image dimensions and resize per thumbnail size to correct ratios */
        
        
    function processImage$imageSize$thumbnail_size )
        {
            
    $image_ratio $imageSize[0] / $imageSize[1];
            
            
    $image_dim = array();
            
            if ( 
    $imageSize[0] < $thumbnail_size && $imageSize[1] < $thumbnail_size 
            {
                return 
    $imageSize;
            } 
            elseif( 
    $imageSize[0] > $imageSize[1] ) 
            {
                
    $image_dim[] = $thumbnail_size;
                
    $image_dim[] = intval$thumbnail_size $image_ratio );
                
                return 
    $image_dim;
            } 
            elseif( 
    $imageSize[0] < $imageSize[1] ) 
            {
                
    $image_dim[] = intval$thumbnail_size $image_ratio );
                
    $image_dim[] = $thumbnail_size;
                
                return 
    $image_dim;
            } 
            else 
            {
                return 
    $imageSize;
            }
        }
    }

    ?>
    In your page where you are displaying the images, add at the top

    PHP Code:
    include 'image_scaler.php';

    /** add this line wherever you want to display the image */
    /** usage: echo  imageThumb::displayImage( 'path/to/image', Max thumbnail size );*/

    echo imageThumb::displayImage'images/some_image.png'43 ); 
    Last edited by mtjo; 01-24-2004 at 12:44 AM.



Tags for this Thread