TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-08-2008, 01:33 PM   #1 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Angry Applying a Filter in GD

In Rendair's thread about the wave effects for the reflections, somebody mentioned that you can apply overlay filters which affect the image below. So for example if I had a captcha image below, how could I apply a wave effect on the top to skew those letters?

What I'm trying to do is replicate the Gmail captcha image which is very simple, but merely skews the letters:

__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
cancer10 (06-14-2008)
Old 01-08-2008, 01:56 PM   #2 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Could you give me an example of the Google Mail Captcha system?
Orc is offline  
Reply With Quote
The Following User Says Thank You to Orc For This Useful Post:
cancer10 (06-14-2008)
Old 01-08-2008, 01:58 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Can you not see the image in my original post?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
cancer10 (06-14-2008)
Old 01-08-2008, 02:02 PM   #4 (permalink)
The Addict
Top Contributor Good Samaritan 
 
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
RobertK is on a distinguished road
Default

I believe they use Imagick, not GD. The reason for this is the object has a direct "distortImage" method, and I cannot find a similar filter for GD. This is by best guess.

PHP: Imagick::distortImage - Manual
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
RobertK is offline  
Reply With Quote
The Following User Says Thank You to RobertK For This Useful Post:
cancer10 (06-14-2008)
Old 01-08-2008, 02:03 PM   #5 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Can you not see the image in my original post?

Sorry a bit tired.
Orc is offline  
Reply With Quote
The Following User Says Thank You to Orc For This Useful Post:
cancer10 (06-14-2008)
Old 01-08-2008, 02:25 PM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Thanks for your replies. So in that case, what is Kalle going on about in this post?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
cancer10 (06-14-2008)
Old 01-08-2008, 02:41 PM   #7 (permalink)
The Addict
Top Contributor Good Samaritan 
 
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
RobertK is on a distinguished road
Default

I honestly have no clue, I'm not very experienced with GD. I do browse the manuals as I find questions though. From what I understand, as of PHP5, there's no predefined filter for waves or "wet floor"-like effects. imagefilter() is the function that applies a filter, but the defined constants don't include a wave filter.

Maybe they have a newer version?

Edit:

I think I found it, all the functions are hand made using the imagecopy() function. Some of the user contributed code is(authors bolded before the code):
administrador(ensaimada)sphoera(punt)com
PHP Code:
function wave_region($img$x$y$width$height,$grade=5){
        for (
$i=0;$i<$width;$i+=2){
            
imagecopy($img,$img,
                
$x+$i-2,$y+sin($i/10)*$grade,     //dest
                
$x+$i,$y,             //src
                
2,$height);
        }
    } 
designerkamal at gmail dot com
PHP Code:
function Skew($src$dest$skew_val)
{
  
$imgsrc imagecreatefromgif($src);
  
$width imagesx($imgsrc);
  
$height imagesy($imgsrc);
  
$imgdest imagecreatetruecolor($width$height+($height*$skew_val));
  
$trans imagecolorallocate($imgdest,0,0,0);
  
$temp=0;
  for(
$x=$x<$width $x++)
   {
     for(
$y=$y<$height $y++)
    {
        
imagecopy($imgdest$imgsrc$x$y+$temp$x$y11);
      
imagecolortransparent($imgdest,$trans);
       
    }
    
$temp+=$skew_val;
   }
  
imagepng($imgdest$dest);
  
imagedestroy($imgsrc);
  
imagedestroy($imgdest);

You could probably inspire some code for yourself based off these two functions, and get a slightly wavy skew filter.
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook

Last edited by RobertK : 01-08-2008 at 02:50 PM. Reason: Think I found it...
RobertK is offline  
Reply With Quote
The Following User Says Thank You to RobertK For This Useful Post:
cancer10 (06-14-2008)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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


All times are GMT. The time now is 10:44 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design