Current location: Hot Scripts Forums » General Community » Script Requests » need an image to video script

need an image to video script

Reply
  #1 (permalink)  
Old 07-10-09, 12:28 AM
Mike Anime Mike Anime is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
need an image to video script

I have a script that shows images on a page like so. http://animerealmz.net/TF_gallery.php

what i need is a script that will let me place X number of thumbnailed images like on the page link above but instead of them going to full sized images i want them to go to videos i plan to upload to my site



like thTF01.jpg goes to TF01.jpg i want it to go from thTF01.jpg to something like TF01.avi (or what ever format i end up with.


here is the script i use now

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<LINK href="style2.css" rel=stylesheet>

</head>
<body>


<!-- START main -->


<table border="0" cellpadding="0" cellspacing="0" align="center">

<?php


// max image width/height
$config['size'] = 150;
// jpeg thumbnail image quality
$config['imagequality'] = 200;

// rows of images per page
$config['rows'] = 5;

// columns of images per page
$config['cols'] = 5;

// max page numbers to show at once
$config['maxShow'] = 10;

$config['start'] = 0;
$config['max'] = 0;
$config['page'] = isset($_GET['page'])?$_GET['page']:"0";

// folder where full size images are stored (include trailing slash)
$config['fulls']="TF_video/";

// folder where thumbnails are to be created
$config['thumbs'] = "$config[fulls]thumb";

// method to create thumbnails. options: gd1, gd2, imagemagick
$config['imagemethod'] = "gd2";             

// (if imagemagick) - Path to Imagemagick "convert" program
$config['convert'] = "/usr/bin/convert";
// (if imagemagick) - Path to Imagemagick "identify" program
$config['identify'] = "/usr/bin/identify";


#######################################################################
//see if dir exits, if not create
if(isset($_GET['entry'])){
    
GetEntry();
}else{
    
PrintThumbs();
}
#######################################################################


#-#############################################
# desc: prints out html for thumbnails of images in directory
function PrintThumbs(){
    global 
$config;

    if (!
file_exists($config['fulls'])) { 
        
oops("directory <b>$config[fulls]</b> does not exist");
        die;
    }
    
//thumb directory
    
if (!file_exists($config['thumbs'])) { 
        if (!
mkdir($config['thumbs'], 0755)) {
            
oops("Could not create thumb directory <b>$config[thumbs]</b> - check write permissions");
            die;
        }
    }

   
$imagelist GetFileList($config['fulls']);
//   echo count($imagelist);

    //processing for how many images to do on current page
    
$config['start']=($config['page']*$config['cols']*$config['rows']);
    
$config['max']=( ($config['page']*$config['cols']*$config['rows']) + ($config['cols']*$config['rows']) );

    if(
$config['max'] > count($imagelist)){$config['max']=count($imagelist);}

echo 
"<tr><td align=\"right\" colspan=\"$config[cols]\" style=\"padding:3px;\" class=\"border\">\n";
#if there is 0 matches, show 0. otherwise show ($start+1)
if ($config['max'] == "0"){echo "Showing results <b>0 - 0</b> of <b>0</b></td></tr>\n";}
else{echo 
"Showing results <b>".($config['start']+1)." - $config[max]</b> of <b>".count($imagelist)."</b> entries</td></tr>\n";}


echo 
"<tr>";

    
$temp=1;
    
//for all the images on the page
    
for($i=$config['start']; $i<$config['max']; $i++){


        
$thumb_image $config['thumbs']."/".$imagelist[$i];
        
$thumb_exists file_exists($thumb_image);

        
// create thumb if not exist
        
if(!$thumb_exists){
            
set_time_limit(30);
            
$thumb_exists ResizeImage("$config[fulls]$imagelist[$i]"$thumb_image$config['size']);
        }

        
$imagelist[$i] = rawurlencode($imagelist[$i]);
        
$thumb_image $config['thumbs']."/".$imagelist[$i];

        echo 
"<td valign=\"bottom\" align=\"center\" class=\"border\" bgcolor=000000><a href=\"$config[fulls]$imagelist[$i]\" title=\"$imagelist[$i]\" target=\"_blank\">"
        if (
$thumb_exists) {
            echo 
"<img src=\"$thumb_image\" border=\"0\" alt=\"$imagelist[$i]\">";
        } else {
            echo 
"$imagelist[$i]";
        }
        echo 
"</a></td>\n";


        
//if the max cols is reached, start new col
        
if(($temp == $config['cols']) && ($i+!= $config['max'])){
            echo 
"</tr><tr><td colspan=\"$config[cols]\" class=\"spacer\">&nbsp;</td></tr><tr>\n";
            
$temp=0;
        }
        
$temp++;
    }
//foreach img

    //if there are no results
    
if($config['start'] == $config['max']){
        echo 
"<td align=\"center\" colspan=\"$config[cols]\" class=\"spacer\">No Entries found</td>\n";
    }
    
//if there are empty "boxes" in the row (ie; last page)
    
elseif($temp != $config['cols']+1){
        echo 
"<td align=\"center\" colspan=\"".($config['cols']-$temp+1)."\">&nbsp;</td>\n";
    }


    echo 
"</tr>";
GetPageNumbers(count($imagelist));

}
#-#PrintThumbs()


#-#############################################
# desc: grabs and prints filename
# returns: (bool) worked
function GetEntry(){
    global 
$config;

if(!
file_exists("$config[fulls]$_GET[entry]")){
    
oops("Entry does not exist");
    return 
false;
}

echo 
"<a href=\"$_SERVER[HTTP_REFERER]\">Back</a><br>";
echo 
"<img src=\"$config[fulls]$_GET[entry]\">";


}
#-#GetEntry()


#-#############################################
# desc: GetFileList
# param: [optional] directory to look through
# returns: array with list of images
function GetFileList($dirname="."){
    global 
$config;
    
$list = array(); 

    if (
$handle opendir($dirname)) {
        while (
false !== ($file readdir($handle))) { 
            if (
preg_match("/\.(jpe?g|gif|png)$/i",$file)) { 
                
$list[] = $file;
            } 
        }
        
closedir($handle); 
    }
    
sort($list);

    return 
$list;
}
#-#GetFileList()


#-#############################################
# desc: throw an error message
# param: [optional] any custom error to display
function oops($msg) {
?>
<table align=center>
<tr><td class=header>
Error
</td></tr>

<tr><td class=entry>
    <br><?=$msg?>
    <br><br>
    <hr size=1 noshade width="80%" class=desc>
    <center>Please hit the <a href="javaScript:history.back();"><b>back button</b></a> on your browser to try again.</center>

</td></tr></table>
<?php
}#-#oops()


#-#############################################
# desc: chooses method to resize image to correct ratio
# param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to
# returns: (bool) if image was created
function ResizeImage($image$newimage$size) {
   global 
$config;
   
    switch (
$config['imagemethod']) {
        case 
"imagemagick":
        return 
ResizeImageUsingIM($image$newimage$size);
            break;
        case 
"gd1":
        case 
"gd2":
            return 
ResizeImageUsingGD($image$newimage$size);
            break;
        default:
            return 
false;
            break;
    }
}
#-#ResizeImage()


#-#############################################
# desc: resizes image if GD was used
# param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to
# returns: (bool) if image was created
function ResizeImageUsingGD($image$newimage$size) {

    list (
$width,$height,$type) = GetImageSize($image);

    if(
$im ReadImageFromFile($image,$type)){
        
//if image is smaller than the $size, make it actual $size
        
if($height $size && $width $size){
            
$newheight=$height;
            
$newwidth=$width;
        }
        
//if image height is larger, height=$size, then calc width
        
else if($height $width){
            
$newheight=$size;
            
$newwidth=($width / ($height/$size));//cast the resized width as int
        
}
        
//if image width is larger, width=$size, then calc width
        
else{
            
$newwidth=$size;
            
$newheight=($height / ($width/$size));//cast the resized height as int
        
}

        
$im2=ImageCreateTrueColor($newwidth,$newheight);
        
ImageCopyResampled($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height);

        if(
WriteImageToFile($im2,$newimage,$type)){
            return 
true;
        }
    }

return 
false;
}
#-#ResizeImageUsingGD()


#-#############################################
# desc: resizes image using imagemagick
# param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to
# returns: (bool) if image was created
function ResizeImageUsingIM($image$newimage$size) {
   global 
$config

   
Exec("$config[identify] -ping -format \"%w %h\" \"$image\""$sizeinfo);

   if (! 
$sizeinfo ) {
      return 
false;
   }
   
$size explode(" "$sizeinfo[0]);
   
$width  $size[0];
   
$height $size[1];

   if (!
$width) {
      return 
false;
   }

        
//if image is smaller than the 160 container, make it actual size
        
if($height $size && $width $size){
            
$newheight=$height;
            
$newwidth=$width;
        }
            
//if image height is larger, height=$size, then calc width
        
else if($height $width){
            
$newheight=$size;
            
$newwidth=($width / ($height/$size));//cast the resized width as int
        
}
            
//if image width is larger, width=$size, then calc width
        
else{
            
$newwidth=$size;
            
$newheight=($height / ($width/$size));//cast the resized height as int
        
}


   
Exec("$config[convert] -geometry \"$newwidth"."x"."$newheight\" -quality \"$config[imagequality]\" \"$image\" \"$newimage\"");

   return 
file_exists($newimage);
}
#-#ResizeImageUsingIM()


#-#############################################
# desc: resizes image using imagemagick
# param: ($filename) filename of image to create ($type) int of type. 1=gif,2=jpeg,3=png
# returns: binary img
function ReadImageFromFile($filename$type) {
    
$imagetypes ImageTypes();

    switch (
$type) {
        case 
:
            if (
$imagetypes IMG_GIF){
                return 
$im ImageCreateFromGIF($filename);
            }
        break;
        case 
:
            if (
$imagetypes IMG_JPEG){
                return 
ImageCreateFromJPEG($filename);
            }
        break;
        case 
:
            if (
$imagetypes IMG_PNG){
                return 
ImageCreateFromPNG($filename);
            }
        break;
        default:
        return 
0;
    }
}
#-#ReadImageFromFile()


#-#############################################
# desc: resizes image using imagemagick
# returns: binary img
function WriteImageToFile($im$filename$type) {
    global 
$config;

    switch (
$type) {
        case 
:
            return 
ImageGIF($im$filename);
        case 
:
            return 
ImageJpeg($im$filename$config['imagequality']);
        case 
:
            return 
ImagePNG($im$filename);
        default:
            return 
false;
    }
}
#-#WriteImageToFile()


#-#############################################
# sub: GetPageNumbers
# desc: gets the pages in the list
function GetPageNumbers($entries) {
    global 
$config;

    
$config['totalPages']=Ceil(($entries)/($config['cols']*$config['rows']));

    
// echo number of pages
    
echo "<tr><td colspan=$config[cols] align=center height=20 class=border>Page ($config[totalPages]): ";

    
// echo out PREV
    
if( ($config['page']-1) >= 0){
    echo 
"<a href=\"$_SERVER[SCRIPT_NAME]?page=".($config['page']-1)."\" class=page><b>&laquo;Prev</b></a>";}
    
// else no link
    
else{echo "<b>&laquo;Prev</b>";}

        
// for each link, echo out page link
            
$start=0// starting image number
            
$end=$config['totalPages']-1// ending image number (total / number image on page)

        // cutoff size < page. or . page != last page (otherwise keep above values)
        
if($config['maxShow'] < $config['page'] || (($config['cols']*$config['rows']*$config['maxShow'])< $entries) ){
            
// if page >= cutoff size+1 -> start at page - cutoff size
            
if($config['page'] >= ($config['maxShow']+1) && $config['page'] < $end-$config['maxShow']){ $start $config['page']-$config['maxShow'];}
            elseif(
$end $config['page']+$config['maxShow']+&& $config['totalPages']->= $config['maxShow']*2+1){$start $config['totalPages']-1-$config['maxShow']*2;}
            else{
$start=0;} // else start at 0
            
            // if page+cutoff+1 > number of pages total -> end= number of pages total
            
if( $config['page']+$config['maxShow']+$config['totalPages']-){$end $entries/($config['cols']*$config['rows']);}
            
#&oops("$end,$config['maxShow']");
            
elseif($start == && $end $config['maxShow']*2){$end $config['maxShow']*2;}
            elseif(
$start == && $config['totalPages'] <= $config['maxShow']*2){$end $config['totalPages']-1;}
            else{
$end = ($config['page']+$config['maxShow']);} //end = page+cutoff+1
        
}


    
// echo out divide marker
    
if($start 0){echo " ... ";}
    else{echo 
" - ";}


    
// echo out each of the numbers
    
for($i=$start$i<=$end $i++){
        if(
$config['page']==$i){echo "<b>[".($i+1)."]</b> \n";}
        else{echo 
"<a href=\"$_SERVER[SCRIPT_NAME]?page=$i\" class=page><b>".($i+1)."</b></a> \n";}
    }


    
// echo out divide marker
    
if(Ceil($end) < $config['totalPages']-1){echo " ... ";}
    else{echo 
" - ";}

    
// echo out NEXT
    
if( ($config['page']+1) <= $config['totalPages']-1){
    echo 
"<a href=\"$_SERVER[SCRIPT_NAME]?page=".($config['page']+1)."\" class=page><b>Next&raquo;</b></a> ";}
    
// else no link
    
else{echo " <b>Next&raquo;</b> ";}

echo 
"</td></tr>";
}
#-#end GetPageNumbers()

?>

<?php 

$_GET
['foo'] = 1
$_GET['bar'] = 2

include 
'galleries2.php'

$foo 1
$bar 2

?>  

<!-- END main -->
</td></tr></table>


</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-11-09, 04:09 AM
Mike Anime Mike Anime is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
sorry forgot some info


- Programming Language _____________PHP
- Platform
- Free or Paid___________
- Type of License______________ free
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-12-09, 04:41 PM
Mike Anime Mike Anime is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
really what i am looking for is a way to upload videos to a folder or folders and the script will show like maybe 6 videos per page. my visitors can then click on a video thumbnail and it will open in their player.would use a youtube like script however i do not like all their features and i don't like their layout


the video thumbs will be spaced out like on the main page of my site Welcome to AnimeRealmZ The Last Stop for Anime Images execpt i will only have 6 images/videos per page maximum.

the video player script can eather open in a new window or be like the one here Naruto Shippuden 113 - Official Naruto Shippuden 113 Anime Videos


see i like how windows does things however i cant use something like that.



sorry for replying to my own thread here i really haddent entended on this however i can see how confusing my original post can be... the reason i posted the image gallery script i use is i was hoping that could be modified to do what i wanted with the video section of my site. .. i like the layout and feel of that script. if nothing else it will give you an idea of how i want things to look.

i think six videos per page will be fine as most people have some sort of broad band connection and can still load in fast enough my current thumbs for the index.php page are 241x142 and i was thinking make the video thumbs double that size and have just two videos per row and have three rows of them or maybe just two by two. the spacing for the thumbs can be the same as it is for my index page though.

Last edited by Mike Anime; 07-12-09 at 04:51 PM. Reason: to better explain what i want more clearly
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-21-09, 02:44 AM
Mike Anime Mike Anime is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
ok IF someone can do it how much money are we talking about for a script like this?

i do not care if it is a script JUST for my site or one you will let others use aswell. I just want to get this new project up and running.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit button....can it send info to my email w/out the use of php???? lisa33 HTML/XHTML/XML 7 10-17-06 12:46 PM
use html to open application absvinyl HTML/XHTML/XML 5 09-18-06 03:04 PM
Can someone create a script for a video site? $Reward$ More Details inside! glick Job Offers & Assistance 6 02-06-06 05:33 PM
small image script needed. graham barnes Script Requests 0 06-18-04 04:06 AM


All times are GMT -5. The time now is 07:23 PM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.