Skip to content

Instantly share code, notes, and snippets.

@bih
Created March 2, 2012 23:24
Show Gist options
  • Save bih/1962279 to your computer and use it in GitHub Desktop.
Save bih/1962279 to your computer and use it in GitHub Desktop.
Scale up 960.gs files to whatever size you want!
<?php
/* This amazingly cool piece of code converts your 960.gs file into whatever you want */
/* Simply enter your new size in pixels that you wish to scale it up to and it will magically do it! */
function scale_960_gs($new_size = 960) {
$multiplier = abs($new_size / 960);
$i = explode(PHP_EOL, file_get_contents('http://960.gs/css/960.css'));
$a = 0;
foreach($i as $line=>$r) {
$m = array(
'width',
'min-width',
'padding-left',
'padding-right',
'left',
'right'
);
foreach($m as $m2) {
if(substr(trim($r), 0, strlen($m2)) == $m2) {
$res = preg_replace('/'.$m2.': (.*)px;/', '$1', $r);
$res = (int) $res;
$nv = ceil($res * $multiplier);
$total[] = str_replace($res, (integer) $nv, $r);
$a = 1;
}
}
if($a == 0) {
$total[] = $r;
}
$a = 0;
}
return implode(PHP_EOL, $total);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment