All Projects → lijinke666 → photo-magician

lijinke666 / photo-magician

Licence: MIT license
🎨 provide some common image process apis with canvas

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to photo-magician

spark-ar-creators
List of 9500 (and counting) Spark AR Creators. Open an issue or contact me if you want to be added.❤️
Stars: ✭ 122 (+916.67%)
Mutual labels:  photos, filter
Fmphotopicker
A modern, simple and zero-dependency photo picker with an elegant and customizable image editor
Stars: ✭ 428 (+3466.67%)
Mutual labels:  photos, filter
Phimpme Ios
Phimp.me - Photo Image Editor and Sharing App. Phimp.me is a Photo App for iOS that aims to replace proprietary photo applications. It offers features such as taking photos, adding filters, editing images and uploading them to social networks.
Stars: ✭ 79 (+558.33%)
Mutual labels:  photos, filter
Android-FilterView
Build a simple filter view with customizable controls.
Stars: ✭ 20 (+66.67%)
Mutual labels:  filter
filter-bar
适用于移动端列表页面的筛选条插件。
Stars: ✭ 14 (+16.67%)
Mutual labels:  filter
romans
A Simple PHP Roman Numerals Library
Stars: ✭ 40 (+233.33%)
Mutual labels:  filter
cover4mp3
[Deprecated] Fetching album covers for your songs.
Stars: ✭ 12 (+0%)
Mutual labels:  cover
Facebook-Album-Browser
jQuery plugin for browsing public albums of a Facebook account
Stars: ✭ 76 (+533.33%)
Mutual labels:  photos
go-mosaic
相片马赛克 (Photographic mosaic)
Stars: ✭ 23 (+91.67%)
Mutual labels:  photos
MoTIS
Mobile(iOS) Text-to-Image search powered by multimodal semantic representation models(e.g., OpenAI's CLIP). Accepted at NAACL 2022.
Stars: ✭ 60 (+400%)
Mutual labels:  clip
SSffmpegVideoOperation
This is a library of FFmpeg for android... 📸 🎞 🚑
Stars: ✭ 261 (+2075%)
Mutual labels:  photos
GWLPhotoSelector
相册照片多张选择控件
Stars: ✭ 50 (+316.67%)
Mutual labels:  photos
php-simple-request
php-simple-request is a request parser library designed to simplify requests validation and filtering using annotations, generating at the same time an object representation from the request data.
Stars: ✭ 15 (+25%)
Mutual labels:  filter
doxygen-php-filters
Filters to get Doxygen work better with PHP code
Stars: ✭ 18 (+50%)
Mutual labels:  filter
google-photos-vue
Google Photos album viewer built with Vue.js
Stars: ✭ 17 (+41.67%)
Mutual labels:  photos
tinypng-free
Use the upload api of tinypng's homeage to compress images
Stars: ✭ 29 (+141.67%)
Mutual labels:  compress
loadkit
Java 资源加载器,充分拓展ClassLoader#getResources(name)的能力,实现递归加载,支持普通风格 / 包名风格 / ANT风格 / 正则风格路径的资源加载同时支持自定义过滤器,通常作为框架的基础类库。
Stars: ✭ 39 (+225%)
Mutual labels:  filter
equalizer
SoundCloud music player with equalizer
Stars: ✭ 25 (+108.33%)
Mutual labels:  filter
morphmorph
😱 Isomorphic transformations. Map, transform, filter, and morph your objects
Stars: ✭ 26 (+116.67%)
Mutual labels:  filter
CodeProject
Common code for unity project develop.
Stars: ✭ 28 (+133.33%)
Mutual labels:  compress

photo-magician

npm npm version jest

🎨 Provide some common image process apis with canvas

React Version

Installation

using yarn :

yarn add photo-magician

using npm :

npm install photo-magician --save

using in the browser :

<script src="photoMagician.min.js"></script>
<script>
    const magician = new photoMagician()
    magician.toBase64Url({cover:"YOUR_IMG_URL"})
</script>

Screenshots

https://github.com/lijinke666/photo-magician/bolb/master/assets/screenshot.png

Example

https://lijinke666.github.io/photo-magician/

Usage

ES6

import photoMagician from "photo-magician";
const magician = new photoMagician();

magician.toBase64Url({ cover: "YOUR_IMG_URL" });

No ES6

const photoMagician = require("photo-magician");
const magician = new photoMagician();

magician.toBase64Url({ cover: "YOUR_IMG_URL" });

set config

// set out put image data quality  [ 0 - 1 ]

magician.setConfig({
  imageQuality: 0.4
});

Return to the promise

//use ES6
magician
  .toBase64Url({
    cover: baseImageUrl
  })
  .then(data => {
    console.log("image data:", data);
  })
  .catch(error => {
    console.error("toBase64Url error", err);
  });

//use ES7
async () => {
  const data = await magician.toBase64Url({
    cover: baseImageUrl
  });
  console.log("image data:", data);
};

outputType

async () => {
  // outputType = 'dataUrl'  default
  const data = await magician.toBase64Url({
    cover: baseImageUrl,
    outputType: "dataUrl"
  });
  console.log("image data:", data);

  // outputType = 'blob'
  const blob = await magician.toBase64Url({
    cover: baseImageUrl,
    outputType: "blob"
  });
  console.log("image blob:", URL.createObjectURL(blob));
};

Development

git clone https://github.com/lijinke666/photo-magician.git
npm install | yarn
npm start

API

/**
 * @name toBase64Url
 * @description get base64 data of the image
 * @param {Object} options
 * @param {String | Object} options.cover cover url | image element node   The next cover parameter is the same as this.
 * @return base64 data
 */
magician.toBase64Url({
  cover: baseImageUrl
});

/**
 * @name getPrimaryColor
 * @description get primary color of the image
 * @param {Object} options
 * @param {String | Object} options.cover
 * @return primaryColor
 */

magician.getPrimaryColor({
  cover: watermark
});

/**
 * @name compressImage()
 * @description compress of the image
 * @param {Object} options
 * @param {String | Object} options.cover
 * @param {Number}  options.quality range(0-1) default '0.92'
 * @return base64 data
 */
magician.compressImage({
  cover: baseImageUrl,
  quality: 0.12
});

/**
 * @name clipImage()
 * @description cut clip of the image
 * @param {object} Options
 * @param {String | Object} options.cover
 * @param {Number} options.scale Image zooming   default '1.0'
 * @param {Array} options.coordinate [[x1,y1],[x2,y2]]
 * @return base64 data
 */
magician.clipImage({
  cover: baseImageUrl,
  scale: 1.0,
  coordinate: [[200, 200], [[300, 300]]
});

/**
 * @name rotateImage()
 * @description Rotate the image
 * @param {String | Object} cover 图片地址或节点
 * @param {Number} rotate 旋转比例 (0 -360 ) °
 */
magician.rotateImage({
  cover: baseImageUrl,
  rotate: 20
});

/**
 * @name addWaterMark
 * @description Add text or picture watermark to the image.
 * @param {Object} options
 * @param {String | Object} options.cover
 * @param {String} options.waterMark waterMark
 * @param {String} options.mode "image | text"  Specify whether it is a image or a text. [default 'text']
 * @param {Boolean} options.fontBold If it's text, then bold [default 'true']
 * @param {Number} options.fontSize If it's text, what font size is it?  [default 20]
 * @param {String} options.fontColor if it's text, If it's text, what font color is it? [default'rgba(255,255,255,.5)']
 * @param {Number} options.width if it's image what width of the image [default '50']
 * @param {NUmber} options.height if it's image what height of the image [default '50']
 * @param {NUmber} options.opacity opacity of the image  [default '0.5']
 * @param {Array} options.coordinate [x,y] [default '[0,0]']
 */
magician.addWaterMark({
  cover: baseImageUrl,
  mode: "image",
  waterMark: watermark,
  width: 60,
  height: 60,
  opacity: 0.8,
  coordinate: [330, 300]
});

/**
 * @name addWaterMark
 * @param Same as above
 */
magician.addWaterMark({
  cover: baseImageUrl,
  mode: "text",
  waterMark: "photo-magician.js",
  fontBold: false,
  fontSize: 20,
  fontColor: "#396",
  coordinate: [10, 20]
});

/**
 * @name addImageFilter
 * @param {Object} options
 * @param {String | Object} options.cover
 * @param {String} options.mode  filter name  "vintage" | "blackWhite" | "relief" | "blur"
 */
magician.addImageFilter({
  cover: baseImageUrl,
  mode: "vintage"
});

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].