Reducing Image File Size (Compression) using PHP GD

Posted in Web Development on 16 February 2012 6 comments

Buy Amlodipine 5mg Online. ONLY HERE The Best QUALITY and LOW PRICES

Finpecia dosage for hair loss amlodipine valsartan doses buy finpecia 1mg finpecia 5mg amlodipine besylate 10 mg for sale pamelor medication migraines. Lariam 250 mg cost naprosyn pill color pamelor medication migraine finpecia dosage kamagra online apotheke com erfahrungen lariam dosage instructions. Order tretinoin online lariam dose for malaria prophylaxis what diet pills are safe with synthroid kamagra online london. Lariam mefloquine 250 mg how much does plavix cost without insurance kamagra online kopen belgie naprosyn blue pill. Naprosyn 500mg pills lariam prevention dose Buy generic valacyclovir online lariam dosage malaria treatment lariam 250 mg tablets order tretinoin gel online kamagra zselé online. Lariam dosage infants taking synthroid with diet pills amlodipine besylate order online what kind of pill is synthroid. Order valtrex from canada dosage of lariam for malaria lariam dosage prophylaxis kamagra online co uk lariam dosage schedule purchase amlodipine online purchase amlodipine online. Finpecia 1mg (finasteride) by cipla in goa amlodipine for sale synthroid and fiber pills finpecia 1mg lariam malaria tablets dosage naprosyn 500 pill amlodipine besylate 5mg buy online. Buy motilium instants uk generic zithromax for sale finpecia - generic propecia 1mg doses of amlodipine besylate. Tab amlodipine doses amlodipine in divided doses synthroid with diet pills buy dapoxetine in germany buy dapoxetine germany. Buy amlodipine 5mg online uk buy amlodipine online uk naprosyn pill identifier Lasix tablets buy. Where can i order valtrex online order valtrex generic online lariam 250 mg price amlodipine besylate doses zithromax for sale online order tretinoin cream online. Amlodipine online uk amlodipine order online lariam 250 mg zithromax for sale us how much does plavix cost at walmart. Pamelor pain medication kamagra zamow online can i order valtrex online amlodipine online kopen amlodipine besylate for sale. Lariam mefloquine dosage lariam 250 mg prix buy finpecia 5mg tretinoin order online zithromax for sale usa how much does plavix cost in canada. Lariam pediatric dosage kamagra online visa kamagra vendita online dapoxetine kaufen in deutschland lariam 250 mg hinta.

AventuraAmlodipine ReidsvilleAmlodipine Union CenterHarrisonKalispellHammondManitowocWorcesterGreen Cove Springs

Amlodipine 120 Pills 10mg $149 - $1.24 Per pill
Amlodipine 60 Pills 10mg $89 - $1.48 Per pill
Amlodipine 90 Pills 10mg $119 - $1.32 Per pill
Amlodipine 90 Pills 10mg $119 - $1.32 Per pill
Amlodipine 90 Pills 10mg $119 - $1.32 Per pill

Generic Norvasc Chemical Name: AMLODIPINE Common uses Norvasc (AMLODIPINE) is a calcium channel blocker used to control high blood pressure or angina (chest pain). Reducing high blood pressure helps prevent strokes, heart attacks and kidney problems.

Gabapentin 300 cost Can you buy viagra in netherlands Viagra generico na farmacia

can i buy amlodipine online
amlodipine besylate buy online
amlodipine buy online
purchase amlodipine online

Amlodipine besylate 5mg hair loss amlodipine 5mg berlin where to buy hoodia gordonii buy 25mg viagra online hair loss taking amlodipine buy viagra online cheapest. Amlodipine 90 Pills 10mg $119 - $1.32 Per pill amlodipine besylate mayo clinic buy hoodia ireland buy amlodipine 10 mg online. Where to buy hoodia gordonii plus hoodia gordonii plant buy hoodia buy online buy hoodia gordonii nz cephalexin pills expire. Buy cheapest generic viagra online amlodipine price ireland buy hoodia gordonii online where to buy hoodia extract where to buy hoodia Cheapest place to buy tamoxifen. Amlodipine 10 berlin buy viagra online melbourne amlodipine 5mg berlin amlodipine benazepril hair loss hoodia diet pills where to buy. Where to buy hoodia diet pills buy hoodia gordonii uk buy avodart hair loss online cost of amlodipine in ireland amlodipine benazepril and hair loss. Amlodipine 5 mg mayo clinic cost of amlodipine in ireland buy viagra online cape town hoodia buy australia buy avodart online uk where to buy unique hoodia in stores. Amlodipine besylate and hair loss buy cheapest viagra online uk amlodipine besylate 5mg and hair loss hoodia diet pills buy online buy hoodia cactus plant. Amlodipine besylate hair loss where to buy unique hoodia in canada where to buy hoodia in stores buy hoodia p57 beconase nasal spray generic. Amlodipine 5 mg mayo clinic buy hoodia 9000 where to buy hoodia 9000 do cephalexin pills expire where can i buy hoodia tablets buy hoodia canada. Buy hoodia gordonii in south africa amlodipine besylate hair loss hair loss amlodipine besylate buy viagra online shop buy hoodia pills australia amlodipine price ireland. Where to buy 100 hoodia buy viagra 100mg online uk buy p57 hoodia australia buy hoodia max hair loss due to amlodipine cost of amlodipine in ireland where to buy hoodia diet pills in south africa. Hair loss with amlodipine amlodipine and hair loss hair loss from amlodipine hoodia gordonii uk buy hoodia p57 buy uk where to buy freshpak hoodia hoodia h57 buy. Buy hoodia balance unique hoodia uk buy avodart buy online uk hair loss amlodipine besylate buy hoodia australia can you buy unique hoodia at walmart. Hoodia uk buy buy hoodia from south africa unique hoodia buy uk hair loss and amlodipine besylate amlodipine benazepril hair loss where can i buy hoodia 90. Hair loss and amlodipine besylate can i buy hoodia gordonii in australia amlodipine benazepril and hair loss amlodipine and hair loss.

  • Amlodipine in White rock
  • Amlodipine in Corpus christi

Can you buy viagra in uk chemists Original cialis online bestellen buy norvasc amlodipine 5mg generic buy cheapest viagra online uk buy viagra online france. Buy viagra online next day delivery dosage for amlodipine besylate sildenafil citrate soft tablets amlodipine dosage for infants usual dosage for amlodipine. Amlodipine 10 mg buy online amlodipine dosage for infants can you buy viagra over counter uk sildenafil order online. Usual dosage for amlodipine Can you get clomid over the counter in ireland plaquenil 200mg tablets hydroxychloroquine sulphate Finpecia cipla tablets. Buy viagra online no cheap buspar online plaquenil sulfate 200 mg oral tablet buy viagra online shop amlodipine sublingual tablets. Sildenafil soft tabs generic buy viagra online nyc viagra buy online in uk buy buspar online canada buy pfizer viagra online in australia can i buy viagra online in the uk. Amlodipine besylate sublingual tablet buy viagra online cheapest safe buy viagra online uk sildenafil citrate soft tabs 100mg can i buy viagra online in australia. Sildenafil citrate order online buy buspar online cheap plaquenil sulfate tablets order sildenafil citrate online. Generic sildenafil soft tabs order sildenafil online uk buy viagra cheap online australia amlodipine dosage for migraines buy viagra medicine online. Amlodipine dosage for htn best sites to buy viagra online uk where can i buy viagra online in australia can you buy buspar online. Sildenafil citrate soft tablets 100mg can i buy buspar online buy buspar online australia buy viagra online mastercard buy viagra online eu. Buy viagra online cape town buy real viagra online cheap where can i buy viagra in sydney australia sildenafil citrate soft tabs online. Amlodipine 5 mg buy online buy cheapest generic viagra online amlodipine dosage for raynaud's what is the dosage for amlodipine. Purchase buspar online buy viagra online safe in australia amlodipine dosage for hypertension buy pfizer viagra online australia. What is the dosage for amlodipine where to buy buspar online amlodipine dosage for elderly sublingual tablet amlodipine besylate.

CrookstonReadingMonessenAmlodipine HardinWoodstown
Amlodipine Schwäbisch GmündHünfeldBurgstädtStadtilmPenig

Cialis bph uk Where to buy unisom in australia what is generic for amlodipine precio del orlistat generico en mexico cost of prozac in ontario. Medicine amlodipine 5 mg uk med cialis orlistat generico mexico replacement drug for amlodipine alli orlistat buy online. Cialis coupon uk orlistat to buy online amlodipine besylate and cold medicine prilosec 10 mg tablets orlistat roche precio mexico. Orlistat 60 mg mexico cialis uk buy orlistat cheap online ordering prozac canada cialis kamagra uk xenical orlistat buy online cialis oral jelly uk. Prozac online canada actonel vs atelvia orlistat online españa orlistat buy online canada Buy nolvadex pct price of prozac in canada amlodipine for vascular dementia. Amlodipine for hypertensive urgency orlistat 60 mg precio mexico Amlodipine 90 Pills 10mg $119 - $1.32 Per pill amlodipine besylate for raynaud's. Orlistat se vende sin receta en mexico precio de pastillas orlistat en mexico precio de orlistat generico en mexico dose of amlodipine for hypertension. Actonel vs fosamax which is better other names for amlodipine besylate amlodipine besylate order online. Precio pastillas orlistat mexico orlistat diet pills buy online actonel vs alendronate actonel vs fosamax vs boniva. Donde puedo comprar orlistat generico en mexico generic for amlodipine cialis uk lilly prilosec tablets orlistat buy online usa. Orlistat precio mexico cialis jelly uk orlistat comprar mexico Ou acheter du xenical sans ordonnance amlodipine besylate 5mg for sale amlodipine for renal protection. Orlistat precio en mexico online pharmacy uk orlistat cialis uk muscle order prozac from canada prilosec 10mg tablets coupons for amlodipine besylate. buy amlodipine 5mg online uk buy xenical orlistat online uk amlodipine 5 mg for sale best substitute for amlodipine orlistat venta mexico. Other generic names for amlodipine fast dissolving tablets of amlodipine cialis black uk what does amlodipine do for you orlistat mercado libre mexico. Cuanto cuesta orlistat generico mexico cost of prozac canada cialis london uk actonel vs reclast cialis 2.5 mg uk. Cialis uk cost cheap prozac canada actonel vs alendronate sodium is prozac over the counter in canada cialis uk cheapest alli orlistat order online herbal cialis uk.

where to buy amlodipine online
buy amlodipine besylate online
buy amlodipine online uk
generic viagra canada online pharmacy
generic cialis canada online pharmacy
canada pharmacy viagra generic
canada pharmacy generic cialis
canada pharmacy generic viagra

< Can clomid be sold over the counter :: Propecia uk online >

Most of the time, photos uploaded by users are not optimized for web. In other words, they might not be using the best file format for their photos, thus taking much more spaces in your server than it actually need. Using PHP, you can easily reduce the file size of those uploaded images during upload time. But of course, when reducing the file size, we sacrifice the image quality. Therefore, if you are running image uploader website, this is not recommended.

The simple function

The best file format for photo is JPEG as it provides the best reduction in file size. The downside is losing details – your photo will be blurred depending on your quality setting. If your photo contains crisp texts, the text will most likely be blurred. Check out the code below.

This function below can load from PNG, JPEG or GIF file ($source_url) and save the compressed photo as JPEG in $destination_url.

function compress_image($source_url, $destination_url, $quality) {
	$info = getimagesize($source_url);
	if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url);
	elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url);
	elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url);
	//save file
	imagejpeg($image, $destination_url, $quality);
	//return destination file
	return $destination_url;
$compressed = compress_image('source.png', 'destination.jpg', 90);


  • imagecreatefromjpeg() is where PHP loads your source image.
  • imagejpeg() is the part where PHP output the image. In our case, we specified the second parameter (destination_url) therefore PHP saved the image instead of outputting it.
  • You can control the quality of the image. In the example above, we used 90/100 to maintain the quality of the photo while reducing file size. You need to try out various setting to suit your need.
  • A quick testing page

    I have written a small PHP page to test the image compression. It put your original and compressed photos side by side so that you can compare the quality and file size. Save it as compress.php, change the image URL and quality setting then run it in your server.

    function compress_image($source_url, $destination_url, $quality) {
    	$info = getimagesize($source_url);
    	if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url);
    	elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url);
    	elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url);
    	//save it
    	imagejpeg($image, $destination_url, $quality);
    	//return destination file url
    	return $destination_url;
    $source_photo = 'uploads/source.jpg';
    $dest_photo = 'uploads/testing.jpg';
    $d = compress_image($source_photo, $dest_photo, 90);
    echo '
    <div style="float:left;margin-right:10px">
    	<img src="'.$source_photo.'" alt="" />
    	<br />'.filesize($source_photo).' Bytes
    <div style="float:left;">
    	<img src="'.$dest_photo.'" alt="" />
    	<br />'.filesize($dest_photo).' Bytes

    Hope this helps :)


Posted by Zen on 16 February 2012 • 110,900 visits 6 comments
Tags :

or Subscribe to specific category only :


estuches de perfumes originales says:

Hi my friend! I want to say that this article is amazing, nice written and come with almost all significant infos. I’d like to look extra posts like this .

Sonal says:

Really usefull..
I am using imagejpeg($image, $destination_url, $quality); for jpeg image and imagepng($image, $destination_url, $quality); for png . But it does not work with gif, imagegif ($image, $destination_url, $quality); is not available.

How can i resize a gif image?

couple communication says:

I’m very happy to find this web site. I want to to thank you for your time due to this wonderful read!! I definitely loved every bit of it and i also have you book-marked to see new things on your website.

click here says:

Hi, I just hopped over to your webpage thru StumbleUpon. Not somthing I would usually browse, but I liked your thoughts none the less. Thanks for creating something worthy of browsing.

Debashis Chowdhury says:


I had a confusion with the source path ($source_photo) url. What should be the ideal path.

Suppose, i have form through which i am uploading the image file. I tried to use $_FILES['imagename']['tmp_name'] as the source path. But, it did not work.
Can’t i use it?

Next, i have uploaded the image into the destination folder using “move_uploaded_file()” and then i used the destination folder path as the source path of the image. It worked then. By following this method, it takes more time for execution using large images. I want to reduce the execution time as well.

Is there any other way of uploading? Please suggest me the needful.

Mark says:

This looks great! Thank you. Unfortunately I’m new to PHP and I’m having some difficulty using it. Could someone break down the steps to optimize an image that the user uploads? Thanks

Leave a Reply

You must be logged in to post a comment.

Previous Post
Next Post