Comments (3)
please have a look at the documentation, in particular:
http://fabricjs.com/fabric-filters
and the paragraph about webgl and texture size
from fabric.js.
please have a look at the documentation, in particular: http://fabricjs.com/fabric-filters and the paragraph about webgl and texture size
This doesn't work for me.
Actually, I'm not facing an issue when I apply filters; it cuts the image width to half of the canvas, but I want filters implemented smoothly without losing the image width. I tried it, but it did not work for me. Here is my code.
// intial image load
const loadImage = () => {
canvas?.clear();
fabric.Image.fromURL(src, function (img) {
img.set({ id: 'main_canvas_image', hasControls: false });
img.set({ scaleX: 1, scaleY: 1 });
img.scaleToWidth(canvas.width);
if (img.height < canvas.height) {
img.scaleToHeight(canvas.height);
}
canvas.add(img);
canvas.renderAll();
loadFilterPreview();
});
handleImageMoving();
};
// filters list with preview
const loadFilterPreview = () => {
const filtersList = [
new fabric.Image.filters.Vibrance({ vibrance: 1 }),
new fabric.Image.filters.Contrast({ contrast: 0.1 }),
new fabric.Image.filters.Brightness({ brightness: 0.1 }),
new fabric.Image.filters.Gamma({ gamma: [1, 2, 2] }),
new fabric.Image.filters.HueRotation({ rotation: 90 }),
new fabric.Image.filters.Brightness({ brightness: 0.5 }),
];
const updatedPreviews = [
{ label: 'Original', preview: '', filters: [] },
{
label: 'Studio',
preview: '',
filters: [filtersList[0], filtersList[1]],
},
{ label: 'Spotlight', preview: '', filters: [filtersList[2]] },
{ label: 'Prime', preview: '', filters: [filtersList[3]] },
{ label: 'Classic', preview: '', filters: [filtersList[4]] },
{ label: 'Edge', preview: '', filters: [filtersList[5]] },
{ label: 'Luminate', preview: '', filters: [filtersList[6]] },
];
setFilterPreview(
updatedPreviews.map(filterItem => ({
...filterItem,
preview: canvas?.toDataURL?.(),
}))
);
};
// useEffect for handle filter change
useEffect(() => {
const current = filterPreview.find(e => e.label === filter);
if (current && canvas) {
const canvasImage = canvas
?.getObjects()
?.find(e => e.id === 'main_canvas_image');
canvasImage.filters = current.filters;
canvasImage.applyFilters();
canvasImage.scaleToWidth(canvas.width);
canvas.renderAll();
}
}, [filter]);
from fabric.js.
Please add a working reproducible case i can't really work with snippets of code that i have to find a way to run.
from fabric.js.
Related Issues (20)
- i cant select a fabric object when its color is transparent with out use perPixelTargetFind , i cant use perPixelTargetFind in my project because of the so many polygon objects aligned closely so i cant use that , is there any other way to select the transparent object ?
- [Bug]: My canvas like a drawing page here im facing an issue that i draw a polyline in down and them i want show the preview of the line when mouse move and the preview showing fine but when i zoom with mouse wheel the preview getting disappear , then mouse wheel down the canvas zoom back to default state the preview showing fine only when the canvas zoom is greater than default state the polyline preview getting disappearing , i cant solve the issue please give me any solution for that
- [Bug]: Main website SSL issue HOT 3
- [Bug]: Abort signal not propagated from loadFromJSON() to objects in Group HOT 2
- [Bug]: can not use fabricjs with web-worker HOT 7
- he controlls point is not valid, i can`t scale the size by the controlls points HOT 2
- [Bug]: `Group.prototype.getObjectsBoundingBox` is no longer available in version v6 rc1
- [Bug]: Textbox does not wrap word when their is no space in words. HOT 1
- [Feature]: Interaction Based on Visual Layering Order HOT 1
- [Feature]: Undo Redo for EraserBrush HOT 1
- [Bug]: hidden textarea make parent overflow hidden div scroll when editing
- CharSpacing not working with textbox object.
- [Bug]: Overwrite fabric.util.createClass for Textbox not working in latest version HOT 2
- [Bug]: CanvasEvents["object:modified"] type has incorrect properties HOT 1
- [Feature]: Group support warp like Photoshop
- [Feature]: Apply LUTs filters with .cube files to an object from canvas. HOT 2
- SerializedPatternOptions type - union instead of intersection
- [Feature]: fabircjs Exports tiff files HOT 1
- [Feature]: Is it possible to add linear-burn, linear-dodge and linear-light in blend mode? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabric.js.