def screenshot(url, *args, **kwargs):
phantomscript = os.path.join(os.path.dirname(__file__),<EOL>'<STR_LIT>')<EOL>directory = kwargs.get('<STR_LIT>', '<STR_LIT>')<EOL>image_name = kwargs.get('<STR_LIT>', None) or _image_name_from_url(url)<EOL>ext = kwargs.get('<STR_LIT>', '<STR_LIT>').lower()<EOL>save_path = os.path.join(directory, image_name) + '<STR_LIT:.>' + ext<EOL>crop_to_visible = kwargs.get('<STR_LIT>', False)<EOL>cmd_args = [<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>phantomscript,<EOL>url,<EOL>'<STR_LIT>',<EOL>str(kwargs['<STR_LIT:width>']),<EOL>'<STR_LIT>',<EOL>str(kwargs['<STR_LIT>']),<EOL>'<STR_LIT>',<EOL>str(kwargs['<STR_LIT>']),<EOL>'<STR_LIT>',<EOL>directory,<EOL>'<STR_LIT>',<EOL>ext,<EOL>'<STR_LIT>',<EOL>str(image_name),<EOL>]<EOL>if crop_to_visible:<EOL><INDENT>cmd_args.append('<STR_LIT>')<EOL><DEDENT>output = subprocess.Popen(cmd_args,<EOL>stdout=subprocess.PIPE).communicate()[<NUM_LIT:0>]<EOL>return Screenshot(save_path, directory, image_name + '<STR_LIT:.>' + ext, ext)<EOL>
Call PhantomJS with the specified flags and options.