-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
214 lines (182 loc) · 7.81 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pintura FilePond example project</title>
<link
rel="stylesheet"
href="./node_modules/@pqina/pintura/pintura.css"
/>
<link
rel="stylesheet"
href="./node_modules/filepond/dist/filepond.min.css"
/>
<link
rel="stylesheet"
href="./node_modules/filepond-plugin-file-poster/dist/filepond-plugin-file-poster.min.css"
/>
<!-- Uncomment to load video editor extension
<link
rel="stylesheet"
href="./node_modules/@pqina/pintura-video/dist/pinturavideo.css"
/>
-->
<style>
html {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji',
'Segoe UI Emoji', 'Segoe UI Symbol';
font-size: 16px;
line-height: 1.5;
}
body {
padding: 1em;
}
img {
max-width: 100%;
}
/* bright / dark mode */
.pintura-editor {
--color-background: 255, 255, 255;
--color-foreground: 10, 10, 10;
}
@media (prefers-color-scheme: dark) {
html {
color: #fff;
background: #111;
}
.pintura-editor {
--color-background: 10, 10, 10;
--color-foreground: 255, 255, 255;
}
}
</style>
</head>
<body>
<h1>Pintura Image Editor</h1>
<input type="file" multiple />
<script type="module">
import * as FilePond from './node_modules/filepond/dist/filepond.esm.js';
import FilePondPluginFilePoster from './node_modules/filepond-plugin-file-poster/dist/filepond-plugin-file-poster.esm.js';
import FilePondPluginImageEditor from './node_modules/@pqina/filepond-plugin-image-editor/dist/FilePondPluginImageEditor.js';
// Register FilePond plugins
FilePond.registerPlugin(
FilePondPluginImageEditor,
FilePondPluginFilePoster
);
import {
openEditor,
createDefaultImageReader,
createDefaultImageWriter,
processImage,
getEditorDefaults,
} from './node_modules/@pqina/pintura/pintura.js';
/* Uncomment to load video editor extension
import {
setPlugins,
createDefaultMediaWriter,
imageStateToCanvas,
} from './node_modules/@pqina/pintura/pintura.js';
import {
plugin_trim_locale_en_gb,
plugin_trim,
createDefaultVideoWriter,
createMediaStreamEncoder,
} from './node_modules/@pqina/pintura-video/pinturavideo.js';
// Load the Trim plugin view
setPlugins(plugin_trim);
*/
FilePond.create(document.querySelector('input'), {
allowReorder: true,
filePosterMaxHeight: 256,
// Image Editor plugin properties
imageEditor: {
// used to create the editor, receives editor configuration, should return an editor instance
createEditor: openEditor,
// Required, used for reading the image data
imageReader: [createDefaultImageReader],
// optionally. can leave out when not generating a preview thumbnail and/or output image
imageWriter: [
// The image writer to use
createDefaultImageWriter,
// optional image writer instructions, this instructs the image writer to resize the image to match a width of 384 pixels
{
targetSize: {
width: 128,
},
},
/* Uncomment when editing videos, remove above code
() =>
createDefaultMediaWriter(
// Generic Media Writer options, passed to image and video writer
{
targetSize: {
width: 400,
},
},
[
// For handling images
createDefaultImageWriter(),
// For handling videos
createDefaultVideoWriter({
// Video writer instructions here
// ...
// Encoder to use
encoder: createMediaStreamEncoder({
imageStateToCanvas,
}),
}),
]
),
*/
],
// used to generate poster images, runs an editor in the background
imageProcessor: processImage,
// Pintura Image Editor properties
editorOptions: {
// pass the editor default configuration options
...getEditorDefaults({
/* Uncomment when editing videos
locale: { ...plugin_trim_locale_en_gb },
*/
}),
// we want a square crop
imageCropAspectRatio: 1,
},
/* uncomment if you've used FilePond with version 6 of Pintura and are loading old file metadata
// map legacy data objects to new imageState objects
legacyDataToImageState: legacyDataToImageState,
*/
},
/* Ucomment when editing videos
filePosterFilterItem: (item) => {
// We currently cannot create video posters
return /image/.test(item.fileType);
},
*/
/* Ucomment when editing videos
// When editing video's it's advised to use asynchronous uploading, this will trigger video processing on upload instead of on file drop
instantUpload: false,
server: {
// https://pqina.nl/filepond/docs/api/server/#end-points
},
*/
/* Uncomment when editing videos
imageEditorSupportImage: (file) =>
/image/.test(file.type) || /video/.test(file.type),
*/
/* uncomment to preview the resulting file in the document after editing
onpreparefile: (fileItem, file) => {
const media = document.createElement(
/video/.test(file.type) ? 'video' : 'img'
);
media.controls = true;
media.src = URL.createObjectURL(file);
document.body.appendChild(media);
},
*/
});
</script>
</body>
</html>