UPDATED

Optimize Image for Google Page Insight a single Command|PHP

How to Optimize Image for Google Page Insight a single Command in PHP and get an optimized site and high ratings


1 contribution

120 Views 0
 
 Tags    #images(2)   #tech(9)  

Requirements

install imagemagick

sudo apt-get install imagemagick //should also have convert


root@ubuntu-512mb-blr1-01:/var/www/matome# dpkg -l|grep imagemagick
ii  imagemagick                       8:6.8.9.9-7ubuntu5.9                amd64        image manipulation programs -- binaries
ii  imagemagick-6.q16                 8:6.8.9.9-7ubuntu5.9                amd64        image manipulation programs -- quantum depth Q16
ii  imagemagick-common                8:6.8.9.9-7ubuntu5.1                all          image manipulation programs -- infrastructure



root@ubuntu-512mb-blr1-01:/var/www/matome# type convert
convert is hashed (/usr/bin/convert)

PHP Code

public static function optimize($from, $to)
{
    $command = 'convert '
        . $from
        . ' -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace RGB '
        . $to;
    return `$command`;
}

Reference

Via Shell

for i in `file --mime-type *|grep -vi gif|cut -d':' -f1` ;do convert $i -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace RGB $i;done


Please login before Adding Contribution

LOGIN


Input Item is required

{{value.error}} Invalid Url Found


{{value.title}}

{{value.description}}

Source:{{value.url}}
{{value.error}} {{value.serror}} Input Item is Required





Source:{{value.cite}}





{{value.error}} Input Item is Required



Instagram Logo
{{value.error}} Input Item is Required



{{value.error}} {{value.serror}} Input Item is Required





{{value.snippet.title}}

{{value.snippet.description|truncate:'20':'...'}} {{value.snippet.channelTitle}}
Views {{value.statistics.viewCount|number}}


Preview will appear here..
No Gifs Found