hackartist
hackartist

Reputation: 5264

Optimizing images for web

I have a lot of jpeg images which I want to optimize for web but I need a process which can also be done for incoming images in real time. In other words I don't want to use a service like Smush.it or drop them into photoshop for manipulation but I do want to know what I can do in php. I would prefer a solution which only requires php image processing functions but if necessary and it would provide significant improvement then a command line tool like jpegcrush could be used as well.

I have read that simply by making the image in php the EXIF data is stripped. What other things can I do without degrading the actual quality? When I save in photoshop using the 'save for web' feature, the savings are significant without a noticeable quality loss so I was wondering if anyone knew exactly what operations are done in there. One other thing I have noticed is that images from youtube are normally much larger area-wise than they need to be but they have very small file sizes... does anyone know what is going on there or is this some secret technique?

If it makes any difference the images I am working with are mostly 320x320 and I want to make them progressive jpg. Thanks in advance.

Upvotes: 3

Views: 3293

Answers (2)

Ben D
Ben D

Reputation: 14479

I'd use the PHP GD library to create a jpg with quality set to around 80:

imagejpeg ( resource $image [, string $filename [, int $quality ]] )

If you want to output Progressive JPEGs, you need to set interlacing on with imageinterlace().

Are you looking for something more than this?

Upvotes: 3

AlfredoVR
AlfredoVR

Reputation: 4287

Assuming "optimizing for the web" is converting to GIF, PEAR does it if i'm not mistaken. You don't need fancy functions to do this. check this question: Convert jpg image to gif, png & bmp format using PHP

Upvotes: -1

Related Questions