WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : imageconvolution() does not appear in PHP with non-bundled GD libraries or a PHP version lower than 5.1. I wrote a replication of imageconvolution() in PHP.
Categories : PHP, GD image library, Graphics Click here to Update Your Picture
Chao Xu
Date : Mar 13th 2007
Grade : 1 of 5 (graded 1 times)
Viewed : 5632
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Chao Xu
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
Like this code?
Show the author your appreciation.
 

imageconvolution() does not appear in PHP with non-bundled GD libraries or a PHP version lower than 5.1.
It is a rare situation(if PHP developers are smart and use a PHP5 hosting), but it still happens. That’s why I wrote a replication of imageconvolution() in PHP, because it’s written in PHP, it is 50 times slower than the bundled version. But compare to the one listed on PHP.net’s comment by interghost at crovortex dot com, this is 30% faster and supports offset.

imageconvolution() does not appear in PHP with non-bundled GD libraries or a PHP version lower than 5.1.
It is a rare situation(if PHP developers are smart and use a PHP5 hosting), but it still happens. That’s why I wrote a replication of imageconvolution() in PHP, because it’s written in PHP, it is 50 times slower than the bundled version. But compare to the one listed on PHP.net’s comment by interghost at crovortex dot com, this is 30% faster and supports offset.

<?php
if(!function_exists(‘imageconvolution’)){
function
imageconvolution($src, $filter, $filter_div, $offset){
    if (
$src==NULL) {
        return
false;
    }
   
   
$sx = imagesx($src);
   
$sy = imagesy($src);
   
$srcback = ImageCreateTrueColor ($sx, $sy);
   
ImageCopy($srcback, $src,0,0,0,0,$sx,$sy);
   
    if(
$srcback==NULL){
        return
0;
    }
       
    for (
$y=0; $y<$sy; ++$y){
        for(
$x=0; $x<$sx; ++$x){
           
$new_r = $new_g = $new_b = 0;
           
$alpha = imagecolorat($srcback, $pxl[0], $pxl[1]);
           
$new_a = $alpha >> 24;
           
            for (
$j=0; $j<3; ++$j) {
               
$yv = min(max($y - 1 + $j, 0), $sy - 1);
                for (
$i=0; $i<3; ++$i) {
                       
$pxl = array(min(max($x - 1 + $i, 0), $sx - 1), $yv);
                   
$rgb = imagecolorat($srcback, $pxl[0], $pxl[1]);
                   
$new_r += (($rgb >> 16) & 0xFF) * $filter[$j][$i];
                   
$new_g += (($rgb >> 8) & 0xFF) * $filter[$j][$i];
                   
$new_b += ($rgb & 0xFF) * $filter[$j][$i];
                }
            }

           
$new_r = ($new_r/$filter_div)+$offset;
           
$new_g = ($new_g/$filter_div)+$offset;
           
$new_b = ($new_b/$filter_div)+$offset;

           
$new_r = ($new_r > 255)? 255 : (($new_r < 0)? 0:$new_r);
           
$new_g = ($new_g > 255)? 255 : (($new_g < 0)? 0:$new_g);
           
$new_b = ($new_b > 255)? 255 : (($new_b < 0)? 0:$new_b);

           
$new_pxl = ImageColorAllocateAlpha($src, (int)$new_r, (int)$new_g, (int)$new_b, $new_a);
            if (
$new_pxl == -1) {
               
$new_pxl = ImageColorClosestAlpha($src, (int)$new_r, (int)$new_g, (int)$new_b, $new_a);
            }
            if ((
$y >= 0) && ($y < $sy)) {
               
imagesetpixel($src, $x, $y, $new_pxl);
            }
        }
    }
   
imagedestroy($srcback);
    return
true;
}
}
?>



PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
Advanced Image WaterMarker
Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented
a simple pie-chart in php3 (with gd)
Categories : PHP, Graphics, GD image library, Charts and Graphs
Display a bar chart based on random values.
Categories : Graphics, PHP, GD image library, Charts and Graphs
Image Generation Class ( PNG Format )
Categories : PHP, GD image library, PHP Classes, Graphics
A captcha image allows you to prevent spam posting when users reload the page and stop bots from submitting forms automatically. This version allows you to use your own fonts (.ttf) to show the text.
Categories : PHP, Security, Graphics, GD image library
Simple PHP Bar Graph using GD library
Categories : PHP, GD image library, Graphics, Arrays
EasyPhpThumbnail Class - The EasyPhpThumbnail class allows you to generate thumbnails and handle image manipulation for GIF, JPG and PNG on-the-fly.
Categories : PHP, PHP Classes, Object Oriented, Graphics, GD image library
PHP Image Compression using GD library
Categories : PHP, Compression, GD image library, Graphics
Line graphics generation library written in PHP + GD library (spanish comments)
Categories : PHP, Graphics, GD image library
CAPTCHA[Image verification]
Categories : PHP, Security, GD image library, Graphics, Sessions
imageMarker v 3.00 with new advanced features
Categories : PHP, PHP Classes, Graphics, GD image library
Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
Generate image with random number (CAPTCHA)
Categories : PHP, GD image library, Graphics, Security