Advertisement
3_2004-2005 Graphics/ Sound #148650

Image ratio resampler

Resamples an uploaded image to 75% jpeg, without changing the ratio! If x and y size is equal, the image will be [100px]*[100px]. If x is bigger than y, the image will be [150px or less] * [100px]. If y is bigger than x, the image will be [100px] * [150px or less].

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
	$UploadedFile = $_FILES['fileupload']['tmp_name'];
	$Quality = 75;
	$CurrentX = imagesx($UploadedImage);
	$CurrentY = imagesy($UploadedImage);
	if($CurrentX >= $CurrentY) {
		$MaxX = 150;
		$MaxY = 100;
		$NewX = $MaxX;
		$NewY = $CurrentY/($CurrentX/$MaxX);
		if($NewY > $MaxY) {
			$NewY = $MaxY;
			$NewX = $CurrentX/($CurrentY/$MaxY);
		}
	} else {
		$MaxX = 100;
		$MaxY = 150;
		$NewY = $MaxY;
		$NewX = $CurrentX/($CurrentY/$MaxY);
		if($NewX > $MaxX) {
			$NewX = $MaxX;
			$NewY = $CurrentY/($CurrentX/$MaxX);
		}
	}
	$im = imagecreatetruecolor($NewX, $NewY);
	imagecopyresampled($im, $UploadedImage, 0, 0, 0, 0, $NewX, $NewY, $CurrentX, $CurrentY);
	imagejpeg($im, $_FILES['fileupload']['tmp_name'], $Quality);
' Description:Send email(s) to an SMTP server, 
' to multiple recipients, with attachments etc. 
' Easy to use, no IIS or MS SMTP service required.
'
' You need the FREEWARE AEmail.dll to run the sample.
' Download it from http://www.vahland.com/pub/aemail.dll
' and register it on your machine.
' Then, choose 'Add Reference' from your Solutions Window,
' and 'Add' the 'ActivEmail 2.1 Type Library'.
' 
' Read http://www.vahland.com/pub/aemail.htm for more info.

Imports AEMAILLib
Module Module1
  Sub Main()
    Dim objSmtpMail As AEMAILLib.SmtpMailClass
    Console.WriteLine("Be sure To have the FREEWARE AEmail.dll registered on your system,")
    Console.WriteLine("and add the ActivEmail 2.1 Type Library to your references.")
    Console.WriteLine("Check out the code header about how to obtain the free component.")
    Console.WriteLine("")
    objSmtpMail = New AEMAILLib.SmtpMailClass()
    objSmtpMail.HostName = "yourmailserver.yourdomain.dom"
    objSmtpMail.FromName = "Senders Name"
    objSmtpMail.FromAddress = "sender@sendersdomain.dom"
    objSmtpMail.AddTo("john.doe@domain.dom", "John Doe")
    objSmtpMail.Subject = "My Subject"
    ' If you want, you can include attachment, multiple recipients, rich text formatting etc.
    ' It's not included in this sample to keep sample straight.
    objSmtpMail.Body = "Here is the body text" & vbCrLf & "Best regards..."
    objSmtpMail.Send()
    Console.WriteLine("Send, result: " & objSmtpMail.LastError.ToString())
    objSmtpMail.Clear() ' To use the same object again with all properties cleared
  End Sub
End Module
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine