Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- ####################### imgup ########################
- # #
- # imgup is an open source piece of software, #
- # developed by Gecko for rstforums.com #
- # #
- # For quick usage instructions, type the name of the #
- # script without passing any arguments: #
- # e.g.: ./imgup.py #
- # #
- ######################################################
- import os
- import sys
- import json
- argv = sys.argv
- ## Upload the image to imgur.com
- def upload_imgur():
- output = os.popen('curl -s -F Filedata=@' + argv[2] + ' http://imgur.com/upload').read()
- data = json.loads(output)['data']
- url = 'http://i.imgur.com/' + data['hash'] + '.png'
- return url
- ## Upload the image to postimage.org
- def upload_postimage():
- output = os.popen('curl -s -F upload=@' + argv[2] + ' http://postimage.org/').read()
- url = output[output.find('url=')+4:-2]
- url = url.replace('http://postimg.org/image/', '')
- url = 'http://postimg.org/image/' + url[0:url.find('/')+1]
- return url
- ## Upload the image to iceimg.com
- def upload_iceimg():
- output = os.popen('curl -s -F img=@' + argv[2] + ' http://iceimg.com/upload.php').read()
- data = json.loads(output)
- url = 'http://www.iceimg.com/' + data['full'].replace('\\', '')
- return url
- ## Show the usage information
- def show_usage():
- print '[!] Usage: imgup target local_file [clip]'
- print ''
- print '[*] imgup the name of the script'
- print ''
- print '[*] target',
- print ' all for all the sites below'
- print ' imgur or ur for imgur.com'
- print ' postimage or pi for postimage.org'
- print ' iceimg or ice for iceimg.com'
- print ''
- print '[*] local_file the path to the local image file'
- print ''
- print '[+] clip copy the image URL to the clipboard'
- print ' doesn\'t work if you choose to upload'
- print ' the image on all the sites'
- print ''
- print 'e.g. imgup ur Screenshot.png clip'
- exit()
- ## If there aren't enough parameters passed,
- ## Show the usage information
- if len(argv) < 3:
- show_usage()
- ## Show the image URL if the user chose imgur
- if argv[1] == 'imgur' or argv[1] == 'ur':
- url = upload_imgur()
- ## Show the image URL if the user chose postimage
- elif argv[1] == 'postimage' or argv[1] == 'pi':
- url = upload_postimage()
- ## Show the image URL if the user chose iceimg
- elif argv[1] == 'ice' or argv[1] == 'iceimg':
- url = upload_iceimg()
- ## Show all the image URLs if the user chose the all option
- elif argv[1] == 'all':
- url = upload_imgur() + ',' + upload_postimage() + ',' + upload_iceimg()
- ## If the option is not recognised, show the usage information
- else:
- show_usage()
- ## Show the URL(s) and copy it to the clipboard if requested
- if argv[1] == 'all':
- print 'Image URLs:'
- urls = url.split(',')
- for u in urls:
- print u
- else:
- print 'Image URL: ' + url,
- if len(argv) == 4:
- os.system('echo ' + url.strip() + ' | pbcopy')
- print '(copied to clipboard)'
Advertisement
Add Comment
Please, Sign In to add comment