Created
June 6, 2013 04:23
-
-
Save josefnpat/5719300 to your computer and use it in GitHub Desktop.
Book Convert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$start = $argv[1]; | |
$stop = $argv[2]; | |
for($i=$start; $i<=$stop; $i++){ | |
$exe = "convert $i.png -rotate 270 $i.png"; | |
echo "$exe\n"; | |
`$exe`; | |
// Left page | |
$exe = "convert $i.png -crop 1577x2294+87+127 $i\_a.png"; | |
echo "$exe\n"; | |
`$exe`; | |
$exe = "convert $i\_a.png -resize 825x1200 $i\_a.png"; | |
echo "$exe\n"; | |
`$exe`; | |
// Right page | |
$exe = "convert $i.png -crop 1577x2294+1841+127 $i\_b.png"; | |
echo "$exe\n"; | |
`$exe`; | |
$exe = "convert $i\_b.png -resize 825x1200 $i\_b.png"; | |
echo "$exe\n"; | |
`$exe`; | |
// Clean up | |
$exe = "rm $i.png"; | |
echo "$exe\n"; | |
`$exe`; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$count = count(glob("*.png")); | |
$threads = $argv[1]; | |
$script = "#!/bin/sh\n"; | |
for($i = 1; $i<=$threads; $i++){ | |
$start = round($count/$threads*($i-1))+1; | |
$stop = round($count/$threads*($i)); | |
$script .= "./conv.php $start $stop &\n"; | |
} | |
echo $script; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment