Project Help Wanted
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherProject Help Wanted

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old February 4th, 2004, 03:25 PM
hknight hknight is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 297 hknight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m 2 sec
Reputation Power: 6
Change this PHP script to use NETPBM instead of GD

I would like to use the following script within a larger application however by server does not support GD. However I do have the NETPBM binaries installed and working. ( for info on NETPBM go to http://netpbm.sourceforge.net )

I need the following script to be modified so that it works with the NETPBM binaries insead of using GD.

PHP Code:
function thumbimage ($image$x$y$aspectratio$resize$cachedir){

          
/*##############################################
          #          - Thumbnail-Script v1.3 -           #
          # Generating thumbnails 'on-the-fly' with PHP  #
          #                                              #
          #  (c) by Christian Lamine, FlashDreams OHG    #
          #                                              #
          # This script may be freely used, distributed  #
          # and modified without any charge as long as   #
          # this copyright information is included.      #
          #                                              #
          # Any commercial selling of this script is     #
          # forbidden.                                   #
          #                                              #
          # The author is not responsible for possible   #
          # damage which may result from the application #
          # of this script, neither direct nor indirect. #
          # Use at your own risk!                        #
          ##############################################*/

     
error_reporting(0);

     
$types = array (=> "gif""jpeg""png""swf""psd""wbmp");
     
$not_supported_formats = array ("GIF"); // Write in capital Letters!!
     
umask(0);
     !
is_dir ($cachedir)
         ? 
mkdir ($cachedir0777)
         : 
system ("chmod 0777 ".$cachedir);

       (!isset (
$x) || ereg ('^[0-9]{1,}$'$x$regs)) &&
       (!isset (
$y) || ereg ('^[0-9]{1,}$'$y$regs)) &&
       (isset (
$x) || isset ($y))
            ? 
true
          
: DIE ('Fehlende(r) oder ungültige(r) Größenparameter!');

     !isset (
$resize) || !ereg ('^[0|1]$'$resize$regs)
          ? 
$resize 0
          
$resize;

     !isset (
$aspectratio) || !ereg ('^[0|1]$'$aspectratio$regs)
          ? isset (
$x) && isset ($y)
                 ? 
$aspectratio 1
                 
$aspectratio 0
          
$aspectratio;

     !isset (
$image)
          ? DIE (
'Es wurde kein Bild angegeben!')
          : !
file_exists($image)
               ? DIE (
'Die angegebene Datei konnte nicht auf dem Server gefunden werden!')
               : 
false;

     
$imagedata getimagesize($image);

     !
$imagedata[2] || $imagedata[2] == || $imagedata[2] == 5
          
? DIE ('Bei der angegebenen Datei handelt es sich nicht um ein Bild!')
          : 
false;

     
$imgtype="!(ImageTypes() & IMG_" strtoupper($types[$imagedata[2]]) . ")";
     if ((eval(
$imgtype)) || (in_array(strtoupper(array_pop(explode('.'basename($image)))),$not_supported_formats))) {
         
$image substr ($image, (strrpos (DIR_FS_CATALOG '/''/'))+1);
         return 
$image;

     }

     if (!isset (
$x)) $x floor ($y $imagedata[0] / $imagedata[1]);


     if (!isset (
$y)) $y floor ($x $imagedata[1] / $imagedata[0]);

     if (
$aspectratio && isset ($x) && isset ($y)) {
        if (((
$imagedata[1]/$y) > ($imagedata[0]/$x) )){
             
$x=ceil(($imagedata[0]/$imagedata[1])* $y);
        } else {
             
$y=ceil($x/($imagedata[0]/$imagedata[1]));
        }
     }

     
$thumbfile =  '/' basename($image);
     if (
file_exists ($cachedir.$thumbfile)) {
          
$thumbdata getimagesize ($cachedir.$thumbfile);
          
$thumbdata[0] == $x && $thumbdata[1] == $y
               
$iscached true
               
$iscached false;
     } else {
          
$iscached false;
     }

     if (!
$iscached) {
          (
$imagedata[0] > $x || $imagedata[1] > $y) || (($imagedata[0] < $x || $imagedata[1] < $y) && $resize)
               ? 
$makethumb true
               
$makethumb false;
     } else {
          
$makethumb false;
     }



     if (
$makethumb) {
          
$image call_user_func("imagecreatefrom".$types[$imagedata[2]], $image);
          
$thumb imagecreatetruecolor ($x$y);
          
imagecopyresampled ($thumb$image0000$x$y$imagedata[0], $imagedata[1]);
          
call_user_func("image".$types[$imagedata[2]], $thumb$cachedir.$thumbfile);
          
imagedestroy ($image);
          
imagedestroy ($thumb);
          
$image DIR_WS_IMAGES 'imagecache' $thumbfile;
     } else {
          
$iscached
               
$image DIR_WS_IMAGES 'imagecache' $thumbfile
               
$image substr ($image, (strrpos (DIR_FS_CATALOG '/''/'))+1);
     }
return 
$image;



Reply With Quote
  #2  
Old February 10th, 2004, 11:46 AM
deanbayley's Avatar
deanbayley deanbayley is offline
Disturbed
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Somewhere In the Great Unknown
Posts: 489 deanbayley User rank is Corporal (100 - 500 Reputation Level)deanbayley User rank is Corporal (100 - 500 Reputation Level)deanbayley User rank is Corporal (100 - 500 Reputation Level)deanbayley User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 23 h 27 m 56 sec
Reputation Power: 7
Send a message via ICQ to deanbayley
Download a gallery program like 4Images they come with image utils to support many different graphic engines..

Dean.
__________________
Put your hand on a hot stove for a minute, and it seems like an hour.
Sit with a pretty girl for an hour and it seems like a minute.
That's relativity.
- Albert Einstein

while($girl=='ugly')
{
$alcohol++;
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherProject Help Wanted > Change this PHP script to use NETPBM instead of GD


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway