定制 xiebruce/php-get-image-from-clipboard 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

xiebruce/php-get-image-from-clipboard

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.

xiebruce/php-get-image-from-clipboard 适用场景与选型建议

xiebruce/php-get-image-from-clipboard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 8, 最近一次更新时间为 2019 年 09 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 xiebruce/php-get-image-from-clipboard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xiebruce/php-get-image-from-clipboard 我们能提供哪些服务?
定制开发 / 二次开发

基于 xiebruce/php-get-image-from-clipboard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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