<?php $url = 'http://server.com/animation.gif'; $level = 15; //Higher = smaller size but worse quality $data = json_decode(file_get_contents('http://api.rest7.com/v1/gif_lossy.php?url=' . $url . '&level=' . $level)); if (@$data->success !== 1) { die('Failed'); } $anim = file_get_contents($data->file); file_put_contents('optimized.gif', $anim);