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
Doesnt work if spawned from another process #68
Comments
Well i figured out the reason, im running the process with a different user did i miss something? |
Strange. I don’t know what is going on there. Any reason that you can’t call the script with python directly rather than call it through a sub process in a different language? The ‘crunch’ executable is a Python script. If you must execute through a non-Python language it should be fairly simple to re-write the execution directly in one of those languages. There is already a JS implementation if that happens to be helpful to you. |
If I login to my system as the user For my use case I have a queue, that spawn crunch instances.. However the queue itself runs as non root account and I can't change that... As far as I know I see that I'm able to execute python and run crunch script with any user... The problem might be on pngquant or zopli not being able to access some system resource under a different account ... |
I think that you are correct. The stdout reporting with the % file size calculations are coming from the Python scripting. The Python source is able to read the target file(s) to calculate the file size. For some reason, it appears that optimizations with pngquant and zopflipng are not being performed and the file size remains at 100% original size. Error messages (and non-zero exit status codes) should be propagated from those tools, but that is not happening which is odd.
php -r 'shell_exec("python crunch.py path/to/a/png/file.png");' |
if i remove
all had exit code 0 but with
|
ok i think i got it figured out now.. when i first install the crunch with this command:
im running as root, therefore the
crunch will will install the dependencies inside
and it works :D |
Excellent! Do you think that this is a common enough need to warrant placing your approach in the documentation? |
i think the ultimate solution to avoid this problem in the future would be not installing the |
The issue with this approach is that it could overwrite a system/package manager/manual install of both project dependencies. This was an intentional decision because:
|
uhm, understood, yeah in that case i think would be worth mentioning on the docs that the installation path can be modified by setting the |
Will update the docs to see if I can clarify this issue. Thanks for helping to get to the bottom of it. I appreciate all of your feedback here! |
Note too that you can specify the path to the pngquant and zopflipng executables in these lines of the script: Lines 38 to 39 in e0bca67
It is not necessary to use os.path.join if you are using this on a known single platform, just replace the entire PNGQUANT_CLI_PATH = "path/to/file"
ZOPFLIPNG_CLI_PATH = "path/to/file" The Python |
uhm but that would require having a fork of this repo which potently could lead me for missing further updates or writing a script to find/replace on the crunch.py, currently for my use case im building it inside a docker container.. could that
|
adds documentation for install account vs. execution account issue that was raised in #68
Added documentation in the Install section of the docs/EXECUTABLE.md document in ee00d14 I am definitely open to considering environment variable support for installations and execution. Mind opening a new issue report with details on how the installation and execution should be modified to support your use case (or a PR with the proposed changes)? Thanks again for your help here! |
When i spawn Crunch from any other process... e.g,
node, php, go
... the compression ratio is always on 100%running the same process manually on bash/sh
crunch fafdae7fd865c9ea6480e5d5037fd69d.png
gives mereproducible command
The text was updated successfully, but these errors were encountered: