image manipulation in safe mode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • goldtech@worldpost.com

    #1

    image manipulation in safe mode

    Is there a way to create thumnails with a script in PHP with safe mode
    ON?

    We want to keep safe mode ON for our server but beable to automatically
    create thumbs from full size image files.

    Is there a script, product or way?

    Thanks

  • Jim Michaels

    #2
    Re: image manipulation in safe mode


    <goldtech@world post.com> wrote in message
    news:1137781255 .605747.169250@ o13g2000cwo.goo glegroups.com.. .[color=blue]
    > Is there a way to create thumnails with a script in PHP with safe mode
    > ON?
    >
    > We want to keep safe mode ON for our server but beable to automatically
    > create thumbs from full size image files.
    >
    > Is there a script, product or way?[/color]

    as far as I know, you should have the GD library available to you. Look in
    the CHM manual under Image Functions. The CHM manual contained this notes
    entry in imagecreatefrom jpeg().

    This is a very useful script when you have hundreds of images and you need a
    quick setup for a thumbnail, where you can select how many
    pictures per row, size of the thumbnail, and the size of the pictures when
    clicked, all in one script. Just throw all your images and this script in a
    file named index.php or index.html (if your apache httpd.conf defaults to
    html and runs .html as php).
    Script also contains simple text watermarking. See function thumbImage()
    and modify to add image watermarking if you like.
    <?
    // 30 Minutes Thumbnail script written by Angel Leon from wedoit4you.com
    // Licensed under the GPL
    // Courtesy of wedoit4you.com
    //Instructions:
    //copy this script wherever you have a bunch of .jpgs
    // Invoke your thumbnail like this http://mysite.com/imageFolder/index.php
    //where index.php is this script.
    //Modify and redistribute but don't remove our trademark.

    //configure script here
    //pictures per row
    $row_size = 3;
    //height of the pictures in thumbnail
    $thumb_height = 200;
    //height of the pictures when clicked (to save bandwidth)
    $big_image_heig ht=668;
    //short name of your site
    $waterMark = "mysite.com ";
    $dh = opendir(".");
    $files = array();
    while (($file = readdir($dh)) !== false) {
    if (ereg("jpg",$fi le) || ereg("gif",$fil e) || ereg("png",$fil e)) {
    $files[] = $file;
    }
    }
    closedir($dh);
    if ($show_image) {
    thumbImage($sho w_image,$big_im age_height,$wat erMark);
    } else if ($thumb_image) {
    thumbImage($thu mb_image,$thumb _height,$waterM ark);
    }
    else {
    echo "<center>" . createThumbTabl e($files,$row_s ize) . "</center>";
    }
    function createThumbTabl e($files,$pics_ wide) {
    $row = intval(count($f iles)/$pics_wide);
    $picIndex = 0;
    $rs = "Mostrando " . count($files) . " imagenes
    ";
    $rs .= "<table border=0 cellspacing=1 cellpadding=0 style='border:1 px solid
    black'>\n";
    for ($i=0; $i <$row; $i++) {
    $rs .= "\t<tr>\n";
    for ($picIndex,$j=0 ;
    $j < $pics_wide && $picIndex < count($files);
    $j++,$picIndex+ +) {
    $rs .= "\t\t<td><a href=index.php? show_image=" .
    $files[$picIndex] . ">" .
    "<img src=index.php?t humb_image=" .
    $files[$picIndex] . " border=0 title='Copyrigh t
    wedoit4you.com' ></a></td>\n";
    //$rs .= "<td>i=$i / $j=$picIndex</td>";

    }
    $rs .= "\t</tr>\n";
    }//for
    $rs .= "<tr><td colspan=$pics_w ide align=center>Fr ee Thumbnail script by <a
    href=http://www.wedoit4you. com>wedoit4you. com</a>
    Written by Angel Leon (March 2005)</td></tr></table>\n";
    return $rs;
    } //createThumbTabl e
    function thumbImage($fil e,$img_height,$ waterMark) {
    $img_temp = imagecreatefrom jpeg($file);
    $black = @imagecolorallo cate ($img_temp, 0, 0, 0);
    $white = @imagecolorallo cate ($img_temp, 255, 255, 255);

    $font = 2;
    $img_width=imag esx($img_temp)/imagesy($img_te mp)*$img_height ;
    $img_thumb=imag ecreatetruecolo r($img_width,$i mg_height);
    imagecopyresamp led($img_thumb,
    $img_temp,0,0,0 ,0,$img_width,
    $img_height,
    imagesx ($img_temp),
    imagesy($img_te mp));
    $originx = imagesx($img_th umb) - 100;
    $originy = imagesy($img_th umb) - 15;
    @imagestring ($img_thumb, $font, $originx + 10, $originy,
    $waterMark, $black);
    @imagestring ($img_thumb, $font, $originx + 11, $originy - 1,
    $waterMark, $white);
    header ("Content-type: image/jpeg");
    imagejpeg($img_ thumb, "", 60);

    imagedestroy ($img_thumb);
    }
    ?>
    [color=blue]
    >
    > Thanks
    >[/color]


    Comment

    Working...