Can anyone edit this script...

images php coding issues or problems here.

Moderators: macek, egami, gesf

scisuk
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Mar 02, 2003 6:49 am
Contact:

Can anyone edit this script...

Postby scisuk » Sun Mar 02, 2003 6:55 am

Hi,

I have this php script:

Code: Select all

<?
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

User avatar
pootergeist
New php-forum User
New php-forum User
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK
Contact:

Postby pootergeist » Sun Mar 02, 2003 7:12 am

short of using exif_thumbnail() you will need either GD libraries, Gimp or ImageMagick to create images on a server.

scisuk
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Mar 02, 2003 6:49 am
Contact:

Postby scisuk » Sun Mar 02, 2003 9:00 am

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

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Sun Mar 02, 2003 11:36 pm



Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest