Размерите ....

Teodotko

Registered
Код:
 <script type="text/javascript">
var links=new Array();
var width=new Array();
var height=new Array();
<?php
include("config.php");
$dir=opendir("$directory");
$i=0;
while($file=readdir($dir)) {
$ext=strtolower(end(explode(".",$file)));
if($ext=="png" || $ext=="gif" || $ext=="jpeg" || $ext=="jpg") {
list($width,$height,$type,$attr)=getimagesize("$directory$file");
echo "links[$i]=\"$directory$file\";\n";
echo "width[$i]=$width;\n";
echo "height[$i]=$height;\n";
$i++;
}
}
closedir($dir);
?>
function $(div) {
return document.getElementById(div);
}
function loadImage() {
while(width[0]>screen.width-200 || height[0]>screen/height-200) {width[0]/=2; height[0]/=2;}
$('image').src=links[0];
$('image').style.left=screen.width/2-width[0]/2;
$('image').style.top=screen.height/2-height[0]/2-50;
$('image').style.width=width[0];
$('image').style.height=height[0];
}
var curr=0;
function next() {
if(curr==links.length-1) return;
curr++;
while(width[curr]>screen.width-200 || height[curr]>screen/height-200) {width[curr]/=2; height[curr]/=2;}
$('image').src=links[curr];
$('image').style.left=screen.width/2-width[curr]/2;
$('image').style.top=screen.height/2-height[curr]/2-50;
$('image').style.width=width[curr];
$('image').style.height=height[curr];
}
function previous() {
if(curr==0) return;
curr--;
while(width[curr]>screen.width-200 || height[curr]>screen/height-200) {width[curr]/=2; height[curr]/=2;}
$('image').src=links[curr];
$('image').style.left=screen.width/2-width[curr]/2;
$('image').style.top=screen.height/2-height[curr]/2-50;
$('image').style.width=width[curr];
$('image').style.height=height[curr];
}
function key() {
var keyid=event.keyCode;
if(keyid==37) {previous(); $('prevlink').style.color="#ffffff";}
if(keyid==39) {next(); $('nextlink').style.color="#ffffff";}
}
function key1() {
var keyid=event.keyCode;
if(keyid==37) $('prevlink').style.color="#00ffff";
if(keyid==39) $('nextlink').style.color="#00ffff";
}
</script>
</head>
<body onload="loadImage();" onkeydown="key1();" onkeyup="key();">
<div id="title">TechnoForce Simple Gallery</div>
<img id="image" alt="Image" />
<div id="links"><a href="javascript:void(0);" onclick="previous();" id="prevlink"><<</a> <a href="javascript:void(0);" onclick="next();" id="nextlink">>></a></div>
</center>


Как да направя картинките да излизат оразмерени и по-малки .
Вижте сега как е - www.test.bulstar.info/gallery.php
 
офф абе това ми е галерията бе .... Другото е дизайн .

ЕДИТ : В config-a има само $style = blue
 
Код:
<script type="text/javascript">
var links=new Array();
var width=new Array();
var height=new Array();
<?php
include("config.php");
$dir=opendir("$directory");
$i=0;
while($file=readdir($dir)) {
$ext=strtolower(end(explode(".",$file)));
if($ext=="png" || $ext=="gif" || $ext=="jpeg" || $ext=="jpg") {
list($width,$height,$type,$attr)=getimagesize("$directory$file");
echo "links[$i]=\"$directory$file\";\n";
echo "width[$i]=$width;\n";
echo "height[$i]=$height;\n";
$i++;
}
}
closedir($dir);
?>
function $(div) {
return document.getElementById(div);
}
function loadImage() {
while(width[0]>screen.width-200 || height[0]>screen/height-200) {width[0]/=2; height[0]/=2;}
$('image').src=links[0];
$('image').style.left=screen.width/2-width[0]/2;
$('image').style.top=screen.height/2-height[0]/2-50;
$('image').style.width=width="150";
$('image').style.height=height="150";
}
var curr=0;
function next() {
if(curr==links.length-1) return;
curr++;
while(width[curr]>screen.width-200 || height[curr]>screen/height-200) {width[curr]/=2; height[curr]/=2;}
$('image').src=links[curr];
$('image').style.left=screen.width/2-width[curr]/2;
$('image').style.top=screen.height/2-height[curr]/2-50;
$('image').style.width=width[curr];
$('image').style.height=height[curr];
}
function previous() {
if(curr==0) return;
curr--;
while(width[curr]>screen.width-200 || height[curr]>screen/height-200) {width[curr]/=2; height[curr]/=2;}
$('image').src=links[curr];
$('image').style.left=screen.width/2-width[curr]/2;
$('image').style.top=screen.height/2-height[curr]/2-50;
$('image').style.width=width[curr];
$('image').style.height=height[curr];
}
function key() {
var keyid=event.keyCode;
if(keyid==37) {previous(); $('prevlink').style.color="#ffffff";}
if(keyid==39) {next(); $('nextlink').style.color="#ffffff";}
}
function key1() {
var keyid=event.keyCode;
if(keyid==37) $('prevlink').style.color="#00ffff";
if(keyid==39) $('nextlink').style.color="#00ffff";
}
</script>
</head>
<body onload="loadImage();" onkeydown="key1();" onkeyup="key();">
<div id="title">TechnoForce Simple Gallery</div>
<img id="image" alt="Image" />
<div id="links"><a href="javascript:void(0);" onclick="previous();" id="prevlink"><<</a> <a href="javascript:void(0);" onclick="next();" id="nextlink">>></a></div>
</center>
 
http://www.web-tourist.net/forum/viewtopic.php?t=69954
Има го с javascript има го и с php на 2-рата страница

JS начин:
jooorooo каза:
<script>
function rs(r, mw, mh) {
var width = r.width;
var height = r.height;

ratio1=width/mw;
ratio2=height/mh;
if(ratio1>ratio2) {
thumb_w=mw;
thumb_h=height/ratio1;
}
else {
thumb_h=mh;
thumb_w=width/ratio2;
}

r.width = thumb_w;
r.height = thumb_h;
}
</script>

<img src="http://pacharoza.esut.eu/kola_2.jpg" onload="rs(this, 300, 300)" />


При този начин просто голямата картинка я визуализира в по малък вариан. Т.е. неудачно е защото картинката ще се зарежда повече време всеки път.


PHP начин:
StormBreaker каза:
Намерих я функцията :)

make_thumbnail( $_FILES['file']['tmp_name'], $Maksimum_6irina_ili_viso4ina, $kade_da_go_ka4i );

Ползвам си я за директно оразмеряване при качването на картинката. Аз си качвам оригинала и си правя и малка.

EDIT:: За различно от jpg ей сега ще го оправя
EDIT 2:: Вече може да работи с gif, png и jpg
EDIT 3 :D : Най-добре при качване да правиш малкото копие, защото при повече снимки ако ги правиш всеки път с php при изкарване ще се бави. Имах една галерия и ползвах динамично ресайзване с php и се бавеше доста.

function make_thumbnail($tmp_name, $t, $path)
{
list($width, $height, $type) = getimagesize($tmp_name);

if ($width > $height)
$percentage = ($t / $width);
else
$percentage = ($t / $height);

$w = round($width * $percentage);
$h = round($height * $percentage);

$image_p = imagecreatetruecolor($w, $h);

if ( $type == 1 )
$image = imagecreatefromgif($tmp_name);
elseif ( $type == 2 )
$image = imagecreatefromjpeg($tmp_name);
elseif ( $type == 3 )
$image = imagecreatefrompng($tmp_name);

imagecopyresampled($image_p, $image, 0, 0, 0, 0, $w, $h, $width, $height);

if ( $type == 1 )
imagegif($image_p, $path);
elseif ( $type == 2 )
imagejpeg($image_p, $path, 80);
elseif ( $type == 3 )
imagepng($image_p, $path);

return true;
}

Тук се създава нова картинка с по малките размери

Използвам информацията само за да ти помогна
 

Back
Горе