-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JpegDecoder is undefined when jpgjs is loaded - module.exports is empty #32
Comments
Hi, I never used npm or Node.js . I use UTIF.js in a web browser. Maybe @Scimonster could help us? |
Thanks, I'll try logging an issue with jpg.js |
Oh also, can you please release the current version to npm? Thanks |
@photopea Hi, I figured out what was wrong with jpg.js but they have not been active for a few years. I forked jpgjs to my github (https://github.com/makr28/jpgjs) would you be willing to switch the dependency to it? If you don't like that idea would you be willing to fork it and put the change that fixes it in? Thanks! |
The JpegDecoder that I use along with UTIF.js is a copy-pasted fragment of pdf.js , see here: mozilla/pdf.js#6128 TIFF files containing JPEG compression are a "legacy thing". I recommend to convert them all to a regular JPEG and then use these JPEGs. Other compressions (CCITT, LZW, PackBits) are included in UTIF.js and do not require any additional library. |
@syvaidya You are the one who understands JPEG! :) Could we insert all necessary parts of JpegDecoder into UTIF.js (only those JPEG features, that can be used in TIFFs)? How much code would it be? It is a bit unpractical to have a dependency. |
In your package.json you have: "dependencies": { So you already are pulling in the dependency |
If you want to take that dependency out, I can just put my version of jpg.js as a dependency in my project. Otherwise if I do npm install, it may overwrite mine with this one |
I'll take a look at npm and the dependency stuff over the weekend.
…On Thu, Apr 26, 2018, 9:44 PM makr28 ***@***.***> wrote:
If you want to take that dependency out, I can just put my version of
jpg.js as a dependency in my project
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACshEqR2p3cHW8cCMQgLSiCjcJY6SRy4ks5tshWJgaJpZM4TkBXl>
.
|
Thanks |
Actually testing with the dependency take out of utif.js's node modules, it doesn't work right, so we do need you to keep the dependency in your package.json but switch it to the working version. It's the only way utif will work for node projects. This shouldnt affect what you use utif for as you dont use the node_modules folder or package.json in your projects but node projects will. And since you already have the dependency there, it won't be adding anything to utif. Thanks :) |
Yes Tiff files containing JPEG is a legacy thing, but there are many files still in existence today that are still that data type. Unfortunately managing long standing enterprise applications we need this support as well. JPGJG was forked from mozilla/pdf.js 3-4 years ago. mozilla/pdf.js has long since enhanced their jpgjs while this has remained stagnant and unresponsive. That and it doesn't even follow modern ecmascript standards which is causing the bug in this issue. +1 to either remove the dependency and add in the functionality to support jpeg natively with utif or to pull in a more modern one that can be used with modern javascript development practices. |
@k1nger I would like to ask Mozilla to publish their JPEG decoders as a separate library (and maintain it in that library), and pdf.js would have a dependency on that library. Otherwise, Github would be filled with dozens of copy-pasted fragments of pdf.js, which are not maintained by anybody anymore. Would you support me and help me emphasize this to pdf.js developers? |
Yup, I think that's a good idea. I found the issue you created on the mozilla/pdfjs repo. I'll start reading up there. |
@k1nger I see you already found my post: mozilla/pdf.js#8966 . Can others also kindly ask Mozilla to publish a separate JPEG decoder? Please? :) |
@photopea Another way would be to change your package.json where you are currently pulling in the unworking jpg.js to pull in pdf.js and switch the require to use their version of jpg.js and the jpegDecoder. I support your campaign to have pdf js extract the jpegdecoder and I will comment on the issue but as of right now it doesn't look like they are going to anytime soon :( If you aren't going to switch the jpg.js dependency then can you please remove the line "jpgjs": "github:notmasteryet/jpgjs", from your package.json as it is currently useless if it doesn't export the jpegdecoder correctly. And to make UTIF work for NodeJs projects can you please remove the require line and add a method to set jpegDecoder to a variable passed in. These proposed changes only affect Node projects. As with @k1nger I am also working in enterprise software that requires us to support older tiff images. Thanks |
@Scimonster Have you made any progress with what you were looking into? @photopea Since it looks like Mozilla is unresponsive I think it may be best to move forward with this issue and drop another release to npm. I can help. |
Thanks @Scimonster |
I have a node project and I did an "npm install utif". This correctly brought in pako and jpgjs as well.
Pako can be found and is fine. But jpgjs module.exports is not being set.
In jpgjs line 102
if (typeof exports === "function") {
module.exports = {
JpegImage: JpegImage,
JpegDecoder: JpegDecoder,
JpxDecoder: JpxDecoder,
Jbig2Decoder: Jbig2Decoder
};
}
Looking in the debugger typeof exports evaluates to 'object'
This may be an issue with Jpg.js but I wanted to ask if you had come across this issue?
Thanks
added notes:
-Using npm version 8.9.4
-I am going thru the require('jpgjs') code path to load jpegDecoder
The text was updated successfully, but these errors were encountered: