node-pngdefry icon indicating copy to clipboard operation
node-pngdefry copied to clipboard

Getting error when trying to run pngdefry

Open korboybeats opened this issue 2 years ago • 18 comments

I've installed this and tried to run it, but I keep getting this error:

image

korboybeats avatar Jul 08 '23 15:07 korboybeats

Hi, coming from your reddit post.

Unfortunately, I haven't used this project, but I might have some idea why it's not working for you.

Can you check whether you have a file named pngdefry under the underlined path? 252003517-99cf0bf6-6eab-4c8c-b377-121574e1d225

I think this is the problem - the code looks for a pngdefry binary under this path, but I think this package is no longer installing it for you at this path.

Not sure how to fix this, maybe you need to find the original binary and put it into said path.

arkus7 avatar Jul 08 '23 22:07 arkus7

Hi, coming from your reddit post.

Unfortunately, I haven't used this project, but I might have some idea why it's not working for you.

Can you check whether you have a file named pngdefry under the underlined path? 252003517-99cf0bf6-6eab-4c8c-b377-121574e1d225

I think this is the problem - the code looks for a pngdefry binary under this path, but I think this package is no longer installing it for you at this path.

Not sure how to fix this, maybe you need to find the original binary and put it into said path.

ohh hm i actually dont. i only have C:\Users\Admin\AppData\Roaming\npm\node_modules\pngdefry\lib\pngdefry\bin\osx\pngdefry no \bin\windows\pngdefry

so i created \windows and copied the pngdefry binary from the osx folder in there, but when i run the command again, it says this now: image

korboybeats avatar Jul 09 '23 05:07 korboybeats

Hi, coming from your reddit post. Unfortunately, I haven't used this project, but I might have some idea why it's not working for you. Can you check whether you have a file named pngdefry under the underlined path? 252003517-99cf0bf6-6eab-4c8c-b377-121574e1d225 I think this is the problem - the code looks for a pngdefry binary under this path, but I think this package is no longer installing it for you at this path. Not sure how to fix this, maybe you need to find the original binary and put it into said path.

ohh hm i actually dont. i only have C:\Users\Admin\AppData\Roaming\npm\node_modules\pngdefry\lib\pngdefry\bin\osx\pngdefry no \bin\windows\pngdefry

so i created \windows and copied the pngdefry binary from the osx folder in there, but when i run the command again, it says this now: image

Well, OSX binary won't work on Windows, they're not compatible.

I think the only way is to compile the binary on windows and put the executable in the mentioned path.

I think this is using this binary: https://github.com/esjeon/pngdefry

arkus7 avatar Jul 09 '23 10:07 arkus7

Hi, coming from your reddit post. Unfortunately, I haven't used this project, but I might have some idea why it's not working for you. Can you check whether you have a file named pngdefry under the underlined path? 252003517-99cf0bf6-6eab-4c8c-b377-121574e1d225 I think this is the problem - the code looks for a pngdefry binary under this path, but I think this package is no longer installing it for you at this path. Not sure how to fix this, maybe you need to find the original binary and put it into said path.

ohh hm i actually dont. i only have C:\Users\Admin\AppData\Roaming\npm\node_modules\pngdefry\lib\pngdefry\bin\osx\pngdefry no \bin\windows\pngdefry so i created \windows and copied the pngdefry binary from the osx folder in there, but when i run the command again, it says this now: image

Well, OSX binary won't work on Windows, they're not compatible.

I think the only way is to compile the binary on windows and put the executable in the mentioned path.

I think this is using this binary: https://github.com/esjeon/pngdefry

I don't understand this one too hahah, how do I compile the binary for this one? I tried cc pngdefry.c and pngdefry.c with no luck

korboybeats avatar Jul 09 '23 11:07 korboybeats

@korboybeats I had no problem compiling the pngdefry, but I'm on macOS.

Running cc pngdefry.c created an executable a.out (default name if not provided) which responds with such usage message

image

Do you have a C compiler installed on your machine?

Maybe this tutorial will help: https://www.wikihow.com/Run-C-Program-in-Command-Prompt

arkus7 avatar Jul 11 '23 10:07 arkus7

@arkus7

Alright so I installed a C compiler and just tried it again, but it just outputted a wall of errors

image

Will the binary you compiled work for me?

korboybeats avatar Jul 11 '23 11:07 korboybeats

@korboybeats No, as mentioned above, I'm on macOS - the binary is not compatible with Windows.

Did you try running another program with a similar purpose, e.g. https://axelbrz.com/?mod=iphone-png-images-normalizer or https://gist.github.com/urielka/3609051

arkus7 avatar Jul 11 '23 13:07 arkus7

@arkus7 so I tried the ipin.py thing but getting an error for that as well. I will just give up on it lol, I really appreciate your help man

image

korboybeats avatar Jul 11 '23 14:07 korboybeats

@korboybeats I might try to compile it on Windows when I get a chance to work on such platform, but cannot guarantee when

arkus7 avatar Jul 11 '23 16:07 arkus7

@korboybeats ok, I think good news, I managed to compile it on Windows.

It wasn't as straightforward as on macOS, but it works :P

Steps to fix:

  1. Download the newest version of miniz from here as a zip package
  2. Replace the original miniz.c file with the miniz.c file from the zip above
  3. Try to compile (gcc -o pngdefry.exe pngdefry.c). If it works, great! DONE! Otherwise, continue.
  4. If you have an error like undefined reference to '_ftelli64', open the miniz.c file and replace all occurrences (there were 2 for me for each word) of _ftelli64 with ftell and _fseeki64 with fseek (found it here)
  5. It should compile now.

Here's the updated pngdefry repo contents with the changes above and compiled binary. You're running the prebuilt binary at your own risk. I'm not a harmful person, but should you trust a random guy on the internet?

Try to build it yourself with the steps above, then you have the most chance it would work on your machine.

pngdefry-master-compiled.zip

image

arkus7 avatar Jul 11 '23 21:07 arkus7

@arkus7 Damnnnn you're a god. I managed to get the binary compiled, but.. lmao now when I try pngdefry -i icon.png -o new.png I get this error: image

korboybeats avatar Jul 12 '23 09:07 korboybeats

@korboybeats Check the help message of pngdefry, the -i option for pngdefry has a different meaning than -i for node-pngdefry

In node-pngdefry the -i option means input file, but in pngdefry it specifies max IDAT chunk size in bytes (whatever this means 😅)

PNGdefry version 1.1 by [Jongware], 21-Jan-2012

Removes -iphone specific data chunk, reverses colors from BGRA to RGBA, and de-multiplies alpha

usage: pngdefry [-soaplvid] file.png [...]

Options: - use this if your first input file starts with an '-' -s(suffix) append suffix to output file name -o(path) write output file(s) to path Note: without -s or -o, NO output will be created. -a do NOT de-multiply alpha -l list all chunks -v verbose processing -i(value) max IDAT chunk size in bytes (minimum: 1024; default: 524288) -p process all files, not just -iphone ones (for debugging purposed only) -d very verbose processing (for debugging purposes only)

If you're calling pngdefry directly, you should call it like this

pngdefry -o new.png icon.png

arkus7 avatar Jul 12 '23 11:07 arkus7

@arkus7 ahh i see, my bad. But now getting yet again, another issue lmao image image

korboybeats avatar Jul 12 '23 11:07 korboybeats

I don't think it wants to work for me lol

korboybeats avatar Jul 12 '23 11:07 korboybeats

@korboybeats Ok, I think I misunderstood how this works, maybe create a new folder where the outputs should land like out and instead new.png pass out

pngdefry -o out icon.png

Unfortunately, I don't have any file that is crushed, so I can't test it on my setup.

arkus7 avatar Jul 12 '23 13:07 arkus7

@korboybeats Ok, I think I misunderstood how this works, maybe create a new folder where the outputs should land like out and instead new.png pass out

pngdefry -o out icon.png

Unfortunately, I don't have any file that is crushed, so I can't test it on my setup.

YESSSS IT WORKED

korboybeats avatar Jul 12 '23 14:07 korboybeats

Thank you so much man. I really appreciate it 🙏🙏

korboybeats avatar Jul 12 '23 14:07 korboybeats

No problem, happy it worked!

arkus7 avatar Jul 13 '23 12:07 arkus7