Jump to content

Recommended Posts

Hi everyone, im using the code i found on the web call dynamic image viewer.

It works great and displays files in my images folder, what i want is to alter the code to resize the images to a fixed size.

Heres all the codes

 

<style type="text/css">

#picturearea{
filter:alpha(opacity=100);
-moz-opacity: 0;
}

</style>

<!-- Change path below to point to "getpics.php" on your server -->
<script src="getpics.php" type="text/javascript"></script>

<script type="text/javascript">

<!-- Dynamic PHP Picture Viewer (v1.0)- By JavaScriptKit.com (http://www.javascriptkit.com) //--->
<!-- For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/ //--->
<!-- This notice must stay intact for use //--->

function populateSelect(selectobj){
for (var i=0; i<picsarray.length; i++)
selectobj.options[selectobj.options.length]=new Option(picsarray[i], picsarray[i])
if (selectobj.options.length>1){
selectobj.selectedIndex=0
showpicture(document.getElementById("picsform").picslist)
}
}

function showpicture(selectobj){
piccontainerobj=document.getElementById("picturearea")
resetfade(10)
piccontainerobj.innerHTML='<img src="'+locationstring+selectobj.options[selectobj.selectedIndex].value+'">'
fadepictoview=setInterval("gradualfade(piccontainerobj)",50)
}

function resetfade(degree){
if (window.fadepictoview)
clearInterval(fadepictoview)
if (typeof piccontainerobj.style.MozOpacity=="string")
piccontainerobj.style.MozOpacity=degree/100
else if (piccontainerobj.filters)
piccontainerobj.filters.alpha.opacity=degree
}

function gradualfade(){
if (typeof piccontainerobj.style.MozOpacity=="string" && piccontainerobj.style.MozOpacity<1)
piccontainerobj.style.MozOpacity=Math.min(parseFloat(piccontainerobj.style.MozOpacity)+0.2, 0.99)
else if (piccontainerobj.filters && piccontainerobj.filters.alpha.opacity<100)
piccontainerobj.filters.alpha.opacity+=20
else //if not IE or Moz
clearInterval(fadepictoview)
}

window.onload=function(){
populateSelect(document.getElementById("picsform").picslist)
}

</script>

 

Code 2

<div style="float: left; width: 200px;">
<form id="picsform">
<select name="picslist" size="4" style="width: 200px" onClick="showpicture(this)">
</select>
</form>
</div>

<div id="picturearea" style="float: left; width: 400px; height: 300px; margin-left: 20px">
</div>

<br style="clear: left" />

<p style="font: normal 11px Arial">This free script provided by<br />
<a href="http://www.javascriptkit.com">JavaScript Kit</a></p>

 

 

Code 3

 

<?
Header("content-type: application/x-javascript");
$pathstring=pathinfo($_SERVER['PHP_SELF']);
$locationstring="http://" . $_SERVER['HTTP_HOST'].$pathstring['dirname'] . "/";

function returnimages($dirname=".") {
 $pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)";
   $files = array();
 $curimage=0;
   if($handle = opendir($dirname)) {
       while(false !== ($file = readdir($handle))){
               if(eregi($pattern, $file)){
                     echo 'picsarray[' . $curimage .']="' . $file . '";';
                     $curimage++;
               }
       }

       closedir($handle);
   }
   return($files);
}

echo 'var locationstring="' . $locationstring . '";';
echo 'var picsarray=new Array();';
returnimages()
?> 

 

Link to comment
https://forums.phpfreaks.com/topic/74587-image-resize/
Share on other sites

Gee... I'm sorry.  I didn't mean to step on your precious tootsies.

 

2.5 mins of searching came up with this...

 

http://tech.mikelopez.info/2006/03/02/php-image-resize-script/

 

Read the instructions therein... and then try to figure out for yourself how to implement it.  A brief look through the code tells me it's exactly what you're after.  How you implement it is entirely up to you.

 

HINT:  The image will be called through the URL to resize it... get my drift?

Link to comment
https://forums.phpfreaks.com/topic/74587-image-resize/#findComment-377744
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.