📜 ⬆️ ⬇️

Gyazo on your own server

Hi, Habr!
image
My friends and I have been using Gyazo for a long time.

In short: a small program that, when launched, can immediately select an area on the screen, and as soon as you release the mouse, the area is uploaded to the gyazo server, and the link to it is immediately copied to the clipboard.
You can try it here: http://gyazo.com

Recently, its creator decided to monetize its development, and in addition to paid features, turned on intrusive advertising for non-premium users.
')
At first, it was not a direct link to the image that was copied to the buffer, but a link to a page with an advertisement. Then the direct file became unavailable.

Since gyazo is an open source project, I decided to make a version for myself and without advertising.
More under the cut.

1. Set up a server for images.


We need any web server with PHP support. The original server script is CGI, I decided to use PHP.

The script itself is here:

<?php $uri = "http://vps.yurganov.ru/gyazo/"; if(isset($_FILES['imagedata']['name'])) { $path = 'i/' . substr(md5(time()), -28) . '.png'; if(move_uploaded_file($_FILES['imagedata']['tmp_name'], $path)) { echo $uri , $path; } else{ echo $uri; } } else { echo $uri; } ?> 


As you can see, nothing supernatural.

When you try to send a file with a program, the script renames it to the character set (uniqueness is md5 + time ()), and also returns a link to the screenshot.

I decided to put the images not in the same folder, but in the folder i /, which I assigned the rights to 777.

2. Client preparation.


2.1 Windows application


The Windows application is written in C ++, an indication of which image server to use is written directly in the program code. In order not to recompile each time, I decided to base on the version of gyazowin from paulirish , in which the settings are taken from the ini-file.

 ; Set up gyazo on your own server using ; ruby: http://github.com/gyazo/Gyazo/tree/master/Server/ ; php : http://benalman.com/news/2009/10/gyazo-on-your-own-server/ [Configuration] SERVER = gyazo.com PATH = /upload.cgi 

Since his code didn’t work right away, I slightly corrected it.

You can download the already compiled version with the ini-file here.

To work with your server, you need to specify in the config:

 [Configuration] SERVER = [ ] -   ip-     PATH = /upload.php -      

You can also take the original application , and correct it for yourself. (in the gyazowin.cpp file, find the lines SERVER and PATH and replace as indicated above)

2.2 Mac OS application


Everything is simpler with the Mac version - an external file is already used there, where the path to the server is stored.

You need to install Gyazo for Mac from the official site , then edit the script file, which is located in /Applications/Gyazo.app/Contents/Resources/ as follows:
 HOST = 'your domain' CGI = '/upload.php' -     

After that, continue to work as usual.

2.3 Linux - application


Installation instructions for Gyazo for Linux.

The path to the server, respectively, must also be changed in the ruby ​​script.

And what, did you win anything?


image Instant speed
image No ads
image All created screenshots at you "at your side"
image We need to think about the free space on the server (for the year I used about 200MB, which in general is not much for single use)
image Your friends are unlikely to want to use your solution because they are afraid that you will have access to their images.

Example


You can estimate the speed of work on my server (I hope it will not be bent under the habra effect):
http://vps.yurganov.ru/gyazo/
Attention: all created screenshots are deleted by cron every 5 minutes.

PS File Gallery


A gallery that shows all your uploaded files in chronological order is here .

Download: http://vps.yurganov.ru/gyazo/distr/gallery.zip .

(Installation instructions inside the archive)

Source: https://habr.com/ru/post/132937/


All Articles