Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FabricJS Can't Apply Filters To Large Image Due To "Max Texture Size"

I could do with some help to understand what fabric means by: Max Texture Size: 16,384 - 16,384 what? The image i used is 5MP (2560 x 1920) and trying to apply a filter to the image like this:

object.filters.push(new fabric.Image.filters.Sepia());
object.applyFilters();

The image object disappears and the message above appears in the console. I can only seem to apply filters to the image if it's < 2MP which isn't ideal at all. I really don't know what it means by a max texture size.

So what does this mean and how can i make it allow the filters on bigger sized images?

like image 788
Glen Elkins Avatar asked Oct 26 '25 00:10

Glen Elkins


1 Answers

You can set Fabric's alotted textureSize based on the max textureSize detected for a user's machine by running:

 if (fabric.isWebglSupported()) {
            fabric.textureSize = fabric.maxTextureSize;
 }

Note that running fabric.isWebglSupported() seems to be necessary to compute fabric.maxTextureSize. Otherwise, it will return undefined.

like image 118
Neil VanLandingham Avatar answered Oct 29 '25 19:10

Neil VanLandingham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!