Jump to content

php image resize


duane

Recommended Posts

My older brother helped me with this and now i'm stuck as he's not here.

I'm really new to php, sois h but he knows more than me. I'm more a designer.

 

He helped me set up a simple text logo generator on coolyankee.com

It works how it should, but I need the image that is rendered to always resize to 125x35

I can't get it to work at all...ive searched for days online and asked so many people im almost about ready to give up.

 

Below is the processing.php file that does everything, the image files are in a dif folder and there's the index.html that's all.

 

Please help me out here as I really need this for friday afternoon.

I appreciate your willingness to help.

 

<?
error_reporting(E_ERROR);
error_reporting(0);
header("Content-Type: image/png");
$str=$_POST["usertext"];
$style=$_POST["style"];
$ln=strlen($str);
function Loadpng($imgname)
{
    $im = @imagecreatefrompng($imgname); /* Attempt to open */
    return $im;
}
$i=0;
$wx=0;
while ($i<$ln) {
    $text[$i]=substr($str,$i,1);
    $index[$i]=ord($text[$i]);
    $array = array('images/style', $style, '/', $index[$i], '.png');
    $iurl = join("", $array);
    //echo $iurl;
    //$iurl="images/style1";
    //$into="48";
    //$iurl=$iurl."/".$into.".png";
    //$iurl='images/style'.$style.'/'.$index[$i].'.png';
    //echo $iurl;
    $img[$i] = Loadpng($iurl);
    $wx=$wx+imagesx($img[$i]);
    $i++;
}

$array = array('images/style', $style, '/logo.png');
$flog = join("", $array);
$fl=Loadpng($flog);
$wlh=imagesy($fl);
$wlw=imagesx($fl);

$array = array('images/style', $style, '/logoe.png');
$floge = join("", $array);
$fle=Loadpng($floge);
$wlhe=imagesy($fle);
$wlwe=imagesx($fle);

$wh=imagesy($img[0]);
$wd=$wx+$wlw+$wlwe;
$logo  = imagecreatetruecolor($wd, $wh);
$bgc = imagecolorallocate($logo, 255, 255, 255);
imagefilledrectangle($logo, 0, 0, $wd, $wh, $bgc);
$wx=0;
$i=0;
imagecopy($logo, $fl, $wx, 0, 0, 0, $wlw, $wh);
$wx=$wx+$wlw;

while ($i<$ln) {
    imagecopy($logo, $img[$i], $wx, 0, 0, 0, imagesx($img[$i]), $wh);
    $wx=$wx+imagesx($img[$i]);
    $i++;
}
imagecopy($logo, $fle, $wx, 0, 0, 0, $wlwe, $wh);
imagepng($logo);
die();
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/92295-php-image-resize/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.