Lossless JPEG Optimizer
Another straight to the point solution

<?php
$url = 'http://your_server.com/image.jpg';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/jpeg_optim.php?url=' . $url . '&encoding=baseline'));
//or:
//$data = json_decode(file_get_contents('http://api.rest7.com/v1/jpeg_optim.php?url=' . $url . '&encoding=progressive'));
if (@$data->success !== 1)
{
die('Failed');
}
$image = file_get_contents($data->file);
file_put_contents('clean.jpg', $image);
Comments