Can anyone edit this script...

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Hi,

I have this php script:

Code:
<?
function getThumbTag($iid, $type, $sql) {
	global $cfgImageDirLocal, $cfgImageDirWeb;
	global $cfgThumbDirLocal, $cfgThumbDirWeb;	
	global $cfgThumbWidth, $cfgThumbHeight;
	global $cfgMediumWidth, $cfgMediumHeight;
	global $cfgConvert;
	
	if ($type == "medium") {
		$makeThumb = 0;
		$thumbName = "$iid-m.jpg";
	} else {
		$makeThumb = 1;
		$thumbName = "$iid.jpg";
	}
	
	// If thumbnail does not exists - create it!
	if (!file_exists($cfgThumbDirLocal . $thumbName)) {	
		// create thumbnail
		// Get image info
		$query = "SELECT ID, sFile from tblImage WHERE ID = $iid";
		$result = mysql_query($query, $sql);
		if ($result && $row=mysql_fetch_array($result)) 
		{ 
			$sql_ID = $row["ID"];
			$sql_sFile = $row["sFile"];
		} else {
			die(mysql_error() . ": " . $query);
		}
		
		// Create thumbnail
		$fromFile = $cfgImageDirLocal . $sql_sFile . "[0]";
		if ($makeThumb) { // thumb
			$geometry = $cfgThumbWidth."x".$cfgThumbHeight.">";
		} else {	// medium
			$geometry = $cfgMediumWidth."x".$cfgMediumHeight.">";
		}
		
		$ext = strrchr($sql_sFile,'.');
		if (strcasecmp($ext, ".pdf") == 0) {
			$sExtraOption = "-flatten ";
		} else {
			$sExtraOption = "";
		}
		
		exec("$cfgConvert -geometry '$geometry' " . $sExtraOption . escapeshellarg($fromFile) . " " . $cfgThumbDirLocal . $thumbName);
	}
	return "<img src=\"" . $cfgThumbDirWeb . $thumbName . "\" border=\"0\">";
}
?>

cfgConvert is meant to use imagemajick.

Instead, all I want the above script to do is display the thumb from the main image resized, or create one a thumb without using imagemagick.

Can anyone help?

Thanks in advance.

Simon
 
short of using exif_thumbnail() you will need either GD libraries, Gimp or ImageMagick to create images on a server.
 
How about just resizing the image? Can that be done?



Excuse my lack of knowledge - I do not really know PHP that well.

Thanks.

Simon
 
http://www.php.net/manual/ru/function.exif-thumbnail.php

for getting a size of image use
http://www.php.net/manual/ru/function.getimagesize.php

for resizing use
http://www.php.net/manual/ru/function.imagecopyresized.php
 
Back
Top