Limbaje de Programare ( C++, Java, HTML, PHP, etc.)

19 484 vizualizări
610 răspunsuri
Arrow
MW Addicted
9475 mesaje
din 30/07/2005
29 aprecieri
11 martie 2007, 08:25:19 • actualizat 11 martie 2007, 08:45:04 (2 ori)
modoran view here http://www.javascript.com/

cod sursa php pentru image resizer

image_resizer.php
<?php

//get the image variables from the url

//$image_source - the source of the image

$image_source = $_GET['image'];

//$max_width and $max_height are the maximum width and height of the image

$max_width = $_GET['w'];
$max_height = $_GET['h'];

//if there is an image

if($image_source!=""){

//the parameters for the image

$image_params = image_type($image_source);

//creat the image resource

$im = $image_params[1]($image_source);

//width and height of the image

$width = imagesx($im);
$height = imagesy($im);

//ratio to maximum width and height
//the larger ratio is the one that needs to be resized

$w_ratio = $width/$max_width;
$h_ratio = $height/$max_height;

//if the width ratio is larger

if($h_ratio<$w_ratio){

//resize the width to the max width

$wid = $max_width;

//resize the height proportionately

$heig = floor($height / $w_ratio);
$chng=1;
}

//if the height ratio is greater

elseif($h_ratio>$w_ratio){

//resize the height to the max height

$heig = $max_height;

//resize the width proportionately

$wid = floor($width / $h_ratio);
$chng=1;
}

//if the ratios are the same and the image needs to be smaller

elseif(($h_ratio==$w_ratio) && ($height>$max_height)){

//height is max height

$heig = $max_height;

//set width as a proportion using the height ratio

$wid = floor($width / $h_ratio);
$chng=1;


}

//if the ratios are the same and the image needs to be larger

elseif(($h_ratio==$w_ratio) && ($height<$max_height)){

//set the height and width as the max height and max width

$heig = $max_height;
$wid = $max_width;
$chng=1;

}

//if the sizes needed resizing

if($chng==1){

//create a new image resource

$resize_img = imagecreatetruecolor($wid,$heig);

//fill the image with white
$white = imagecolorallocate($resize_img,255,255,255);
imagefilledrectangle($resize_img,0,0,$wid,$heig,$white);

//copy the original image to the new image resource with the new size

imagecopyresampled($resize_img,$im,0,0,0,0,$wid,$heig,$width,$height);

//headers

header("$image_params[0]");

//send the image

$image_params[2]($resize_img);

//destroy the image

//modified thanks to randy's comment

imagedestroy($im);
imagedestroy($resize_img);
}

//if the image does not need resizing

else{

//headers

header("$image_params[0]");

//send the image

$image_params[2]($im);

//destroy the image
//modified thanks to randy's comment

imagedestroy($im);
}
}


/*
Creates an array of image values used above
$image_params[0] - the image headers
$image_params[1] - Creates the image
$image_params[2] - displays the image
*/

function image_type($v){

//find the filetype

$type = strtolower(strrchr($v,"."));

//depending what image file is used - different params are needed

switch($type){

case'.jpg':
$image_params = array("Content-type:image/jpeg",
"imagecreatefromjpeg","imagejpeg");
break;

case'.jpeg':
$image_params = array("Content-type:image/jpeg",
"imagecreatefromjpeg","imagejpeg");
break;

case'.gif':
$image_params = array("Content-type:image/gif",
"imagecreatefromgif","imagegif");
break;

case'.png':
$image_params = array("Content-type:image/png",
"imagecreatefrompng","imagepng");
break;

}

//return the image paramaters array

return($image_params);
}

?>
Publicitate
Publicitate
Draculea
MW Addicted
1513 mesaje
din 07/10/2005
18 aprecieri
Nokia3220
29 martie 2007, 11:35:37
Stie cineva un program cu care pot sa decompilez un fiesier .exe facut in borlandc. Un prieten a facut un program si mi-a dat doar executabilul si vreau sa vad codu sursa.
otzy_007
MW Addicted
1350 mesaje
din 09/09/2006
29 martie 2007, 14:51:57
poate doar sa-l dezansamblezi. pt decompilare este un program, dar e foarte scump 1000-2000usd si nu-l gasesti trial sau furat
Draculea
MW Addicted
1513 mesaje
din 07/10/2005
18 aprecieri
29 martie 2007, 16:28:26
asta era un fel de "virus" care se instala la startup si de fiecare data cand pornea stergea cate ceava. si eu vroiam sa gasesc o solutie pentru el...
otzy_007
MW Addicted
1350 mesaje
din 09/09/2006
Opera Mini
29 martie 2007, 17:03:36
Cea mai simpla solutie run-msconfig si-l dezactivezi sau hklm-software-microsoft-windows-current version-run
Dicocodino
MW Addicted
1151 mesaje
din 16/07/2005
10 aprilie 2007, 18:42:12
Are si poate uploada cineva un tutorial despre comunicarea programelor cu portul USB care sa trimita mai departe informatii spre un aparat ? Nu prea am gasit pe google... Vreau sa aprind niste leduri facand un joc intre ele. Mi-ar place ca tutorialul sa foloseasca pentru exemple un limbaj mai cunoscut precum C++, Python, Pascal. Mutumesc anticipat. :)
calc
MW Addicted
2952 mesaje
din 01/09/2006
10% warn
MOT-V980M
19 aprilie 2007, 10:31:13
Ce eroare e asta: Parse error : syntax error, unexpected T_ENCAPSED_AND_WHITESP ACE, expecting ']' ???
otzy_007
MW Addicted
1350 mesaje
din 09/09/2006
19 aprilie 2007, 15:05:11
depinde ce ai scris tu in script. pune sursa scriptului aici sa vedem ce e cu el
calc
MW Addicted
2952 mesaje
din 01/09/2006
10% warn
MOT-V980M
19 aprilie 2007, 15:19:42
oh :( gata, era de la mine! pusesem un tag gresit ce dadea acea eroare  :D s-a rezolvat  ;) inca ceva: la ce foloseste functia php mail () ???
modoran
MW Addicted
7608 mesaje
din 26/01/2006
38 aprecieri
Symbian
19 aprilie 2007, 15:23:03
Ce intrebare "desteapta" :down:
calc
MW Addicted
2952 mesaje
din 01/09/2006
10% warn
MOT-V980M
19 aprilie 2007, 15:26:33
bine mai modoran. pana postai aia, mai bine raspundeai frumos! nimeni nu s-a nascut invat, dar unii vor sa invete si altii rad de ei :death:
otzy_007
MW Addicted
1350 mesaje
din 09/09/2006
19 aprilie 2007, 15:28:46
pt trimiterea de mailuri de pe hostul respectiv  :D
http://www.php.net/manual/en/ref.mail.php
calc
MW Addicted
2952 mesaje
din 01/09/2006
10% warn
MOT-V980M
19 aprilie 2007, 15:29:51
mersi :) @otzy_007
modoran
MW Addicted
7608 mesaje
din 26/01/2006
38 aprecieri
Symbian
19 aprilie 2007, 15:32:25
Mailuri se mai pot trimite si prin smtp cu fsockopen()
Publicitate
Publicitate
otzy_007
MW Addicted
1350 mesaje
din 09/09/2006
19 aprilie 2007, 15:46:43
da dar poti configura functia mail() sa le trimita astfel
Înapoi la Creative Corner
cine e aici?
Subiectul a fost creat la .
Hei! Pentru a putea interacționa cu comunitatea Mobilewave trebuie să ai un cont (care e gratuit) și să fii autentificat.
fortnite map
mowned logo
Inițiator acum 20 ani
wapavo
MW Veteran
Ultimul acum 14 ani
TABela
MW Addicted
Cauta in topic
Unelte topic
Dacă vă place acest articol trimiteți mai departe!
  • Arăta mai bine înainte.. 28% ⋅ 39
  • E frumos dar nu prea 23% ⋅ 32
  • Laser frate! 48% ⋅ 66
Au votat 137 utilizatori
^
Mobilewave.ro logo
MobileWave.ro 2005-2014
© MW v1.0a PhoeniX
0.032⋅4⋅6
Portalul tău de telefoane mobile!