Skip to content
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

@jimp/png won't work with @jimp/custom #1272

Open
gevhambarzumyan93 opened this issue Jan 19, 2024 · 0 comments · May be fixed by #1285
Open

@jimp/png won't work with @jimp/custom #1272

gevhambarzumyan93 opened this issue Jan 19, 2024 · 0 comments · May be fixed by #1285

Comments

@gevhambarzumyan93
Copy link

Expected Behavior

it should read PNG files as it does with the JPEG and others

Current Behavior

I am using customJimp with Vite and whenever I include the JIMP/png package inside my config files JIMP throws an error

Failure Information (for bugs)

Uncaught TypeError: Cannot read properties of undefined (reading 'toString')
    at node_modules/browserify-zlib/lib/index.js (chunk-BDYZPAYP.js?v=25465f5d:7645:100)
    at __require2 (chunk-R3NO7AUE.js?v=25465f5d:26:50)
    at node_modules/pngjs/lib/parser-async.js (chunk-BDYZPAYP.js?v=25465f5d:9212:16)
    at __require2 (chunk-R3NO7AUE.js?v=25465f5d:26:50)
    at node_modules/pngjs/lib/png.js (chunk-BDYZPAYP.js?v=25465f5d:10164:18)
    at __require2 (chunk-R3NO7AUE.js?v=25465f5d:26:50)
    at chunk-BDYZPAYP.js?v=25465f5d:10299:28
node_modules/browserify-zlib/lib/index.js @ chunk-BDYZPAYP.js?v=25465f5d:7645
__require2 @ chunk-R3NO7AUE.js?v=25465f5d:26
node_modules/pngjs/lib/parser-async.js @ chunk-BDYZPAYP.js?v=25465f5d:9212
__require2 @ chunk-R3NO7AUE.js?v=25465f5d:26
node_modules/pngjs/lib/png.js @ chunk-BDYZPAYP.js?v=25465f5d:10164
__require2 @ chunk-R3NO7AUE.js?v=25465f5d:26
(anonymous) @ chunk-BDYZPAYP.js?v=25465f5d:10299

Steps to Reproduce

nothing particulate.

create config and import it.

everything is ok until I import PNG as a type

import bmp from "@jimp/bmp";
import configure from "@jimp/custom";
import gif from "@jimp/gif";
import jpeg from "@jimp/jpeg";
import blur from "@jimp/plugin-blur";
import color from "@jimp/plugin-color";
import contain from "@jimp/plugin-contain";
import normalize from "@jimp/plugin-normalize";
import resize from "@jimp/plugin-resize";
import png from "@jimp/png";
import tiff from "@jimp/tiff";

export default configure({
  types: [jpeg, png, bmp, gif, tiff],
  plugins: [resize, blur, color, contain, normalize],
});

Context

vite.config

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import inject from '@rollup/plugin-inject'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    inject({
      modules: { Buffer: ['buffer', 'Buffer'] }
    }),
    nodePolyfills()
  ]
})

package.json

{
  "name": "jimp-vite",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "build:ghpages": "tsc && vite build --base=/jimp-vite/",
    "preview": "vite preview"
  },
  "dependencies": {
    "@jimp/core": "^0.22.10",
    "@jimp/custom": "^0.22.10",
    "@jimp/jpeg": "^0.22.10",
    "@jimp/plugin-resize": "^0.22.10",
    "@jimp/plugins": "^0.22.10",
    "@jimp/plugin-blur": "^0.22.10",
    "@jimp/plugin-color": "^0.22.10",
    "@jimp/plugin-contain": "^0.22.10",
    "@jimp/plugin-normalize": "^0.22.10",
    "@jimp/bmp": "^0.22.10",
    "@jimp/gif": "^0.22.10",
    "@jimp/png": "^0.22.10",
    "@jimp/tiff": "^0.22.10",
    "buffer": "^6.0.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "timm": "^1.7.1",
    "pngjs": "^7.0.0"
  },
  "devDependencies": {
    "@rollup/plugin-inject": "^5.0.5",
    "@types/react": "^18.2.48",
    "@types/react-dom": "^18.2.18",
    "@jimp/types": "^0.22.10",
    "@vitejs/plugin-react": "^4.2.1",
    "npm-run-all": "^4.1.5",
    "patch-package": "^8.0.0",
    "typescript": "^5.3.3",
    "vite": "^5.0.11",
    "vite-plugin-node-polyfills": "^0.19.0"
  }
}

  • Jimp Version: 0.22.10
  • Operating System: macOS
  • Node version: 16

Failure Logs

@hipstersmoothie hipstersmoothie linked a pull request Mar 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant