Hi,

Have very little of idea of the GD functions (and dont
ahve imagemagik) so am having problems....

1. I need to read all the images from a dir and write
something on it at the bottom right side of the
picture

2.save this image in a diff folder keeping the
originals as is.

I have worked out the logic to fetch the imgs from the
folder into an array but the rest is beyond me...


I HAVE gotten a good class that does a lot but...it
does not save the image, it outputs it to the browser
(class below) can anybody help me save the file to a
folder on my disk please?

I have gone to http://se.php.net/image, 
searched the archives,
http://www.hotscripts.com/PHP/Tips_and_Tutorials/Image_Manipulation/
and google...but am as confused as ever...maybe
because its 5am ;-) and been working whole day.

Solutions or URLs are most welcome, thanks in advance.
-Mag



************************* Class **************

<?
        class img_add_txt{
        
        
                /*
                        Created by Richard Sumilang
                        http://www.richard-sumilang.com
                        
                        
                        object img_add_txt($array);
                        ------------------------------------
                        This function adds text on top of an image
                        
                        Usage:
                        ------------------------------------
                        $config=array(
                                                "text" => "Coupon: Here is your free 
coupon",
                                                "text_colors" => "255 68 0", // RGB 
Seperated by
spaces
                                                "image_loc" => "example.jpg",
                                                "image_type" => "JPEG", // PNG and GIF 
Supported
                                                // Optional arguments; default is 
center area on
image
                                                "x_pos" => "",
                                                "y_pos" => "",
                                                
                        );
                        
                        $graphic=new img_add_txt($config);
                */
                
                function img_add_txt($config){
        
                        // header
                        //header("Content-Type: image/gif");
                        $this->func_header($config['image_type']);
                        
                        // set up image
                        $im = ImageCreateFromJPEG($config['image_loc']);
                        
                        // Set up text colors
                        $text_colors=explode(" ", $config['text_colors']);
                        $text_color = ImageColorAllocate($im,
$text_colors['0'], $text_colors['1'],
$text_colors['2']);
                        
                        // get font dimensiona
                        $font_height = ImageFontHeight(3);
                        $font_width = ImageFontWidth(3);
                        
                        // get image dimensiona
                        $image_height = ImageSY($im);
                        $image_width = ImageSX($im);
                        
                        // get string length
                        $length = $font_width * strlen($config['text']);
                        
                        // set the x, y cords of where the text will be
placed
                        if(empty($config['x_pos'])){
                                // calculate start coordinates for string
                                $image_center_x = ($image_width/2)-($length/2);
                        }else{
                                $image_center_x = $config['x_pos'];
                        }
                        if(empty($config['y_pos'])){
                                // calculate start coordinates for string
                                $image_center_y =
($image_height/2)-($font_height/2);
                        }else{
                                $image_center_y = $config['y_pos'];
                        }
                        
                        // write string
                        ImageString($im, 3, $image_center_x,
$image_center_y, $config['text'], $text_color);
                        
                        // output to browser
                        $this->output_image($config['image_type'], $im);
                
                }// End img_add_txt
                
                
                /*
                        Output the correct header based
                        on file type
                */
                function func_header($var){
                        
                        switch($var){
                                case "PNG":
                                        header("Content-Type: image/png");
                                break;
                                
                                case "GIF":
                                        header("Content-Type: image/gif");
                                break;
                                
                                case "JPEG":
                                        header("Content-Type: image/jpeg");
                                break;
                        }
                        
                }// End func_header
        
        
                /*
                        Output the correct image type
                        based on type
                */
                function output_image($var, $pointer){
                        
                        switch($var){
                                case "PNG":
                                        ImagePNG($pointer);
                                break;
                                
                                case "GIF":
                                        ImageGIF($pointer);
                                break;
                                
                                case "JPEG":
                                        ImageJPEG($pointer);
                                break;
                        }
                        
                } // End out output image
                        
        } // End of class
?>

=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)


                
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to