Welcome to the Linux Foundation Forum!

gnome-web-photo & php

Hello,

I have implemented this script:

<?php
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.

Comments

  • 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:

    <?php
    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:
    http://php.net/manual/en/book.imagick.php
    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.

Categories

Upcoming Training