Welcome to the Linux Foundation Forum!

gnome-web-photo & php


I have implemented this script:

shell_exec('gnome-web-photo -t 0 --mode=thumbnail -w 512 -s 256 http://www.google.com /tmp/google.jpg');

If I execute it in the shell it runs perfectly, but if I execute it in a browser I view this error: Cannot open display:

Somebody can help me please?

Thank you so much.


  • gomer
    gomer Posts: 158
    Sounds like the application is trying to open the X display. Are you trying to get the image to display for someone logged into the server's console or for someone logged into a web site?
  • gomer
    gomer Posts: 158
    It looks like the app won't actually print to the screen the way you've invoked it, so maybe you can get away by setting the DISPLAY environment variable first:

    shell_exec('DISPLAY=0:0 gnome-web-photo -t 0 --mode=thumbnail -w 512 -s 256 http://www.google.com /tmp/google.jpg');
  • Thank you for your quickly response.

    I have tried your option but the result is the same error.

    Best regards.
  • gomer
    gomer Posts: 158
    I did a stack trace on gnome-web-photo.

    open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = 3
    close(3) = 0

    I'm not sure why, but it really wants to open the terminal.

    If your goal is just to generate a thumbnail, have you considered using imagemagick's convert?
  • Thanks,

    Do you know some method to make a thumbnail with php and imagemagick?
  • gomer
    gomer Posts: 158
    The API is here:
    Simply, Imagick::thumbnailImage should do the trick.

    If you wanted to still use imagemagick on the command line, then something akin to:
    convert -thumbnail 100x100x0x0 original.jpg new.jpg

    or convert -resize works, too.


Upcoming Training