Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Scripts

Reply
 
LinkBack Thread Tools Display Modes
Old 06-05-2007, 11:09 PM   #1 (permalink)
New Member
 
Join Date: Jun 2007
Posts: 1
Default External image size.

I was wondering if anyone could write a script that will adjust the image width/height from an external javascript file.

I have the same image on alot of pages and don't want to adjust the size on everyone when i decide to change it.

So if there was some way to input a single number into one file and have it adjust it on all of the other pages that would be great... i know the basic basics of javascript but know a lot in HTML so i'll try to follow what your saying.
TBuck is offline   Reply With Quote
Old 06-06-2007, 03:50 PM   #2 (permalink)
Super Noob
 
zkiller's Avatar
 
Join Date: Aug 2004
Location: position:relative
Posts: 1,560
Send a message via AIM to zkiller Send a message via Yahoo to zkiller
Default

i use the aspjpeg component from persists to do this on the fly. however, to use it you would need to find a host that offers it. i am sure their are also ways to do this using php, i don't know about basic javascript though.
__________________
Stefan, the Post Master

Track Devil - May the boost be with you!
zkiller is offline   Reply With Quote
Old 09-12-2007, 09:09 AM   #3 (permalink)
New Member
 
Imagn's Avatar
 
Join Date: Sep 2007
Location: Los Angeles, California
Posts: 12
Default

PHP Solution:

-----------------------------------------------------
FUNCTION
-----------------------------------------------------

function createThumbnail($img_file, $max_width, $max_height, $img_quality, $img_path='images', $class='', $alt_tag='') {

$nameparts = pathinfo($img_file);
$file_extension = $nameparts['extension'];

$thumb_script = "create_thumbs.php";

$z = "<img src=\"" . $thumb_script . "?photo_file=" . $img_path . "/" . $img_file . "&amp;maxW=" . $max_width . "&amp;maxH=" . $max_height . "&amp;quality=" . $img_quality . "\" alt=\"" . $alt_tag . "\" class=\"" . $class . "\" />";
echo $z;
}




-----------------------------------------------------
'create_thumbs.php' PAGE
-----------------------------------------------------

<?php
!isset($_GET['maxW']) ? $_GET['maxW']=400 : NULL;
!isset($_GET['maxH']) ? $_GET['maxH']=400 : NULL;
!isset($_GET['quality']) ? $_GET['quality']=100 : NULL;
$ratio=1;
$sourceHandle=imagecreatefromjpeg($_GET['photo_file']);
$sourceW=imagesx($sourceHandle);
$sourceH=imagesy($sourceHandle);
if ($sourceW>$sourceH) { $sourceW>$_GET['maxW'] ? $ratio=$_GET['maxW']/$sourceW : NULL; } elseif ($sourceW<$sourceH) { $sourceH>$_GET['maxH'] ? $ratio=$_GET['maxH']/$sourceH : NULL; } else { $ratio=min($_GET['maxH'],$_GET['maxW'])/$sourceH; }
$resizedW=$sourceW*$ratio;
$resizedH=$sourceH*$ratio;
$resizedHandle=imagecreatetruecolor($resizedW,$res izedH);
imagecopyresampled($resizedHandle,$sourceHandle,0, 0,0,0,$resizedW,$resizedH,$sourceW,$sourceH);
//$resizedHandle=imagecreate($resizedW,$resizedH);
//imagecopyresized($resizedHandle,$sourceHandle,0,0, 0,0,$resizedW,$resizedH,$sourceW,$sourceH);
header('Content-type: image/jpeg');
imagejpeg($resizedHandle,'',$_GET['quality']);
imagedestroy($sourceHandle);
imagedestroy($resizedHandle);
?>



-----------------------------------------------------
CALL TO IMAGE WITHIN HTML
-----------------------------------------------------

<?php createThumbnail($FILENAME,130,130,90,'FILE_PATH'); ?>
Imagn is offline   Reply With Quote
Reply

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:27 AM.


Computer Forum - Internet Business - Webpage Design

 
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.