August 10, 2011

Skew and image with PHP image libaray gd2

function skewed($fileName, $dest, $skew_val) { $mime_type = getimagesize($fileName); //print_r($mime_type); switch($mime_type[‘mime’]) { case ‘image/png’: $src = imagecreatefrompng($fileName); break; case ‘image/gif’: $src = imagecreatefromgif($fileName); break; case ‘image/jpeg’: $src = imagecreatefromjpeg($fileName); break; case ‘image/wbmp’: $src = imagecreatefromwbmp($fileName); break; } $width = imagesx($src); $height = imagesy($src); $imgdest = imagecreatetruecolor($width, $height+($height*$skew_val)); $trans = imagecolorallocate($imgdest,0,0,0); $temp=0; for($x=0 ; $x

Merge two images with php image libraries gd2 and imagick

function mergeFrontBack($img_front, $img_back, $final_output, $x, $y, $imagick=FALSE) { if($imagick) { $overlay = new Imagick($img_front); $bg = new Imagick($img_back); $temp_image = new Imagick(); $d = $overlay->getImageGeometry(); $w = $d[‘width’]; $h = $d[‘height’]; $bg_temp = $this->prefixToImg(‘_temp’,$bg); $bg_copy = $this->prefixToImg(‘_copy’,$bg); $temp_image->newImage($w, $h, new ImagickPixel(‘white’)); $temp_image->setImageFormat(‘png’); $temp_image->writeImage($bg_temp); // Set the colorspace to the same value $temp_image->setImageColorspace($bg->getImageColorspace()); //Second image is […]

August 9, 2011

Calling JS function from outside the iframe

Calling JS function from outside the iframe Parent File: <iframe src=”iframe.php” width=”100″ height=”100″ name=”iframName”></iframe> <script language=”javascript” type=”text/javascript”> function callFunc() { alert(‘Working!’); } </script> Iframe File: <a href=”#” onclick=”parent.callFunc();”>Click here</a>

August 6, 2011

PHP Image Manipulation and Related Issues

PHP Image Manipulation and Related Issues Image manipulation in php is always remain as favorite as upload image functionality being better. Multiple uploader like fancy uploader using mootools lighten the image manipulation aspect once again. HTML 5 is coming up with the feature of progress bar and multiple uploads. This will certainly open another door […]

August 4, 2011

Add prefix to a file, add prefix to an image

Add prefix to a file, add prefix to an image: function prefixToImg($prefix,$img_src) { $img = explode(‘/’,$img_src); $img[(count($img)-1)] = $prefix.$img[(count($img)-1)]; return implode(‘/’,$img); }

preg_match, preg_match_all, preg_replace

To fetch all images from html content: preg_match_all(‘/]+>/i’,$content, $images_src); & $imgsrc_regex = ‘#<\s*img [^\>]*src\s*=\s*([“\’])(.*?)\1#im’; Function to get attributes of img tag: function img_plain($html,$tag=’src’) { if (stripos($html, ‘<img’) !== false) { $imgsrc_regex = ‘#<\s*img [^\>]*’.$tag.’\s*=\s*([“\’])(.*?)\1#im’; preg_match($imgsrc_regex, $html, $matches); unset($imgsrc_regex); unset($html); if (is_array($matches) && !empty($matches)) { $img = $matches[2]; return $img; } else { return false; } […]

July 21, 2011

joomla plain text page with format raw

This was a problem for php developers that they wanted to use AJAX functionality in their joomla components and modules. But when they find that index.php always include code within the XHTML-template of joomla template and thats not what they needed. Instead of generating XML for to evaluate in JavaScript without any XHTML rendered is […]

July 14, 2011

create facebook applications

create facebook applications Please follow the steps: Click here to start http://developers.facebook.com/ http://developers.facebook.com/docs/guides/canvas/ to view your facebook applications: https://developers.facebook.com/apps Click on create an app Enter your application name Enter validation code Provide Basic Information That’s it This article create facebook applications is just a quick review of steps for those developers who want such steps […]