Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Help - How do I call this function?


PHP Help - How do I call this function?

Reply
  #1 (permalink)  
Old 04-02-06, 01:30 PM
INTEL INTEL is offline
Newbie Coder
 
Join Date: Mar 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Help - How do I call this function?

Please see http://www.zend.com/codex.php?id=1101&single=1

I'm trying to turn my image sepia (third function in above URL)

PHP Code:

function sepia($tintR 80,$tintG 43,$tingB = -23,$rateR .229,$rateG .587,$rateB .114,$whiteness 3
        { 

                for (
$x 0$x $this->numColors$x++) 
                { 
                        
$src_colors     imagecolorsforindex($this->resource_image,$x); 
                        
$new_color      min(255,abs($src_colors["red"] * $rateR $src_colors["green"] * $rateG $src_colors["blue"] * $rateB) + $whiteness); 
                        
$r              min(255,$new_color $tintR); 
                        
$g              min(255,$new_color $tintG); 
                        
$b              min(255,$new_color $tintB); 
                        
imagecolorset($this->resource_image,$x,$r,$g,$b); 
                } 
        } 
I dont know how to call this function. would i do sepia($imagesrc) ?

I appreciate any help.
Reply With Quote
  #2 (permalink)  
Old 04-02-06, 01:39 PM
Barnz1986 Barnz1986 is offline
Aspiring Coder
 
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by INTEL
Please see http://www.zend.com/codex.php?id=1101&single=1

I'm trying to turn my image sepia (third function in above URL)

PHP Code:

function sepia($tintR 80,$tintG 43,$tingB = -23,$rateR .229,$rateG .587,$rateB .114,$whiteness 3
        { 

                for (
$x 0$x $this->numColors$x++) 
                { 
                        
$src_colors     imagecolorsforindex($this->resource_image,$x); 
                        
$new_color      min(255,abs($src_colors["red"] * $rateR $src_colors["green"] * $rateG $src_colors["blue"] * $rateB) + $whiteness); 
                        
$r              min(255,$new_color $tintR); 
                        
$g              min(255,$new_color $tintG); 
                        
$b              min(255,$new_color $tintB); 
                        
imagecolorset($this->resource_image,$x,$r,$g,$b); 
                } 
        } 
I dont know how to call this function. would i do sepia($imagesrc) ?

I appreciate any help.
My guess is you call it by doing: -

serpia();

And dont specify any arguements.
Reply With Quote
  #3 (permalink)  
Old 04-02-06, 01:50 PM
INTEL INTEL is offline
Newbie Coder
 
Join Date: Mar 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for the reply, but how do i tell it what image im inputting?
Reply With Quote
  #4 (permalink)  
Old 04-02-06, 01:51 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
As it's part of a class called "imageFiltersIndex", you'd call it one of two ways:
PHP Code:

<?php


$imageFiltersIndex 
= new imageFiltersIndex();
$imageFiltersIndex->sepia();

?>
...or:
PHP Code:

<?php


imageFiltersIndex
::sepia();

?>
...after including the class, of course.

Last edited by Keith; 04-02-06 at 01:55 PM.
Reply With Quote
  #5 (permalink)  
Old 04-02-06, 01:55 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Quote:
Originally Posted by INTEL
thanks for the reply, but how do i tell it what image im inputting?
It tells you exactly how to do that in the very page you linked to.
Reply With Quote
  #6 (permalink)  
Old 04-02-06, 01:57 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
From (*gasp*) http://www.zend.com/codex.php?id=1101&single=1

Code:
  * Usage: 
  * 
  *     $img_src                = ImageCreateFromJpeg("image.jpg"); 
  *     $imageFiltersIndex      = new imageFiltersIndex; 
  *     $imageFiltersIndex->resource($img_src); 
  *     $imageFiltersIndex->filter([$options1],[$options2,...]); 
  * 
  *  Where filter is the filter name and $options is a filter option. 
  *  All imageFilterIndex should have some defaults filters options, so you do not need to 
  *     use options if you do not want to. 
  * 
  * 
  * Example: 
  * 
  * $img_src_file = "file.jpg"; 
  * 
  * $img_src=ImageCreateFromJpeg($img_src_file); 
  * 
  * $imageFiltersIndex = new imageFiltersIndex; 
  * $imageFiltersIndex->resource($img_src); 
  * $imageFiltersIndex->sepia(); 
  * 
  * header("Content-type: image/jpeg"); 
  * imagejpeg($img_src,"",50);
Reply With Quote
  #7 (permalink)  
Old 04-02-06, 01:59 PM
INTEL INTEL is offline
Newbie Coder
 
Join Date: Mar 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
can't believe i missed it.

PHP Code:

 $img_src                ImageCreateFromJpeg("image.jpg"); 

thanks for all the replies.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP upload prob minority ASP 1 06-27-05 08:35 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP Error Fairnie PHP 8 06-26-04 07:15 AM
accessing existing ISP email with a PHP webmail script. nlancaster PHP 1 01-07-04 03:28 AM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 09:50 AM


All times are GMT -5. The time now is 07:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.