vue-image-diff
vue component for multiple image comparison.
multiple images can be panned and scaled simultaneously and compared by pixel-wise.
currently supported only 8bit jpg and png format.
Examples
Web-App: https://github.com/whwnsdlr1/image-diff
jsfiddle1 - using web image url: https://jsfiddle.net/whwnsdlr1/xgz21e95/
jsfiddle2 - diff blur images: https://jsfiddle.net/whwnsdlr1/84bkq2hy/
jsfiddle3 - using input event: https://jsfiddle.net/whwnsdlr1/38zhbtm1/
Usage
install
npm i vue-image-diff
how to include component
in Vue Project
<template>
...
<vue-image-diff :data="data" :options="options" :options-tool-bar="optionsToolBar" />
...
</template>
<script>
import vueImageDiff from 'vue-image-diff'
export default {
...
components: {
'vue-image-diff': vueImageDiff
}
...
}
</script>
in html
<body>
<script src="vue.js"></script>
<script src="VueImageDiff.js"></script>
...
<div class="container">
<vue-image-diff :data=data :options=options :options-tool-bar=optionsToolBar />
</div>
...
<script>
new Vue({
el: '.container',
components: {
'vue-image-diff': vueImageDiff
},
data: {
return {
data: [],
options: {}
}
}
})
</script>
</body>
props
data
An array of objects that hold image information.
data = [
{
name: 'korea Mountains',
blob: blob,
ext: 'jpg'
params: {author: 'fxgsell'},
id: id
}
]
options
An object that gives information about the initial state of the component.
options = {
coord: {
x: 0,
y: 0
},
zoom: 1,
voi: {
windowCenter: 127,
windowWidth: 256
},
predefinedImageSize: {
width: undefined,
height: undefined
},
diff: {
activate: false,
reference: {
id: undefined,
},
tolerance: 1,
opacity: 0.7,
colors: {
same: new Uint8ClampedArray([0, 0, 255]),
diff: new Uint8ClampedArray([255, 0, 0])
}
},
style: {
borderWidth: 1,
borderColor: new Uint8ClampedArray([255, 0, 0]),
showOverlayText: true,
frameRowCount: 3
}
}
tolerance: 
An object that gives information about the initial state of the component toolbar.
optToolBar = {
show: true,
pan: {
show: true,
disabled: false
},
zoom: {
show: true,
disabled: false
},
diff: {
show: true,
ref: {
show: true
},
tolerance: {
show: true
}
}
}
API

- openControlPanel: open Control panel.
- resetState: reset to initial state.
- setState: set new state.
- getState: get current state.
event
- onstatechange: vue-event raised when state change with state object. you can catch like this
<vue-image-diff ... @onstatechange="listener" ... />
Control
- left mouse & touch drag - panning
- mouse wheel & pinch to zoom - zoom in / out
- mouse doubleclick - change reference image for diff
- right mouse drag - adjust brightness and contrast
Browser support - (tested)
- Google Chrome 77+
- Google Chrome 77+ on Android 9+
- Mozilla FireFox 68+
Third-party libraries
Dependencies
Dev-Dependencies
- @vue/cli-plugin-babel
- @vue/cli-plugin-eslint
- @vue/cli-service
- babel-eslint
- eslint
- eslint-plugin-vue
- vue-template-compiler
TO DO
- support tiff, bmp and 16bit png format.
- reduce library size.
- add SSIM
评论