CSS img-resize Problems
Josh-
Royal Oak, MI
<style> .img-resize { position: relative; width: 10%; height: 10%; } </style>I am not understanding how it resizes the image. It's been bugging at me for a while, since I like to have things be perfect. It's for a picture gallery, coded in PHP, and backed by a mySQL database. Pretty much created from scratch, with some reference. Although, this image resizing thing is making me get a large headache, literally speaking.
If the image was 400x100, then the area of the image would be 40,000. (I believe) 10% of 40,000 is 4,000. But, instead, (remember this is an example), it would resize it to about 8,000, or so. I am totally confused about this. Hopefully one of you understand, since I said this rather illiterately.
Thanks for any help that you may be possible to give.
-J
0
Comments
Here it is without the <style></style> tags.
How to do it right?.. I don't know Maybe Google for it. Good luck
That's what I meant by "see what's taking place" -- the %s aren't based on the images, but the browser window size.
-J
[php]
<!--START OF HTML-->
<p align="center">
<? echo $name ?><br>
<a href="<? echo $message ?>"><img src="<? echo $message ?>" class="img-resize" border="0"></a><br>
</p>
<? } ?>
[/php]
It uses something similar to that, I'm not positive it is that, word for word, but its close. I am going to attempt to make a table, 5 rows 5 columns, that would create 25 spaces, I assume. Perhaps then the different tables can confine the images and the titles of the image to that table, not extending or making the rows or columns larger then they should be. Hopefully, this works, as I don't want to start re-doing things majorly.
-J
What it does is gets the size of the image via PHP, then cuts them down to 10%. Then just ECHOs out the new dimensions! Feel free to shoot me questions.
[PHP]
<?php
$img_size = getimagesize($message);
$width = $img_size[0] * 0.1 //10% of original size
$height = $img_size[1] * 0.1 //10% of original size
?>
<!--START OF HTML-->
<p align="center">
<? echo $name ?>
<a href="<? echo $message ?>"><img src="<? echo $message .'" width="'. $width .'" height="'. $height .'"'; ?> border="0"></a>
</p>
<? } ?>
[/PHP]
More on getimagesize function.
[php]
<?
$img_size = getimagesize($message);
$width = $img_size[0] * 0.1; //10% of original size
$height = $img_size[1] * 0.1; //10% of original size
print <<< EOL
<div align="center">
$name<br />
<a href="$message"><img src="$message"width="$width" height="$height" border="0" alt="$named" /></a>
</div>
EOL;
?>
[/php]
$height = $img_size[0] * 0.1; //10% of original size
should be
$height = $img_sizeb]1[/b * 0.1; //10% of original size
Enjoy
- Park
[php]
Array
(
[0] => 640
[1] => 412
[2] => 2
[3] => width="640" height="412"
[bits] => 8
[channels] => 3
[mime] => image/jpeg
)
[/php]
I think [2] is the file type. 1 = gif, 2 = jpg.
I'm busy and have to leave at the moment, but I will try them later and tell you the results.
-J