question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error: maxMemoryUsageInMB limit exceeded when resizing large jpeg textures

See original GitHub issue

Describe the bug Resizing large jpeg textures fails with error: maxMemoryUsageInMB limit exceeded.

To Reproduce Run gltf-transform resize --width 512 --height 512 on a model with an 8192x8192 jpeg texture.

Additional context This seems to be an upstream bug in the scijs/get-pixels dependency. I opened an issue here: https://github.com/scijs/get-pixels/issues/57.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
donmccurdycommented, Aug 2, 2022

/cc https://github.com/donmccurdy/glTF-Transform/issues/647

For folks running into this issue, the manual workaround for glTF files hitting this error would be to unpack the textures (if they aren’t already separate) and resize large textures manually.

gltf-transform cp input.glb output.gltf

The number of textures and size of textures both contribute to memory limits, with ≤4K being generally recommended. Aim for powers of two on each side, like 512px, 1024px, or 2048px. The textures do not need to be square.

0reactions
timhc22commented, Aug 2, 2022

Yes this worked for me, thanks for the response on Stack Overflow @donmccurdy, what I did, for anyone else interested, was:

  1. Use blender to save a HUGE gltf as a ‘separate’ file (so the texture is separate).
  2. Use Photoshop/Gimp to resize the texture.
  3. Re-import into blender
  4. Export again as an embedded gltf
  5. Run npx gltfjsx ./myfile.gltf --types --shadows --transform --aggressive --draco https://www.gstatic.com/draco/versioned/decoders/1.4.1/ to squish it into a nicely sized glb file

When you do 5., the tsx generated might include a . in the file name, so either rename them in blender in step 3., or write typescript like so in the generated tsx:

type GLTFResult = GLTF & {
  nodes: {
    Mesh_0001: THREE.Mesh
  }
  materials: {
    'material_0.001': THREE.MeshBasicMaterial
  }
}

<mesh castShadow receiveShadow geometry={nodes.Mesh_0001.geometry} material={materials['material_0.001']} />

https://blender.stackexchange.com/questions/270593/how-to-use-blender-to-get-model-to-a-state-where-it-can-be-shrank-with-gltfjsx?noredirect=1#comment464073_270593

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nodejs memory gets filled too quick when uploading images
Since I don't have a memory restriction, the app won't crash but the memory usage is ~870MB when uploading a 10MB image. A...
Read more >
ImageMagick crashes on large images
ImageMagick is not able to handle larges images. As you can see in the following code, I am running identify on a JPG...
Read more >
maxMemoryUsageInMB limit exceeded - Backendless Support
When calling one of my API Services, I'm getting the following error: 668 Error: maxMemoryUsageInMB limit exceeded by at least 24MB.
Read more >
Alternative textureResize() implementations · Issue #647 ... - CNHUB
donmccurdy commented 28 days ago ; error: maxMemoryUsageInMB limit exceeded when resizing large jpeg textures #344. Closed ; Resizing textures to 2k is...
Read more >
Jimp - npm
var Jimp = require('jimp'); // open a file called "lenna.png" Jimp.read('lenna.png', (err, lenna) => { if (err) throw err; lenna .resize(256 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found