Skip to main content

Posts

Showing posts from May, 2015

Re size captures image from Web before Uploading.

1) Add a input file tag in your html page.

<input type="button" value="Capture" onclick="document.getElementById('image').click(); return false;" />

<input type="file" accept="image/*" capture="camera" id="image" style="visibility: hidden;">

2) Add below jquery script:

var image= document.getElementById('image');

image.onchange = function() {
var file = image.files[0];
var img = document.createElement("img");
var reader = new FileReader();
reader.onload = function(e) {
img.src = e.target.result;
img.onload = function () {
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var MAX_WIDTH = 400;
var MAX_HEIGHT = 300;
var width = this.width;
var height = this.height;
if (width > height) {
if (width > MAX_WIDTH) {
height *= MAX_WIDTH / width;
width = MAX_WIDTH;
}
} else {
if (height > MAX_HEIGHT) {
width *= MAX_H…

Creating Text as Image using PHP

You can simply represent a text as image using PHP by simple following program.

<?php
header("Content-type:image/jpeg");
$text = "Hello World! Hows You???";
$textlLength = strlen($text);
$fontSize = 5;

/* imagefontheight() returns the pixel height of a character in specified font. */
$imageHeight = imagefontheight($fontSize);

/* imagefontwidth() returns the pixel width of a character in specified font. */
$imageWidth = imagefontwidth($fontSize) * $textLength;

/* imagecreate() returns an image identifier representing a blank image of specified size. */
$image = imagecreate($imageWidth, $imageHeight);

/* imagecolorallocate() allocated colour to an image */
imagecolorallocate($image, 255, 255, 255);
$fontColor = imagecolorallocate($image, 0, 0, 0);

/* imagestring() draws a string horizontally at given co-ordinates. */
imagestring($image, $fontSize, 0, 0, $text, $fontColor);

/* imagejpeg() creates a jpeg file from given image. */
imagejpeg($image);
?>

Output will looks like below:


Implementing Client Side WebRTC using Sipml5 javascript

Step 1:

Download and require Sipml5 library function.

Step 2:

Initialize sipml5 Engine in your web page :

var readyCallback = function(e) {
// function called when sipml is successfully initialised.
createSipStack(); // calling this function to create sip stack(see below)
};

var errorCallback = function(e) {
// function called when error occured during sipml initialisation.
};

SIPml.init(readyCallback, errorCallback);

Step 3:

Create Sip Stack :-
Sip Stack is an object that must be created before making/receiving call and sms. Creating Sip stack is an asynchronous process, so you need to create an event listener function to get state change notification.

var sipStack;

function EventListener(e) {

/*
* e.type ;type of event listener
* e.session ; current event session
* e.getSipResponseCode() ; event response code
* e.description ; event description
*/

if(e.type == 'started'){
// successfully started the stack.
register();
} else if(e.type == 'i_new_call'){
// when new incoming call comes.
      …