jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
http://jimp-dev.github.io/jimp/
MIT License
13.9k stars 761 forks source link

Do you support vite? #1244

Closed suzhenghui-sky closed 2 weeks ago

suzhenghui-sky commented 1 year ago

Expected Behavior

jimp.read should not be undefined

Current Behavior

jimp.read is undefined

Failure Information (for bugs)

import Jimp from 'jimp'; console.log(Jimp.read) // undefined

Steps to Reproduce

Screenshots

Context

Failure Logs

suzhenghui-sky commented 1 year ago

图片

mustafaekim commented 1 year ago

Is it possible to use Jimp with vite?

suzhenghui-sky commented 1 year ago

Is it possible to use Jimp with vite?

I don't think so.

JasonKwok8588 commented 9 months ago

are you use in web browser? you can try : import "jimp/browser/lib/jimp.js"; console.log(Jimp.read)

hipstersmoothie commented 2 weeks ago

:rocket: Issue was released in v1.0.2 :rocket:

sergeushenecz commented 2 weeks ago

@hipstersmoothie How to use in web after release this package?

hipstersmoothie commented 2 weeks ago

http://jimp-dev.github.io/jimp/guides/browser/

sergeushenecz commented 2 weeks ago

It doen't work in vite. I tried and use jimp/browser and jimp

Failed to resolve import "jimp/browser"

if use import Jimp from 'jimp'; then i see this error in console.

image
hipstersmoothie commented 2 weeks ago

That stack trace seems odd. Could you share a minimal repro?

hipstersmoothie commented 2 weeks ago

So there was a problem with us not shipping the browser files. That's fixed in 1.1.3.

Lookin into making the bundler experience more automatic

sergeushenecz commented 2 weeks ago

I noticed on prev version of library works

await Jimp.read(ctx.getImageData(0, 0, canvas.width, canvas.height));

image

but now i see error

hipstersmoothie commented 2 weeks ago

what previous version?

sergeushenecz commented 2 weeks ago
"jimp": "0.22.12",
hipstersmoothie commented 2 weeks ago

It looks like in v1 you would call fromBitmap instead of fromBuffer

sergeushenecz commented 2 weeks ago

@hipstersmoothie I updated to 1.2.0 version and use

import Jimp from 'jimp';

but see error node_modules/.vite/deps/jimp.js?v=84fca0b0' does not provide an export named 'default'

hipstersmoothie commented 2 weeks ago

That's cause Jimp has no default export anymore.

import { Jimp } from 'jimp';
sergeushenecz commented 2 weeks ago

A lot of thanks for support

hipstersmoothie commented 2 weeks ago

no prob! added to migration guide http://jimp-dev.github.io/jimp/guides/migrate-to-v1/