You will get black background if you resize a transparent image. To fix it, You need set alpha channel imagecolorallocatealpha to 127. With imagecolorallocatealpha, it will allocate a color for an image.
Usage:
int imagecolorallocatealpha ( resource image, int red, int green, int blue, int alpha)
From PHP manual:
imagecolorallocatealpha() behaves identically to imagecolorallocate() with the addition of the transparency parameter alpha which may have a value between 0 and 127. 0 indicates completely opaque while 127
indicates completely transparent. Returns FALSE if the allocation failed.
Before using it, you must set to false the blending mode for an image and set true the flag to save full alpha channel information.
Example:
<?
$newImg = imagecreatetruecolor($nWidth, $nHeight);
imagealphablending($newImg, false);
imagesavealpha($newImg,true);
$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]);
?>
Another way to fix this issue:
phpThumb() - Resize images on the fly
Description: phpThumb() uses the GD library to create thumbnails from images (JPEG, PNG, GIF, BMP, etc) on the fly. The output size is configurable (can be larger or smaller than the source), and the source may be the entire image or only a portion of the original image.
Download: Download
Site: phpThumb()
Demo: Demo
Installation:
1. unzip the folder and upload the content into the server
2. give the correct path of the phpThumb.php and image path as per the following syntax
Resize Syntax:
<img src="../phpThumb.php?src=images/watermark.png&bg=FFFFFF&f=png" alt="">
<img src="../phpThumb.php?src=images/watermark.png&bg=FFFFFF&f=gif" alt="">
<img src="../phpThumb.php?src=images/watermark.png&bg=FFFFFF&f=jpeg" alt="">
where the bg=FFFFFF represents the bg color of your transparent image.
If you are new to the virtue mart shopping cart software, the following steps will help you to add additional product images in Product details page.
Assumptions:
You are using,
- Joomla 1.5 or Joomla 1.0.x
- Virtue Mart 1.1.0 stable.
Steps to add additional images in Product details page:
- Go to virtue mart admin panel
- Choose “choose extended layout” <helps easy navigation>
- List out your products.
- Click on media button. A new popup will be opened.
- Click the new button to add additional images
- Choose additional image s as option, give appropriate height and width for the image
- Click on save button. That’s all
I am not sure about, it will work for lower version of virtue mart also. Please check and gimme a feed back to this post.
The following pictures help you for easy understanding.






Reset your local wordpress password easily
While building my theme I installed wordpress with lots of sample data and I realized.
mysql picture
I forgot my password and couldn't recover it even with a "forgot password" link. So after
playing around for 30 mins, I reset my password. This is how.
Wordpress admin login error happen for two following reason:
- User may forgot the admin password
- User might have entered wrong site url in setting tab
go to your mysql administrator (usually called as phpmyadmin)
- select your wordpress database
- run the following update query with your password as in bracket using sql tab
SELECT 'wordpress' //this should be your database name
UPDATE `wp_users` SET `user_pass` = MD5( 'password' ) WHERE `ID` =1 LIMIT 1 ;
where password is your new password. Your password is reset, for the admin acount.
For admin side login problem, there might be another reason. You might have given wrong site
url. This can be update by the following query
UPDATE `wp_options` SET `option_value` = 'You site url' WHERE `wp_options`.`option_id` =1
LIMIT 1 ;
It will update your site url in the wp_options table and it will solve your login error.
<head>
<script type="text/javascript">
function makAx() // this function to activate XMLHttpRequest Object
{
try
{
xm = new ActiveXObject("Msxml2.XMLHTTP");
return true;
}
catch (e)
{
try
{
xm = new ActiveXObject("Microsoft.XMLHTTP");
return true;
}
catch (e2)
{
xm = false;
}
}
if (!xm && typeof XMLHttpRequest != ‘undefined’)
{
xm = new XMLHttpRequest();
return true;
}
}
function showImages()
{
if(makAx()) // XMLHttpRequest checked here
{
url = "external-page-for-db-query.php"; // this file will contains your db query
callavail();
}
}
function callavail()
{
xm.open("GET",url,true); // This is ajax functionality. It may have true(for synchronous request) or false(for asynchronous request)
xm.onreadystatechange = cavail;
xm.send(null);
}
function cavail()
{
if(xm.readyState == 4) // If ready state reached
{
var response = xm.responseText;
var str = document.getElementById("showResult"); // result of "external-page-for-db-query.php" will come here
str.innerHTML = response;
setTimeout("showImages()",1000); // here 1000 represents one second for time delay. showImage() function will be called with the specified time delay
}
}
</script>
</head>
<body>
<div id="showResult"></div> <!–page result will be displayed here–>
</body>
</html>