Connect GIMP with PHP or Python - php

is there any way to connect GIMP with python or PHP and use its libraries? It seems that all i can find on the web is pygimp which is not supported anymore.
ps. i do my development on mac and i use linux as a production server

You can write GIMP plugins in Python (see, for example James Hestenridge's clothify, then call the plug-in from the command-line with a command of the form
gimp -i -b '(python-fu-bw-film RUN-NONINTERACTIVE "/path/to/filename.jpg" 0 1 FALSE FALSE FALSE FALSE FALSE FALSE)' -b '(gimp-quit 0)'
It's not exactly pretty, but it's possible. Here is another example.

Probably not directly, but I'll bet you can access some functions via 'exec()' on the command line. What are you trying to do? Can the GD or ImageMagic tools help?

One important thing regarding running gimp python plugin in batch mode.
Option -i means no interface. But in gimp documentation there is another option with same explanation --no-interface. User could though that they have same effect.
But when you try to run batch script on remote linux machine, with option -i you will get 'no display'. With option --no-interface, batch script will run without error. My colleague discovered that this is undocumented gimp 2.6.11 feature.
Regards, Karlo.

Related

How to use official php docker image without interactive mode

I'm trying to create a docker image that will spin up a container to run a Minecraft PE server. PocketMine-MP a Minecraft PE server.
The server requires PHP binary, and I want to use the official PHP docker image. However, it seems like the php docker image is configured to run in interactive mode.
I just want to use that PHP image since it has the binary in it, and copy over the necessary file to start the server, is there anyway to get rid of the interactive prompt?
I can run the php image in detached mode, but I wasn't sure if there is a better way to approach it.
I hope my intention is clear. Thank you for your time.
Found my answer. Seems like running the container in detached and interactive mode with flag -d and -t is the recommended way.

Run a C++ Application on a Webserver with WordPress

I have a C++-library (.so) for some calculations that I would like to call from Wordpress/PHP via an input formular. The promising idea to build the .so-library as a PHP extension using PHP-CPP has been fine locally on Ubuntu 14.04. But on the webserver this method failed because my webhoster doesn't support changing the extension directive in the php.ini/.user.ini. I see the following alternatives:
Build an exutable application and run it from PHP via proc_open() and send a lot of variables to the stdin of the application. Wordpress itself offers PHP plugins.
Redirect to another server where my own php extensions are supported.
Is there a way using python/web2py for that purpose?
Which would be best?
Or any other ideas?
Probably the simplest way is to create command line utility in C++ and execute it from php with shell_exec. I tried that in past and the performance was not too bad.
"Probably the simplest way is to create command line utility in C++ and execute it from php with shell_exec. I tried that in past and the performance was not too bad."
This did help. Finally I managed a build on Linux which was portable to the webserver where the website and wordpress are located. The call to the binary built from C++ was done with shell exec or popen in PHP (which one I don't remember, it was in 2018). The PHP code was finally migrated to an own wordpress plugin. Unforunately, I could not use PHP-CPP due to missing admin rights for the webderver. But the integration via shell exec or popen works fine.

PHP Interpreter for Windows

Trying to mess around with PHP, but I don't want to install IIS or Apache and was hoping for a small interpreter that I can pass the scripts to and have them run in like a console or something. Much like Lua does. Does this exist? When I go to download PHP it seems to only talk about running it on IIS or Apache.
PHP can be used on the command line. Just download and extract the executable.
Running can be done 3 ways: a file, supplied code or in an interactive shell
php file.php
php -r "echo 'hello';"
php -a
You can also install a pre-packaged server (e.g. XAMPP) or run your code online on various places (e.g. phpfiddle.org)
With PHP 5.1+ you have an interactive shell too:
launch php with -a parameter
php.exe -a
http://php.net/manual/en/features.commandline.interactive.php
I believe that PHP v5.4 comes with its own webserver built-in. Install that version and you should be fine. Though I really would like to know why you have problem with installing Apache (IIS sucks though).
EDIT:
As a few others have said, you can run PHP from the command line.
check out easyphp, a server for php development
http://php.net/cli
Alternatively, you can write your PHP scripts as you would normally (with some limitations),
And use the following command line:
C:\php.exe -f "D:\phpFile.php"
dtech's answer seems most fitting for the simple script-running things you're looking for. If you decide you want an actual web-server, with as little setup as possible, look at "XAMPP".

PHP command-line: How do I read in a typed-in password without displaying the typed chars on the console?

I want to read in a password as part of a command-line script, but do not what the typed password to appear on the screen. This seems to be a fairly common feature in command-line apps, but my Google-fu has failed in identifying how this works. Is it a feature of the OS? Do you have to intercept the input stream somehow so it doesn't write out to the console? I would like to use this in a php command line script, but I cannot use what I cannot understand.
Some independent searching yielded this link, where way down at the bottom they mention that mysqladmin does not use STDIN to read in the password. How do they do it then, and how could I implement this functionality?
Answering in case someone finds this googling.
It isn't possible in pure PHP. The solution is to execute a small shell script for Linux or a small program for Windows.
The shell script would look like this for the zsh shell:
/usr/bin/env zsh -c 'stty -echo; read -r mypassword; stty echo; echo $mypassword'
A full working implementation was written by Seldaek from Composer, which you can find at https://github.com/Seldaek/cli-prompt

interactive console for Ruby, PHP

How do you start the Interactive Console for ruby and php
For ruby, you want the 'irb' command.
For python, you can enter interactive mode with the 'python' command.
For php, you enter a basic interactive mode with 'php -a'. Because of its limitations, other interactive shells have sprung up. PHP-Shell is one of them.
Also, if you are working with a Ruby On Rails project you could use
ruby script/console
from your Rails application root. This is a good approach since you get an interactive ruby shell and the advantage is that loads the entire application stack for you. Pretty handy if you are testing your new code or trying to debug something.
php doesn't lend itself very well to an interactive shell, because you can't redefine functions and classes. So while there is an interactive shell available, it's not very useful.
Make sure you have php5-cli installed and type 'php -a' at the command line.
you are looking for phpsh same as irb for ruby. php-cli allow you to run scripts for the command line like
myserver> php -r "echo 'hola mundo';"
so what you are asking and all replies about php-cli are different. also php-cli has it own php.ini that allow you to have differents configurations depends of run php over httpd (like apache) or in bash
saludos
There is an excellent script for PHP that allows you to run a php console on a local website.
http://seld.be/notes/php-console-in-your-browser
There's obvious security implications here, but if it's only accessible locally, then there's no need to worry.
Really saves time if you want to double check the function behaviour, or to isolate a piece of code and diagnose what happens.
For a console with a rails 3.x+ project loaded
rails c
this is shorthand for ruby scripts/rails console
See more abbreviations here: http://xyzpub.com/en/ruby-on-rails/3.2/abkuerzungen.html
In php its php or php-cli - different name in different installations

Categories