|
Posted by Steve on 09/16/07 23:56
"Confused but working on it" <PostInGroups@wherever.com> wrote in message
news:2007091523044150073-PostInGroups@wherevercom...
>>>
>>> Steve,
>>>
>>> Wow, way too much time on your hands. :)
>>
>> i think when i originally wrote that, it took all of about 5 minutues.
>> ;^)
>>
>>> My first goal was to get my pics to display, then get rid of the . and
>>> .., now I will fix the code to the example you gave before if you say
>>> it's faster. Then,(light drumroll...), I want to read everything in
>>> thumbs and create my output so I get the thumbto link to a larger pic in
>>> images. Some sort of anchor tag thing. THAT would be cool to me. Then I
>>> can rewrite about 20 pages, export 20 albums as thumbs and 20 albums as
>>> images... :)
>>
>> you realize you don't have to have a thumb of each pic in order to
>> generate a thumb, right?
>>
>> if you'd like, i can post a class that does this based on the actual
>> image, and then show how to use it in your main script.
>
> Well hell yeah, post away!
>
> I was trying to do it myself as I see a lot of posts asking for free work.
> :)
>
> At this point storage isn't an issue and it takes 20 seconds to generate
> the thumbs and the resized images from iPhoto. As opposed to if I had a
> 1600x1200 pic and uploaded I think that takes more storage than a 800px
> pic and a 100px thumb. Let me see if I can write a script to calculate the
> storage difference... :)
>
> So when I take pics I make a dir and make images and thumbs dir inside of
> that. The I have a very simple php page with includes for header and
> footer. Change the title, add my paragraph or two and then my thumbs
> output. I tried to use iWeb for plain export of html pages but ends up
> being more work because every file extension needs to be changed to php,
> footer and header added, css line to be added. UGH.
>
> So in 67 lines of code or less, read my images, display as thumbs linking
> back to the originals, sorted by filename...
ok...call this script get.thumb.nail.php (or whatever you'd like).
site.cfg.php is a configuration script that objectifies different things for
my site...in this case, where included directories are. hard-code as you see
fit. below this main script you'll find the functions used and supplied by
functions.inc.php. finally, below that, you'll see an example use of
everything together. if you have questions or need help, just post back.
cheers...
========
get.thumb.nail.php
<?
require_once 'site.cfg.php';
require_once $site->includeDirectory . 'functions.inc.php';
$fileName = $_REQUEST['fileName'] ? $_REQUEST['fileName'] :
$_REQUEST['altImage'];
$maxSize = $_REQUEST['maxSize'] ? $_REQUEST['maxSize'] : 200;
$filePath = $site->imagesDirectory;
$fileData = @file_get_contents($filePath . $fileName);
$originalImage = @imagecreatefromstring($fileData);
@list($imageWidth, $imageHeight, $imageType, $imageAttributes) =
@getimagesize($filePath . $fileName);
$newImageHeight = $imageWidth < $maxSize ? $imageHeight : ($imageHeight /
$imageWidth) * $maxSize;
$newImageWidth = $imageWidth < $maxSize ? $imageWidth : $maxSize;
$thumbNail = @imagecreatetruecolor($newImageWidth, $newImageHeight);
@imagecopyresampled(
$thumbNail,
$originalImage,
0,
0,
0,
0,
$newImageWidth,
$newImageHeight,
@imagesx($originalImage),
@imagesy($originalImage)
);
@imagejpeg($thumbNail);
@imagedestroy($thumbNail);
@imagedestroy($originalImage);
?>
======
get.file.php
<?
require_once 'site.cfg.php';
$fileData = '';
$fileName = $_REQUEST['fileName'];
$filePath = $site->uploadBaseDirectory;
if ($fileName != ''){ $fileData = @file_get_contents($filePath .
$fileName); }
header('pragma: public' );
header('expires: 0' );
header('cache-control: private', false );
header('cache-control: must-revalidate, post-check=0, pre-check=0' );
header('content-disposition: attachment; filename="' . $fileName . '"' );
header('content-size: ' . count($fileData) );
header('content-transfer-encoding: binary' );
header('content-type: application/octet-stream' );
echo $fileData;
?>
=======
test.php
<?
$sql = "
SELECT Id
,
Description
,
FileName
,
FileSize
,
FileType
,
DATE_FORMAT(Stamp, '%m/%d/%Y %H:%i:%s') Stamp
FROM upLoads
ORDER BY FileName
";
$records = db::execute($sql);
foreach ($records as $row => $record)
{
$queryString = "?fileName=" . $record['FILENAME'] . "&maxSize=200";
?>
<a
href="<?= $site->uri ?>get.file.php<?= $queryString ?>"
style="font-size:12pt;"
>
<img
src="<?= $site->uri ?>get.thumb.nail.php<?= $queryString ?>"
alt="<?= $record['DESCRIPTION'] ?>"
title="Click To Open: <?= $record['DESCRIPTION'] ?>"
/>
</a>
<?
}
?>
[Back to original message]
|