Results 1 to 4 of 4
Related
-
new question on CSS Forum: CSS Forum
Replies: 10 -
Another Question Forum: HTML Forum
Replies: 2 -
AnOtHeR QuEsTiOn Forum: HTML Forum
Replies: 1 -
Question Forum: HTML Forum
Replies: 2 -
another question... Forum: HTML Forum
Replies: 6
-
01-13-2004, 09:29 PM #1
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></tr>
<td>After: <img src = "more obfuscation"></td>
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?
-
01-13-2004, 09:47 PM #2
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">
DaveLast edited by HTML; 03-23-2009 at 04:28 PM.
-
01-14-2004, 12:37 AM #3
Originally Posted by Dave
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
-
01-24-2004, 12:27 AM #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;
}
}
}
?>
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.
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum