svk
svk

Reputation: 4553

Image Compression in PHP?

I want to compress the image with same quality using PHP.What is my situation is I want to display the user images when they loged in.Currently I am showing the original image whatever they uplaod in mysite.So if they uplaod 4MB file I am downloading the 4MB file and showing to them.Instead of that I want to compress the image with same quality.

I want to do it with same height and width also.Like smush it trying to do.But for 4mb files its not working with smush it.

Is there any way to do.How can I achieve it.

Upvotes: 0

Views: 1142

Answers (3)

Rijk
Rijk

Reputation: 11301

You can't compress an image maintaining the same quality and resolution. You can scale it down however (a 4MB JPEG file is pretty huge - if it's meant for screen use only, 1600 pixels or less image would do fine most of the times), using GD, Imagick, etc.

Upvotes: 1

Zento
Zento

Reputation: 335

You should resize the images when they have been uploaded to your FTP server.

Of course you will have to deal with a loss of quality and resolution.

Have a look at http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

Upvotes: 0

genesis
genesis

Reputation: 50982

Try to convert them to different formats. gif is the best for small images. There are a lot of converting classes so just look around google

Upvotes: 0

Related Questions