Lightweight Library to Copy PNG and JPG Images to Clipboard

Copy Image Clipboard library allows you to easily copy JPG and PNG (only) images to the clipboard. It can be used with React, Vue, Angular, and other web frameworks. The new browser uses the Clipboard API and has no external dependencies.

how to copy image to clipboard in jquery, copy image to clipboard android, html2canvas copy to clipboard, javascript paste image from clipboard

Most Popular File Extensions and File Types Icons | CSS-file-icons

How to make use of it:

1. Install and download the copy-image-clipboard package.

# Yarn
$ yarn add copy-image-clipboard

# NPM
$ npm i copy-image-clipboard --save

2. Import the copyImageToClipboard component.

// ES Module
import { copyImageToClipboard } from 'copy-image-clipboard'

// Browser
<script src="index.browser.js"></script>

3. Call the copyImageToClipboard method and specify the path of the image to be copied.

// ES Module
copyImageToClipboard('image.png')
.then(() => {
  console.log('Image Copied')
})
.catch((e) => {
  console.log('Error: ', e.message)
})
// Browser
CopyImageClipboard.copyImageToClipboard('image.png')
.then(() => {
  console.log('Image Copied')
})
.catch((e) => {
  console.log('Error: ', e.message)
})

4. Get the big binary data from the image element.

import {
  getBlobFromImageElement,
  copyBlobToClipboard,
} from 'copy-image-clipboard'
const imageElement = document.getElementById('image')
getBlobFromImageElement(imageElement)
.then((blob) => {
  return copyBlobToClipboard(blob)
})
.then(() => {
  console.log('Blob Copied')
})
.catch((e) => {
  console.log('Error: ', e.message)
})

5. Check if an image can be copied to the clipboard.

import { canCopyImagesToClipboard } from 'copy-image-clipboard'
const canCopy = canCopyImagesToClipboard()
console.log('Can Copy Images To Clipboard:', canCopy)

6. Check if the browser has permission Clipboard.write().

import { requestClipboardWritePermission } from 'copy-image-clipboard'
requestClipboardWritePermission().then((hasPermission) => {
  console.log('Has Permission:', hasPermission)
})

Copy Image To Clipboard Using JavaScript, Copy Image Clipboard Plugin/Github, copy base64 image to clipboard javascript


See Demo And Download

Official Website(LuanEdCosta): Click Here

This superior jQuery/javascript plugin is developed by LuanEdCosta. For extra Advanced usage, please go to the official website.

Related Posts

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Data-Table-Generator-Tabulator

Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…

alert-confirm-prompt-attention-js

Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…

Bootstrap-4-Sidebar-Menu-Responsive-Template

Bootstrap 4 Sidebar Menu Responsive Template | MDB

Bootstrap Side Navbar – Responsive sidebar template based on the Bootstrap 4 framework. An easy-to-use, totally responsive, Google Material Design impressed aspect navigation for modern web app…

Bootstrap-4-Toast-Notification-Plugin

Lightweight Bootstrap 4 Toast Notification Plugin | BS4 Advanced Toast

A lightweight Bootstrap 4 Toast Notification plugin integrated with JS/jQuery. bs4-toast.js is a JavaScript library that enhances the native Bootstrap toast component with icons, buttons, callbacks, and…

Audio-Visualizations-Wave

How to Create Audio Visualizations with JavaScript | Wave.js

Audio Visualizer Library – wave.js is a vanilla javascript audio visualization library that provides 20+ creative audio visualization effects to bring more engagement to your visitor. Contribute…

Leave a Reply

Your email address will not be published. Required fields are marked *