xiebruce/php-get-image-from-clipboard 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xiebruce/php-get-image-from-clipboard

最新稳定版本:v0.1

Composer 安装命令:

composer require xiebruce/php-get-image-from-clipboard

包简介

Get image that copied to the clipboard(usually from screenshot) and dump it into jpg/png image file. Support macOS/Windows/Linux(Only test on Ubuntu 18.04.2 LTS).

README 文档

README

PHP-GetImgFromClipboard is a tool that allows you to get image on the clipboard(usually copy to the clipboard by taking a screenshot or copy from web page) and save it to an image file like jpg or png.

Install

composer require xiebruce/php-get-image-from-clipboard

Requires

Actually, php can not get image on the clipboard directly, so this tool is rely on other tools.

For macOS

For macOS, it relies on pngpaste, so you should install pngpaste first:

brew install pngpaste

For Windows 10

For Windows 10, it's free to use, nothing need to be install.

For Windows 7

For Windows 7, you need to update Powershell. Download Powershell update package "Win7AndW2K8R2-KB3191566-x64.zip" from here: https://www.microsoft.com/en-us/download/details.aspx?id=54616, then update and restart.

Before update, you can check the Powershell version. Click "Start" menu on the bottom right corner, input "powershell" to search, then powershell shows up like this: Xnip2019-09-05_14-43-33

Click to open it and type this command:

$PSVersionTable

Now you can see, before update, the Powershell version is 2.0: Check Powershell version before update

After update, the Powershell version is 5.0: Check Powershell version after update

For Linux Desktop

For Linux Desktop System(e.g. Ubuntu, Manjaro, CentOS etc.) , you need to install xclip.

On Ubuntu:

apt install xclip

I didn't test other Linux distributions, but it should be work as long as you install xclip.

Usage

<?php
	require 'vendor/autoload.php';
	
	use GetImgFromClipboard\GetImgFromClipboard;
	
	$obj = new GetImgFromClipboard();
	switch (PHP_OS){
		case 'Darwin':
			// For macOS, save screenshot to Desktop
			# /Users/youusername/Desktop/ScreenShot.jpg
			# /Users/youusername/Desktop/ScreenShot.jpg
			$savedImgPath = '/Users/bruce/Desktop/ScreenShot.jpg';
			break;
		case 'WINNT':
			// For Windows, save screenshot to Desktop
			# C:\Users\youusername\Desktop\ScreenShot.jpg
			# C:\Users\youusername\Desktop\ScreenShot.png
			$savedImgPath = 'C:\Users\youusername\Desktop\ScreenShot.png';
		case 'Linux':
			// For Linux, save screenshot to Desktop
			# /home/yourusername/Desktop/ScreenShot.jpg
			# /home/yourusername/Desktop/ScreenShot.png
			$savedImgPath = '/home/yourusername/Desktop/ScreenShot.jpg';
	}
	$savedImgPath = $obj->save($savedImgPath);
	echo $savedImgPath . "\n";

Acknowledgement

Thanks to octan3's img-clipboard-dump, I use it to get image from clipboard on Windows in my Project.

统计信息

  • 总下载量: 45
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固