Jump to content

vbnullchar

Members
  • Posts

    428
  • Joined

  • Last visited

Posts posted by vbnullchar

  1. got it working.. put the water first then resize.

     

    
    
    $srcimg = "test.jpg"; //the source file
    $tmimg = "sm_".$srcimg; //were to place the thumb
    $wmimg = "hack.png"; //the watermark files
    $target = 150; //thumbnail target size
    $waterlevel = 40; //the level of opacity
    
    //load the jpeg and get its sizes
    $image = imagecreatefromjpeg($srcimg);
    $size = getimagesize($srcimg);
    
    //make watermage img | and get its sizes;
    $watermark = imagecreatefrompng($wmimg);
    $watermark_width = imagesx($watermark);
    $watermark_height = imagesy($watermark);
    
    //this will place it Bottom-Left, 5px from the border
    $dest_x = $size[0] - $watermark_width - 5;
    $dest_y = $size[1] - $watermark_height - 5;
    
    //copy it over | save it over the original | and clean up
    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $waterlevel);
    
    //this if just figures out what side is dominant
    if ($size[0] > $size[1]) {
    $percentage = ($target / $size[0]);
    } else {
    $percentage = ($target / $size[1]);
    }
    //calc the thumb sizes
    $newwidth = round($size[0] * $percentage);
    $newheight = round($size[1] * $percentage);
    
    //make a new img | copy the smaller | save as jpeg | clean up
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    imagecopyresized($thumb, $image, 0, 0, 0, 0, $newwidth, $newheight, $size[0], $size[1]);
    imagejpeg($thumb, $tmimg);
    imagedestroy($thumb);
    
    imagedestroy($watermark);
    imagedestroy($image);
    
    

  2. The scope of a variable is the context within which it is defined.

     

    use the global keyword to access variables outside the function..

     

    
    $result = mysql_query($sql)
       or die(mysql_error());
    
    function timeCompare()
    {
    
    [b]global $result[/b]
    
       while ($row = mysql_fetch_array($result))
        {
          echo "<td>". $row["date"] ."</td>";
        }
       
    }
    
    

  3. okay I got it...

     

    <?php
    
    $csv1 = array(
    array(4,5,6),
    array(99,23,42),
    array(112,282,131),
    array(22,282,131),
    array(42,1282,1131),
    array(12,282,131),
    array(14,2,3),
    array('b1','b2','b3'),
    array('a','a2','a3')
    );
    
    function __unset(&$arr){ unset($arr[0]); }
    
    foreach($csv1 as $k => $value){ $v[] = array_merge((array) substr($value[0],0,1), $value ); }
    
    array_multisort($v);
    array_walk($v, "__unset");
    print_r($v);
    

  4. try the code below.. this is from http://www.php.net/function.mail

     

    <?php
    // multiple recipients
    $to  = 'aidan@example.com' . ', '; // note the comma
    $to .= 'wez@example.com';
    
    // subject
    $subject = 'Birthday Reminders for August';
    
    // message
    $message = '
    <html>
    <head>
      <title>Birthday Reminders for August</title>
    </head>
    <body>
      <p><b>Here are the birthdays upcoming in August!</b></p>
    </body>
    </html>
    ';
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
    $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
    $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
    $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
    
    // Mail it
    mail($to, $subject, $message, $headers);
    ?>
    
    

×
×
  • 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.