Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9042717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:34:02+00:00 2026-06-16T10:34:02+00:00

When running Page Speed in Google Chrome it suggests to optimize/compress the images. These

  • 0

When running Page Speed in Google Chrome it suggests to optimize/compress the images. These images are mostly uploaded by users, so I would need to optimize them during uploading. What I find about optimizing jpeg images with php is something like using the following GD functions:

getimagesize()
imagecreatefromjpeg()
imagejpeg()

Since I am resizing the images after upload I’m already pulling the image through these functions and in addition I use imagecopyresampled() after imagecreatefromjpeg() to resize it.

But then, Page Speed is still telling me these images can be optimized. How can I accomplish this optimisation in a php script? Set the quality lower in imagejpeg() doesn’t make a difference either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:34:04+00:00Added an answer on June 16, 2026 at 10:34 am

    The imagejpeg function is where you assign the quality. If you’re already setting that to an appropriate value then there is little else you can do.

    Page speed probably considers all images above a certain size to be “needing compression”, perhaps just ensure they are all as small as reasonable (in terms of height/width) and compressed.

    You can find more about page speed and it’s compression suggestions on the pagespeed docs http://code.google.com/speed/page-speed/docs/payload.html#CompressImages which describes some of the techniques/tools to compress appropriately.

    I’ve also just read the following:

    Several tools are available that perform further, lossless compression on JPEG and PNG files, with no effect on image quality. For JPEG, we recommend jpegtran or jpegoptim (available on Linux only; run with the –strip-all option). For PNG, we recommend OptiPNG or PNGOUT.

    So perhaps (if you really want to stick to Google’s suggestions) you could use PHP’s exec to run one of those tools on files as they are uploaded.


    To compress with php you do the following (sounds like you are already doing this):

    Where $source_url is the image, $destination_url is where to save and $quality is a number between 1 and 100 choosing how much jpeg compression to use.

    function compressImage($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;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I run the Google Chrome Page Speed on one of the web sites
Hey guys, After running Google Page Speed, my Compression Results were red. Google Page
I just ran Google's Page Speed application against our site and one of the
I'm attempting to satisfy the Cookieless domain suggestion of Google's Page Speed plugin and
I have a website and when I check page speed with Google plug-in, I
I'm running Google PageSpeed on my site and it's tell me that I need
In a web page running on an Android browser (on a Galaxy Nexus), is
We have an ASP.NET page running on .NET Framework 4.0. At the moment we
I am using Struts application while running welcome page is run successfully after that
I'm running a web page that has a SL 'box' in it. I know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.