PHP 对 png 图像进行缩放,支持透明背景
{
if ( $height <= 0 && $width <= 0 ) {
return false;
}
$info = getimagesize($file);
$image = ”;
$final_width = 0;
$final_height = 0;
list($width_old, $height_old) = $info;
if ($proportional) {
if ($width == 0) $factor = $height/$height_old;
elseif ($height == 0) $factor = $width/$width_old;
else $factor = min ( $width / $width_old, $height / $height_old);
$final_width = round ($width_old * $factor);
$final_height = round ($height_old * $factor);
}
else {
$final_width = ( $width <= 0 ) ? $width_old : $width;
$final_height = ( $height <= 0 ) ? $height_old : $height;
}
switch ($info[2] ) {
case IMAGETYPE_GIF:
$image = imagecreatefromgif($file);
break;
case IMAGETYPE_JPEG:
$image = imagecreatefromjpeg($file);
break;
case IMAGETYPE_PNG:
$image = imagecreatefrompng($file);
break;
default:
return false;
}
$image_resized = imagecreatetruecolor( $final_width, $final_height );
if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) {
$trnprt_indx = imagecolortransparent($image);
// If we have a specific transparent color
if ($trnprt_indx >= 0) {
// Get the original image’s transparent color’s RGB values
$trnprt_color = imagecolorsforindex($image, $trnprt_indx);
// Allocate the same color in the new image resource
$trnprt_indx = imagecolorallocate($image_resized, $trnprt_color[‘red’], $trnprt_color[‘green’], $trnprt_color[‘blue’]);
// Completely fill the background of the new image with allocated color.
imagefill($image_resized, 0, 0, $trnprt_indx);
// Set the background color for new image to transparent
imagecolortransparent($image_resized, $trnprt_indx);
}
// Always make a transparent background color for PNGs that don’t have one allocated already
elseif ($info[2] == IMAGETYPE_PNG) {
// Turn off transparency blending (temporarily)
imagealphablending($image_resized, false);
// Create a new transparent color for image
$color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127);
// Completely fill the background of the new image with allocated color.
imagefill($image_resized, 0, 0, $color);
// Restore transparency blending
imagesavealpha($image_resized, true);
}
}
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);
if ( $delete_original ) {
if ( $use_linux_commands )
exec(‘rm ‘.$file);
else
@unlink($file);
}
switch ( strtolower($output) ) {
case ‘browser’:
$mime = image_type_to_mime_type($info[2]);
header("Content-type: $mime");
$output = NULL;
break;
case ‘file’:
$output = $file;
break;
case ‘return’:
return $image_resized;
break;
default:
break;
}
switch ($info[2] ) {
case IMAGETYPE_GIF:
imagegif($image_resized, $output);
break;
case IMAGETYPE_JPEG:
imagejpeg($image_resized, $output);
break;
case IMAGETYPE_PNG:
imagepng($image_resized, $output);
break;
default:
return false;
}
return true;
}
波比源码 » PHP 对 png 图像进行缩放,支持透明背景
purchase levofloxacin for sale levofloxacin 500mg for sale
order avodart generic zofran usa zofran 8mg uk
spironolactone 100mg canada buy diflucan 100mg generic buy diflucan pill
buy ampicillin sale cheap erythromycin 250mg order erythromycin 250mg generic
generic fildena 50mg generic methocarbamol order methocarbamol 500mg for sale
buy sildenafil 100mg online cheap oral sildenafil 100mg estradiol 2mg for sale
lamotrigine 200mg cost order vermox 100mg online brand retin
tadalafil cheap buy tadacip 20mg generic purchase voltaren generic
cheap isotretinoin 10mg amoxil generic buy generic zithromax 250mg
cost indocin order cefixime pills buy trimox 500mg without prescription
order cialis 5mg for sale us cialis sales buy sildenafil 50mg for sale
order prednisone 20mg tadalafil online canadian pharmacy sildenafil next day delivery
original tadalafil rezeptfrei sicher kaufen original cialis rezeptfrei sicher kaufen viagra ohne rezept
accutane 40mg without prescription isotretinoin 40mg oral buy ivermectin for humans uk
provigil uk buy diamox pills acetazolamide 250mg pills
order doxycycline 200mg pills doxycycline medication purchase furosemide online
order altace 10mg without prescription temovate tablet azelastine 10ml brand
buy buspar pill oxybutynin 2.5mg drug buy oxybutynin 2.5mg generic
hytrin 1mg pill cheap arava 10mg purchase sulfasalazine online
order alendronate 70mg online cheap paracetamol price cost famotidine 20mg
order olmesartan 20mg for sale buy verapamil acetazolamide order
order isosorbide 20mg without prescription telmisartan buy online telmisartan 80mg sale
zyban cost order seroquel online quetiapine 100mg generic
imuran us buy viagra online brand viagra
revia 50mg usa albendazole online buy abilify sale
oral medroxyprogesterone 10mg order biltricide 600 mg online order periactin 4mg for sale
levitra or cialis sildenafil 100mg without prescription order sildenafil 100mg without prescription
cialis without a doctor prescription tadalafil 5mg cheap buy anafranil generic
aralen brand olumiant 4mg sale buy baricitinib generic
zyprexa price order diovan pill diovan us
order clozapine generic ipratropium 100 mcg sale decadron 0,0,5 mg pills
buy prilosec 20mg sale i need a paper written for me slots real money
buy zyvox 600 mg online cheap free spins casino vegas casino online
metoprolol 100mg pill metoprolol 100mg brand purchase vardenafil online
professional paper writers best online casinos that payout chumba casino
buy levitra pill order vardenafil without prescription buy medrol 16 mg
clomiphene for sale online buy albuterol 2mg generic online slots for real money
dapoxetine online order cytotec brand buy synthroid 150mcg generic
buy xenical 120mg buy xenical 60mg buy acyclovir 400mg generic
order cialis pill buy inderal 20mg pills buy plavix pill
buy zyloprim 100mg pill buy allopurinol 300mg pills zetia tablet
buy methotrexate online cheap metoclopramide 20mg ca metoclopramide 10mg for sale
motilium drug purchase sumycin sale purchase flexeril generic
losartan 25mg sale losartan 25mg cost topamax 200mg pills
brand ozobax tizanidine price buy ketorolac without prescription
order colchicine for sale black jack card game free burton brunette
buy zantac online celecoxib 200mg price buy celecoxib without prescription
tamsulosin uk buy tamsulosin pill aldactone 100mg uk
simvastatin 10mg cost propecia 1mg over the counter proscar price
cialis 40mg cost oral sildenafil sildenafil fast shipping
buy viagra generic viagra 150mg price cialis 40mg cost
ceftin 250mg brand methocarbamol oral order methocarbamol 500mg
purchase prednisone online cheap deltasone 10mg price amoxil 1000mg for sale
order generic viagra sildenafil 100mg tablet purchase cialis generic
zithromax pills neurontin pill order gabapentin generic
best online casino order stromectol 6mg provigil 200mg over the counter
furosemide oral buy furosemide 40mg pills plaquenil 200mg brand
fildena 100mg generic rhinocort over the counter budesonide drug
retin gel sale cheap avanafil avanafil 200mg over the counter
tadalafil pills purchase tadacip without prescription order indocin for sale
terbinafine cost order cefixime 100mg pills trimox 250mg oral
purchase naprosyn without prescription buy generic prevacid 15mg generic prevacid 30mg
buy tiotropium bromide 9 mcg online cheap minocin online order terazosin 5mg generic
order albuterol 100mcg online cheap buy cipro 1000mg generic purchase ciprofloxacin
actos 30mg without prescription sildenafil 50mg sale sildenafil 25mg for sale
singulair tablet viagra 50mg generic sildenafil generic
buy generic cialis Cialis overnight sugarhouse casino online
order generic cialis 10mg prices of cialis tadalafil 20mg pill
real money slots free spins no deposit ocean casino online live online blackjack
online blackjack free best online poker sites spins real money
real money games money can t buy everything essay cheap essay online
purchase doxycycline for sale purchase doxycycline online cleocin 300mg without prescription
buy benicar 10mg without prescription buy calan sale buy divalproex generic
clobetasol for sale brand buspirone buy amiodarone online
lanoxin 250 mg uk order digoxin 250 mg pills buy generic molnunat 200mg
order pamelor 25mg generic oral nortriptyline 25mg paroxetine for sale
purchase doxycycline generic cost doxycycline 100mg methylprednisolone oral
tadacip 20mg cost plavix 150mg pill order trimox 250mg pills
order generic nexium biaxin tablet order lasix 40mg online
Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Onwin , Onwin Giriş , Onwin Güncel Giriş , Onwin Yeni Adres , onwin
metformin cheap calan 120mg cheap nolvadex 10mg cheap
provigil 200mg cost buy modafinil 200mg pill promethazine 25mg tablet
order accutane 40mg pills buy accutane 20mg acillin canada
Thank you for great information. Hello Administ . Hacklink , Hacklink panel , Hacklink al Hacklink panel
order generic isotretinoin 40mg buy amoxicillin pill zithromax online buy
imuran online micardis without prescription order naprosyn
buy ditropan 2.5mg pill oxybutynin without prescription oxcarbazepine over the counter
zocor 20mg canada simvastatin pills sildenafil fast shipping
order coumadin online zyloprim over the counter brand allopurinol
cetirizine online order purchase cetirizine without prescription order sertraline 50mg generic
cenforce 50mg sale metformin for sale order glucophage 1000mg generic
order lipitor 10mg pills order generic sildenafil order viagra 100mg without prescription
purchase femara generic viagra 25 mg purchase viagra pills
buy cialis 5mg online cheap free shipping cialis best ed pills non prescription
purchase tadalafil pills buy generic tadalafil 40mg buy ed medications online
order absorica without prescription accutane 40mg oral zithromax online order
Thank you great post. Hello Administ .Click on the Keyword to Enter the Website. onwin
buy prednisolone 40mg for sale prednisolone 10mg uk buy lasix generic diuretic
clomid 50mg sale hydroxychloroquine 400mg tablet hydroxychloroquine 400mg drug
tenormin 100mg usa buy letrozole 2.5 mg pill letrozole 2.5 mg us
albenza 400 mg drug brand medroxyprogesterone order medroxyprogesterone 10mg pills
methotrexate 10mg usa buy generic medex online purchase metoclopramide generic
losartan order losartan price purchase topiramate sale
buy sumycin 500mg generic buy ozobax online cheap order baclofen 10mg generic
buy toradol paypal colchicine brand buy cheap generic inderal
cost clopidogrel 150mg clopidogrel price buy ketoconazole for sale
buy tamsulosin 0.4mg pill flomax pills spironolactone pills
After all, what a great site and informative posts, I will upload inbound link – bookmark this web site? Regards, Reader. Hacklink Panel Hacklink
buy betnovate 20 gm generic cheap betnovate 20gm itraconazole generic
order combivent 100mcg online cheap buy generic zyvox 600 mg brand zyvox 600 mg
progesterone 200mg generic buy generic zyprexa for sale zyprexa 10mg cost
nebivolol price buy bystolic sale clozaril 50mg ca
buy simvastatin 20mg pill sildenafil 50mg us sildenafil 100mg price
carbamazepine 400mg cost tegretol 200mg drug where to buy lincocin without a prescription
order cefadroxil 250mg sale proscar 1mg generic cost propecia 5mg
fluconazole for sale online fluconazole 200mg tablet cost cipro
vermox online order tretinoin cream online cheap buy tadalis pills for sale
buy avanafil 100mg sale buy avanafil 100mg without prescription buy voltaren 50mg
brand nolvadex 10mg order ceftin pills cheap ceftin 250mg
amoxicillin oral buy clarithromycin biaxin 250mg for sale
careprost generic buy generic desyrel buy trazodone 50mg online cheap
order catapres 0.1mg pills order antivert 25mg without prescription tiotropium bromide 9mcg pills
order sildenafil 50mg pills suhagra online buy sildenafil 100mg pills for sale
buy minocin 100mg pill buy minocycline pills buy actos 30mg generic
buy accutane 20mg online order azithromycin 500mg pill azithromycin online order
tadalafil 40mg usa cialis 10mg oral tadalafil 20mg uk
stromectol cvs ed pills comparison deltasone 20mg ca
lasix 100mg pills vibra-tabs ca ventolin 2mg oral
levitra 20mg for sale order hydroxychloroquine 200mg online cheap order generic plaquenil 200mg
vardenafil 20mg over the counter buy generic plaquenil 200mg purchase plaquenil generic
order benicar 10mg generic olmesartan without prescription order depakote generic
order clobetasol online cheap cordarone 100mg usa amiodarone where to buy
order coreg 25mg generic buy generic chloroquine 250mg order chloroquine 250mg generic
buy naprosyn 250mg generic cefdinir 300mg buy generic lansoprazole