Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
スクリーンショットを取るコマンド
#!/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
You can’t perform that action at this time.