Solved

image compress with php code without image quality disturb

Posted on 2013-11-28
4
2,047 Views
Last Modified: 2013-12-17
Hello Expert,

We write program in php for upload photo and photo size may be small, big. In case of big image, server take more space so i want to upload photo with compress and compress image is very small size rather than original image or without disturb image quailty .

I would like to know that do you have any idea for compress image when upload photo via script in PHP.

Please help me.

Thanks
0
Comment
Question by:singhpreeti
  • 2
4 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39684735
Compressing and/or reducing images always loses quality because compression is done thru a mathematical operation that discards information to reduce the file size.
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39685553
very small size rather than original image or without disturb image quailty
Can't be done.  And any image that is made smaller suffers a loss of image information.  You can't enlarge them again with the same original fidelity.

You have three methods of storing images.  GIF compression is useful if the images are graphics (not photos) and the color precision is unimportant.  PNG compression and JPEG compression are useful if the images are photographs.  PNG compression is lossless, meaning that all of the original image information is retained, and as a result, it allows very little compression.  JPG compression is lossy, in that it discards image information but in a way that causes the compressed image to be a visually satisfactory representation of the original image.

These three articles may be useful to you.  Please read them over and post back with any questions.  They cover the essentials and they have code examples.
http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/A_5931-Putting-Your-Photos-Online.html
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_6554-Use-PHP-to-Make-an-Image-Thumbnail.html
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_10065-Adding-a-Watermark-to-an-Image.html

One final note... Consider the value of your images compared to the cost of computer storage.  Computer storage is very, very cheap today.  But replacing a lost or degraded image may be very expensive.  Imagine the cost of restaging a wedding!  You might want to consider keeping all versions of the image files.
0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 39691421
What you should do is upload the original image but also create a smaller image to display on your webpage so it loads faster. You can do this with php and you make a link on your smaller thumbnail image to the original large image. There are lots of examples of how to do this if you search google.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39723649
@singhpreet: I see you are new to Experts-Exchange.  When you give a marked down grade, you're expected to provide an explanation of the deficiency in the answer.
A should be the default grade awarded unless the answer is deficient.
When closing the question, the asker should explain why a B grade was awarded.
If you read the three articles linked here, you would have found exactly what you're looking for, so I would like to hear your explanation of the bad grade.
http://support.experts-exchange.com/customer/portal/articles/481419
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now