.dsy:it.
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Tech (http://www.dsy.it/forum/forumdisplay.php?forumid=189)
-- [Info] Script random per immagini (http://www.dsy.it/forum/showthread.php?threadid=21130)


Posted by publi on 31-08-2005 16:59:

[Info] Script random per immagini

Nessuno sa dirmi come fare uno script che randomizzi delle immagini in una cartella e le visualizzi ridotte del 50% ?

__________________
Acchiappasogni


Posted by Gusher on 31-08-2005 17:46:

Re: [Info] Script random per immagini

Originally posted by publi
Nessuno sa dirmi come fare uno script che randomizzi delle immagini in una cartella e le visualizzi ridotte del 50% ?


<?php

srand ((float) microtime() * 10000000);
$input = array ("Immagine01.jpg", "Immagine02.jpg", "ImmagineN.jpg" );
$chiavi = array_rand ($input);
$handle = fopen ($input[$chiavi[0]], "rb");
$image = fread($handle, filesize($input[$chiavi[0]]));
fclose($handle);
Header("Content-type: image/jpeg");
echo $image;

?>


Estrae a caso dall'array un immagine.
Per fare il resize dai un occhio alle GD.

In particolare a:

http://it.php.net/manual/en/functio...pyresampled.php
http://it.php.net/manual/en/functio...copyresized.php


Posted by 0m4r on 31-08-2005 19:41:

se il problema è solo visualizzarle senza realmente ridurle di dimensione puoi usare un javascript tipo questo:

code:
function changeImage(){ var image1 = new Image(); image1.src = "image03.gif"; var image2 = new Image(); image2.src = "image05.gif"; var image3 = new Image(); image3.src = "image07.gif"; var image4 = new Image(); image4.src = "image09.gif"; var arrayImage = {image1, image2, image3, image4}; var ranNum= Math.round(Math.random()*4); var r = (ranNum%(arrayImage.length))+1; document.getElementById('img').src = arrayImage[r].src; setTimeout("changeImage()", 1000); }


mentre nella pagina html avrai una cosa del tipo
code:
<html> <head> [omissis] </head> <body onLoad="changeImage();"> <img id="img" src="immagine.gif" width="50%"> </body> </html>

__________________
http://www.twitter.com/0m4r


Posted by N@RV1 on 31-08-2005 21:12:

<%@ Page Language="VB" ContentType="text/html" %>
<form runat="server">
<asp:Image ID="rndImg" runat="server" />
</form>
<SCRIPT language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim Randi as New Random()
rndImg.ImageUrl = Randi.Next(1, 9).ToString() & ".jpg"
End Sub
</SCRIPT>

in asp.net unico difetto e che devi chiamare i file con numeri 1.jpg 2.jpg ecc...

__________________
.:N@RV!:.


Posted by ripe on 01-09-2005 10:50:

Per quanto riguarda il ridimensionamento dinamico dell'immagine, in Asp.Net ho scritto una classe che si occupa di tutto il lavoro. Se ti interessa fammi un fischio!

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by 0m4r on 08-09-2005 11:21:

sei riuscito a trovare uno script utile per il tuo scopo?

__________________
http://www.twitter.com/0m4r


Posted by publi on 08-09-2005 11:42:

Originally posted by 0m4r
sei riuscito a trovare uno script utile per il tuo scopo?


Si scusate se nn ho singraziato, lo faccio ora, ma ero preso da quell'afafre li :D

Grazie a tutti!!! Vi darei un bacio ma siete tutti ometti... :shock:

__________________
Acchiappasogni


All times are GMT. The time now is 09:36.
Show all 7 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.