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 8734959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:56:55+00:00 2026-06-13T09:56:55+00:00

I am working on one of my project where user will upload the image.

  • 0

I am working on one of my project where user will upload the image. The uploaded image will be displayed using lightbox.

The problem is that user may upload an image of size say 5mb and so on. Because of this it takes large loading time. So I thought to reduce quality of image keeping the dimension same.

I know that we can use, imagejpeg() function, and pass third parameter which is quality say 90, that also reduces file size.

I need all image file size to be max 1mb, not more than that.

So, I am confused in what value should be pass as quality, so as to have optimum quality.

For eg. if uploaded image file size is 1.2mb, then say I will pass 90 as quality, that may bring down the size to less that 1mb, and also quality will be acceptable. Another case if uploaded file size is say 5mb, than if I pass 90 as quality, then file-size may not be less than 1mb. Here I need to pass less quality value (I guess).

So is there any method that helps me in determining optimum quality parameter that should be passed.

Many thanks for your time.

  • 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-13T09:56:56+00:00Added an answer on June 13, 2026 at 9:56 am

    I spent ages messing with this same sort of thing a while back. First of all PNG and JPG formates i found to be quite awkward in guessing the results. JPG photos generally wont convert well to PNG, but vector jpg images will, vector png generally dont convert well to JPG, but photos will. You will find it very hard to ensure that the images get just under 1mb especially if you are not resizing them as well. If you do not resize them you will also hit more troubles – the quality will become less and less the larger the image is (kind of ironic).

    You need a few versions of each image. Let me explain.

    1. You want to keep the original, so you can refresh the images based on the original at any time in the future to lets say, increase the quality of the images later on or even get some new dimentions.

    2. Using the original image with lightbox would generally be a bad idea. You would be better to resize it to fit inside say 1024 x 1024. That would more than satisfy most, and would usually give a reasonable file size. You could then offer the original to be downloaded if you wish. Using the largest file possible would usually result from unhappy visitors when the image takes ages to load and could even cost them a lot after some time through bandwidth usage (and you for the same reason).

    The only way i can think of to do what you are asking is to create some horrible code performance wise that loops through, gradually decreasing the quality and checking the resulting image size. Once it finds the image size that is below 1mb it comes out the loop and uses that quality setting. I would really advise against this though.

    P.S. Outside the scope of this answer i have mentioned in the comments the methodology of a solution i used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m working on project user to move the image in one position to
I am working on a windows forms project that will allow a user to
I'm working on a project for college that will let a user place a
While working a project tonight, I ended up using one .js resource file for
I'm currently working on a project with a one page design that'll slide up
I'm working on problem 9 in Project Euler: There exists exactly one Pythagorean triplet
I'm working on a fairly large project in Python that requires one of the
I'm working on a Qt/C++ open source project that uses MySQL databases. One class
I'm working on a project creating a fairly simple one-to-many host-to-slave network using a
I'm currently working on a project where a user will select a bunch of

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.