/    Sign up×
Community /Pin to ProfileBookmark

Thumbnail generator

ez,

Alright I need some help finding the right script for the application. I have a design firm and we design a lot of things that are printed. I was wondering if anyone knows of a good script that I can upload the images to a folder.

This is what I’m looking for, I’m looking for a script that generates the thumb nails and displays them on a specific page. Say I have 12 images for the section called prints, I want to have the thumbnails displayed on the prints page, with the format I have of the page set up, im thinking like a 60 x 60 thumb with one space in between. I just need to know how to get the images to display on a certain page other than making its own gallery page?.

thanks. ?

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@bokehNov 28.2005 — What, something like this? http://bugster.co.uk/thumbnail
Copy linkTweet thisAlerts:
@hollowp0authorNov 28.2005 — yes, I have a script right now that makes the tumbs.

[URL=http://www.hpadv.net/area51/imagegallery/test.php]http://www.hpadv.net/area51/imagegallery/test.php[/URL]

I did a small edit to the code that make the image when clicked lunch in a new window. I would like to know if there is anyway to launch a window that is the size of the full size image?

Im using TStarGallery 1.0 engine

the whole code is as follows....

// TStarGallery 1.0 engine

// With basic PHP knowledge you can understand what's happening here.

// Don't blame me for writing non-perfect code for I do not care.

// If there is an error or something, mail me at [email][email protected][/email]


// Read the current directory, throw out non-jpg/gif/png + thumbfiles

// --------------------------------------------------------------------

$dirfiles = array();

$handle=opendir('.');

while ($file = readdir($handle)) {

if

((

strtolower(strrchr($file, '.')) == ".jpg" OR

strtolower(strrchr($file, '.')) == ".jpeg" OR

strtolower(strrchr($file, '.')) == ".png" OR

strtolower(strrchr($file, '.')) == ".gif"

)

&&

(

strstr($file, ".thumb.jpg") == ''

))

{

array_push($dirfiles, $file);

}

}

sort ($dirfiles);

closedir($handle);

// Write the beginning of the basic table for displaying the thumbs.

// Modify this section to make it fit your own website.

// -----------------------------------------------------------------

echo "<table width="100" border="0" cellpadding="1" cellspacing="0" id="structure"><tr>";


// Read the valid filenames from the array, have your way with every single one of them

// ------------------------------------------------------------------------------------

foreach($dirfiles as $aktuellesfile)

{

// Elements of the filename are cut into pieces

$dateiendung = strrchr( $aktuellesfile, '.' );

$dateiname = substr_replace ($aktuellesfile, '', -strlen($dateiendung) );


// First a routine for creating a thumb

createthumb ($dateiname, $dateiendung);

// Now open up a table cell

echo "<td>";

// Second a routine for showing a thumb

showthumb ($dateiname, $dateiendung);

// Close the table cell

echo "</td>";

// And make a linebreak after every 5 thumbs

if(++$cnt % 5 == 0) echo "</tr>";

}

// Finished

exit;


// Function to create a thumbnail if it doesn't already exist

// -----------------------------------------------------------------

function createthumb ($thumbdateiname, $thumbdateiendung)

{

$fullname = $thumbdateiname.$thumbdateiendung;

$fullthumbname = $thumbdateiname.$thumbdateiendung.".thumb.jpg";

// If thumb exists,nothing will happen
if (file_exists($fullthumbname) OR strstr($fullname, ".thumb.jpg") != '')
{
}
// If thumb doesn't exist,it's created now

else

{

if ((strtolower($thumbdateiendung) == ".jpg") OR (strtolower($thumbdateiendung) == ".jpeg")){

$src_img = imagecreatefromjpeg($fullname);

}

if (strtolower($thumbdateiendung) == ".gif"){

$src_img = imagecreatefromgif($fullname);

}

if (strtolower($thumbdateiendung) == ".png"){

$src_img = imagecreatefrompng($fullname);

}

$origx=imagesx($src_img);
$origy=imagesy($src_img);

// Maximum width and height of the thumbnails
$max_x = 60;
$max_y = 60;

// Calc, if thumb has has to be squeezed from width or height
if($origx >= $origy AND $origx > $max_x)
{
$faktor = $origx / $max_x;
$new_x = $origx / $faktor;
$new_y = $origy / $faktor;
}

elseif($origy > $origx AND $origy > $max_y)
{
$faktor = $origy / $max_y;
$new_x = $origx / $faktor;
$new_y = $origy / $faktor;
}

else
{
$new_x = $origx;
$new_y = $origy;
}

// Squeeze and write it into a file
$dst_img = imagecreatetruecolor($new_x,$new_y);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_x,$new_y,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, $fullthumbname, 50);
}

}

// Function to show a thumbnail

// -----------------------------------------------------------------

function showthumb ($thumbdateiname, $thumbdateiendung)

{

$fullname = $thumbdateiname.$thumbdateiendung;

$fullthumbname = $thumbdateiname.$thumbdateiendung.".thumb.jpg";

if (file_exists($fullthumbname))

{

echo "<a href="$fullname" target="_blank"><img src ="$fullthumbname" border="0"></a>";

}

else

{

}

}

I have added a java script also,

<--

<script type="text/javascript">

function obrazek(url, width, height){ var windowX = Math.ceil( (window.screen.width-width) / 2 ); var windowY = Math.ceil( (window.screen.height-height) / 2 ); var Win = window.open(url,"",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no' ); Win.moveTo ( Math.ceil( windowX ) , Math.ceil( windowY ) ); }

-->

The new window part looks like,

// Function to show a thumbnail

// -----------------------------------------------------------------

function showthumb ($thumbdateiname, $thumbdateiendung)

{

$fullname = $thumbdateiname.$thumbdateiendung;

$fullthumbname = $thumbdateiname.$thumbdateiendung.".thumb.jpg";

if (file_exists($fullthumbname))

{

echo "<a href="javascript:obrazek('../imagegallery/$fullthumbname',800,600)" target="_blank"><img src ="$fullthumbname" border="0"></a>";

}

else

{

}

}

Now my problem is getting the image to load into a window thats 800 x 600 or the whatever the original image size is....

test it here : http://www.hpadv.net/area51/imagegallery/test.php
Copy linkTweet thisAlerts:
@hollowp0authorNov 28.2005 — or, is there a way to use css to set the target window, say its _blank but have the window that pops up have a set of already desinated properties such as a bg the size of the window base on the original image size margins etc..
Copy linkTweet thisAlerts:
@bokehNov 28.2005 — In future when you post code please put it between code tags.

To be honest your are best off asking about pop-up windows in the, [I]gasp[/I], javascript section of the forum.
Copy linkTweet thisAlerts:
@hollowp0authorNov 28.2005 — thanks, but my problem lies within the php code and allowing it to make a pop up window..
Copy linkTweet thisAlerts:
@purefanNov 29.2005 — I agree with bokeh, you asked about how to size the poped up window to the exact size of the image being displayed, thats done with javascript.

I saw your Javascript function for poping up, and forgive me fellas, I know this is not the JS section but anyhow, I think you should use something like:
[code=html]
var NewWindow=window.open('','name','height=675,width=655,status=0');
NewWindow.document.write('<html><head><title></title>');
[/code]

hope it helps
Copy linkTweet thisAlerts:
@hollowp0authorNov 29.2005 — ok, now that code needs to be used for the images.

When you click the thumbnail a new window pops up and its the size of the original image not the thumb.

I just need to know how to add it to the php gallery code for the thumbnail link

[CODE]// Function to show a thumbnail
// -----------------------------------------------------------------
function showthumb ($thumbdateiname, $thumbdateiendung)
{
$fullname = $thumbdateiname.$thumbdateiendung;
$fullthumbname = $thumbdateiname.$thumbdateiendung.".thumb.jpg";
if (file_exists($fullthumbname))
{
echo "<a href="$fullname" target="_blank"><img src ="$fullthumbname" border="0"></a>";
}
else
{
}

}[/CODE]


Some how if possiable i need the script to pop up a window with the full size image in it. I dont want to have to make a page for each fullsize image.

sry about posting this in php, but my problem lies in both php and java.

Thanks gents!
Copy linkTweet thisAlerts:
@bokehNov 29.2005 — You can't pop up a window with just an image and no html otherwise that window will take on the browser default styling. The window needs html and CSS and the html needs to contain an image tag to call the image.
×

Success!

Help @hollowp0 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...