Created
May 4, 2011 13:26
-
-
Save s-aska/955202 to your computer and use it in GitHub Desktop.
スクリーンショットを取るコマンド
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/env perl | |
# get screenshot | |
# screenshot.pl URL filename | |
# | |
# ubuntu | |
# sudo apt-get install xvfb chromium-browser imagemagick | |
# | |
# Japanese Font | |
# sudo apt-get install ttf-takao | |
use strict; | |
use warnings; | |
setpgrp(0, 0); | |
my ($url, $file) = @ARGV; | |
my $display_num = $$; | |
my $display = ':' . $display_num; | |
warn $display; | |
$ENV{'DISPLAY'} = $display; | |
warn "xvfb"; | |
unless (fork()) { | |
system('Xvfb', $display, '-screen', 0, '1024x1024x24'); | |
exit(0); | |
} | |
sleep(1); | |
warn "chromium"; | |
unless (fork()) { | |
system('chromium-browser', '--display', $display, '--kiosk', '--start-maximized', '--disable-restore-background-contents', '--disable-translate', '--app='.$url, '--user-data-dir=~/.config/google-chrome/'.$display_num); | |
exit(0); | |
} | |
sleep(2); | |
warn "import"; | |
system('import', '-display', $display, '-window', 'root', $file); | |
warn "convert"; | |
system('convert', '-crop', '1004x1004+0+0', $file, $file); | |
warn "kill process."; | |
kill -15, $$; | |
exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment