mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 17:53:16 +00:00
Merge pull request #2461 from pixelfed/staging
Add federated photo filters
This commit is contained in:
commit
5d7152a937
8 changed files with 81 additions and 1 deletions
|
@ -18,6 +18,7 @@
|
||||||
- New Discover Layout, add trending hashtags, places and posts ([c251d41b](https://github.com/pixelfed/pixelfed/commit/c251d41b))
|
- New Discover Layout, add trending hashtags, places and posts ([c251d41b](https://github.com/pixelfed/pixelfed/commit/c251d41b))
|
||||||
- Add Password change email notification ([de1cca4f](https://github.com/pixelfed/pixelfed/commit/de1cca4f))
|
- Add Password change email notification ([de1cca4f](https://github.com/pixelfed/pixelfed/commit/de1cca4f))
|
||||||
- Add shared inbox ([4733ca9f](https://github.com/pixelfed/pixelfed/commit/4733ca9f))
|
- Add shared inbox ([4733ca9f](https://github.com/pixelfed/pixelfed/commit/4733ca9f))
|
||||||
|
- Add federated photo filters ([0a5a0e86](https://github.com/pixelfed/pixelfed/commit/0a5a0e86))
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
- Updated PostComponent, fix remote urls ([42716ccc](https://github.com/pixelfed/pixelfed/commit/42716ccc))
|
- Updated PostComponent, fix remote urls ([42716ccc](https://github.com/pixelfed/pixelfed/commit/42716ccc))
|
||||||
|
|
|
@ -41,6 +41,9 @@ class MediaController extends Controller
|
||||||
->whereNull('status_id')
|
->whereNull('status_id')
|
||||||
->findOrFail($id);
|
->findOrFail($id);
|
||||||
|
|
||||||
|
$media->version = 2;
|
||||||
|
$media->save();
|
||||||
|
|
||||||
$fragments = explode('/', $media->media_path);
|
$fragments = explode('/', $media->media_path);
|
||||||
$name = last($fragments);
|
$name = last($fragments);
|
||||||
array_pop($fragments);
|
array_pop($fragments);
|
||||||
|
|
|
@ -22,7 +22,7 @@ class MediaTransformer extends Fractal\TransformerAbstract
|
||||||
'is_nsfw' => $media->is_nsfw,
|
'is_nsfw' => $media->is_nsfw,
|
||||||
'orientation' => $media->orientation,
|
'orientation' => $media->orientation,
|
||||||
'filter_name' => $media->filter_name,
|
'filter_name' => $media->filter_name,
|
||||||
'filter_class' => $media->filter_class,
|
'filter_class' => $media->version == 1 ? $media->filter_class : null,
|
||||||
'mime' => $media->mime,
|
'mime' => $media->mime,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
BIN
public/js/app.js
vendored
BIN
public/js/app.js
vendored
Binary file not shown.
BIN
public/js/compose.js
vendored
BIN
public/js/compose.js
vendored
Binary file not shown.
Binary file not shown.
43
resources/assets/js/app.js
vendored
43
resources/assets/js/app.js
vendored
|
@ -139,6 +139,49 @@ window.App.util = {
|
||||||
['Willow','filter-willow'],
|
['Willow','filter-willow'],
|
||||||
['X-Pro II','filter-xpro-ii']
|
['X-Pro II','filter-xpro-ii']
|
||||||
],
|
],
|
||||||
|
filterCss: {
|
||||||
|
'filter-1977': 'sepia(.5) hue-rotate(-30deg) saturate(1.4)',
|
||||||
|
'filter-aden': 'sepia(.2) brightness(1.15) saturate(1.4)',
|
||||||
|
'filter-amaro': 'sepia(.35) contrast(1.1) brightness(1.2) saturate(1.3)',
|
||||||
|
'filter-ashby': 'sepia(.5) contrast(1.2) saturate(1.8)',
|
||||||
|
'filter-brannan': 'sepia(.4) contrast(1.25) brightness(1.1) saturate(.9) hue-rotate(-2deg)',
|
||||||
|
'filter-brooklyn': 'sepia(.25) contrast(1.25) brightness(1.25) hue-rotate(5deg)',
|
||||||
|
'filter-charmes': 'sepia(.25) contrast(1.25) brightness(1.25) saturate(1.35) hue-rotate(-5deg)',
|
||||||
|
'filter-clarendon': 'sepia(.15) contrast(1.25) brightness(1.25) hue-rotate(5deg)',
|
||||||
|
'filter-crema': 'sepia(.5) contrast(1.25) brightness(1.15) saturate(.9) hue-rotate(-2deg)',
|
||||||
|
'filter-dogpatch': 'sepia(.35) saturate(1.1) contrast(1.5)',
|
||||||
|
'filter-earlybird': 'sepia(.25) contrast(1.25) brightness(1.15) saturate(.9) hue-rotate(-5deg)',
|
||||||
|
'filter-gingham': 'contrast(1.1) brightness(1.1)',
|
||||||
|
'filter-ginza': 'sepia(.25) contrast(1.15) brightness(1.2) saturate(1.35) hue-rotate(-5deg)',
|
||||||
|
'filter-hefe': 'sepia(.4) contrast(1.5) brightness(1.2) saturate(1.4) hue-rotate(-10deg)',
|
||||||
|
'filter-helena': 'sepia(.5) contrast(1.05) brightness(1.05) saturate(1.35)',
|
||||||
|
'filter-hudson': 'sepia(.25) contrast(1.2) brightness(1.2) saturate(1.05) hue-rotate(-15deg)',
|
||||||
|
'filter-inkwell': 'brightness(1.25) contrast(.85) grayscale(1)',
|
||||||
|
'filter-kelvin': 'sepia(.15) contrast(1.5) brightness(1.1) hue-rotate(-10deg)',
|
||||||
|
'filter-juno': 'sepia(.35) contrast(1.15) brightness(1.15) saturate(1.8)',
|
||||||
|
'filter-lark': 'sepia(.25) contrast(1.2) brightness(1.3) saturate(1.25)',
|
||||||
|
'filter-lofi': 'saturate(1.1) contrast(1.5)',
|
||||||
|
'filter-ludwig': 'sepia(.25) contrast(1.05) brightness(1.05) saturate(2)',
|
||||||
|
'filter-maven': 'sepia(.35) contrast(1.05) brightness(1.05) saturate(1.75)',
|
||||||
|
'filter-mayfair': 'contrast(1.1) brightness(1.15) saturate(1.1)',
|
||||||
|
'filter-moon': 'brightness(1.4) contrast(.95) saturate(0) sepia(.35)',
|
||||||
|
'filter-nashville': 'sepia(.25) contrast(1.5) brightness(.9) hue-rotate(-15deg)',
|
||||||
|
'filter-perpetua': 'contrast(1.1) brightness(1.25) saturate(1.1)',
|
||||||
|
'filter-poprocket': 'sepia(.15) brightness(1.2)',
|
||||||
|
'filter-reyes': 'sepia(.75) contrast(.75) brightness(1.25) saturate(1.4)',
|
||||||
|
'filter-rise': 'sepia(.25) contrast(1.25) brightness(1.2) saturate(.9)',
|
||||||
|
'filter-sierra': 'sepia(.25) contrast(1.5) brightness(.9) hue-rotate(-15deg)',
|
||||||
|
'filter-skyline': 'sepia(.15) contrast(1.25) brightness(1.25) saturate(1.2)',
|
||||||
|
'filter-slumber': 'sepia(.35) contrast(1.25) saturate(1.25)',
|
||||||
|
'filter-stinson': 'sepia(.35) contrast(1.25) brightness(1.1) saturate(1.25)',
|
||||||
|
'filter-sutro': 'sepia(.4) contrast(1.2) brightness(.9) saturate(1.4) hue-rotate(-10deg)',
|
||||||
|
'filter-toaster': 'sepia(.25) contrast(1.5) brightness(.95) hue-rotate(-15deg)',
|
||||||
|
'filter-valencia': 'sepia(.25) contrast(1.1) brightness(1.1)',
|
||||||
|
'filter-vesper': 'sepia(.35) contrast(1.15) brightness(1.2) saturate(1.3)',
|
||||||
|
'filter-walden': 'sepia(.35) contrast(.8) brightness(1.25) saturate(1.4)',
|
||||||
|
'filter-willow': 'brightness(1.2) contrast(.85) saturate(.05) sepia(.2)',
|
||||||
|
'filter-xpro-ii': 'sepia(.45) contrast(1.25) brightness(1.75) saturate(1.3) hue-rotate(-5deg)'
|
||||||
|
},
|
||||||
emoji: ['😂','💯','❤️','🙌','👏','👌','😍','😯','😢','😅','😁','🙂','😎','😀','🤣','😃','😄','😆','😉','😊','😋','😘','😗','😙','😚','🤗','🤩','🤔','🤨','😐','😑','😶','🙄','😏','😣','😥','😮','🤐','😪','😫','😴','😌','😛','😜','😝','🤤','😒','😓','😔','😕','🙃','🤑','😲','🙁','😖','😞','😟','😤','😭','😦','😧','😨','😩','🤯','😬','😰','😱','😳','🤪','😵','😡','😠','🤬','😷','🤒','🤕','🤢','🤮','🤧','😇','🤠','🤡','🤥','🤫','🤭','🧐','🤓','😈','👿','👹','👺','💀','👻','👽','🤖','💩','😺','😸','😹','😻','😼','😽','🙀','😿','😾','🤲','👐','🤝','👍','👎','👊','✊','🤛','🤜','🤞','✌️','🤟','🤘','👈','👉','👆','👇','☝️','✋','🤚','🖐','🖖','👋','🤙','💪','🖕','✍️','🙏','💍','💄','💋','👄','👅','👂','👃','👣','👁','👀','🧠','🗣','👤','👥'
|
emoji: ['😂','💯','❤️','🙌','👏','👌','😍','😯','😢','😅','😁','🙂','😎','😀','🤣','😃','😄','😆','😉','😊','😋','😘','😗','😙','😚','🤗','🤩','🤔','🤨','😐','😑','😶','🙄','😏','😣','😥','😮','🤐','😪','😫','😴','😌','😛','😜','😝','🤤','😒','😓','😔','😕','🙃','🤑','😲','🙁','😖','😞','😟','😤','😭','😦','😧','😨','😩','🤯','😬','😰','😱','😳','🤪','😵','😡','😠','🤬','😷','🤒','🤕','🤢','🤮','🤧','😇','🤠','🤡','🤥','🤫','🤭','🧐','🤓','😈','👿','👹','👺','💀','👻','👽','🤖','💩','😺','😸','😹','😻','😼','😽','🙀','😿','😾','🤲','👐','🤝','👍','👎','👊','✊','🤛','🤜','🤞','✌️','🤟','🤘','👈','👉','👆','👇','☝️','✋','🤚','🖐','🖖','👋','🤙','💪','🖕','✍️','🙏','💍','💄','💋','👄','👅','👂','👃','👣','👁','👀','🧠','🗣','👤','👥'
|
||||||
],
|
],
|
||||||
embed: {
|
embed: {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<input type="file" id="pf-dz" name="media" class="w-100 h-100 d-none file-input" v-bind:accept="config.uploader.media_types">
|
<input type="file" id="pf-dz" name="media" class="w-100 h-100 d-none file-input" v-bind:accept="config.uploader.media_types">
|
||||||
|
<canvas class="d-none" id="pr_canvas"></canvas>
|
||||||
|
<img class="d-none" id="pr_img">
|
||||||
<div class="timeline">
|
<div class="timeline">
|
||||||
<div v-if="uploading">
|
<div v-if="uploading">
|
||||||
<div class="card status-card card-md-rounded-0 w-100 h-100 bg-light py-3" style="border-bottom: 1px solid #f1f1f1">
|
<div class="card status-card card-md-rounded-0 w-100 h-100 bg-light py-3" style="border-bottom: 1px solid #f1f1f1">
|
||||||
|
@ -983,9 +985,40 @@ export default {
|
||||||
this.cameraRollMedia = res.data;
|
this.cameraRollMedia = res.data;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
applyFilterToMedia() {
|
applyFilterToMedia() {
|
||||||
// this is where the magic happens
|
// this is where the magic happens
|
||||||
|
|
||||||
|
let medias = this.media;
|
||||||
|
let media = null;
|
||||||
|
const canvas = document.getElementById('pr_canvas');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
let image = document.getElementById('pr_img');
|
||||||
|
let blob = null;
|
||||||
|
let data = null;
|
||||||
|
|
||||||
|
for (var i = medias.length - 1; i >= 0; i--) {
|
||||||
|
media = medias[i];
|
||||||
|
if(media.filter_class) {
|
||||||
|
image.src = media.url;
|
||||||
|
image.addEventListener('load', e => {
|
||||||
|
canvas.width = image.width;
|
||||||
|
canvas.height = image.height;
|
||||||
|
ctx.filter = App.util.filterCss[media.filter_class];
|
||||||
|
ctx.drawImage(image, 0, 0, image.width, image.height);
|
||||||
|
ctx.save();
|
||||||
|
canvas.toBlob(function(blob) {
|
||||||
|
data = new FormData();
|
||||||
|
data.append('file', blob);
|
||||||
|
axios.post('/api/local/compose/media/update/'+media.id, data).then(res => {
|
||||||
|
}).catch(err => {
|
||||||
|
});
|
||||||
|
}, media.mime, 0.9);
|
||||||
|
});
|
||||||
|
ctx.clearRect(0, 0, image.width, image.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
tagSearch(input) {
|
tagSearch(input) {
|
||||||
|
|
Loading…
Reference in a new issue