3

I try to convert a rgb color to transparent

When i use this code in the command line, it works perfect.

convert -transparent 'RGB(249,249,255)' /home/me/web/my.png /home/me/web/mynew.png

But when i use it with php:

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

$output = shell_exec("convert -transparent 'RGB(249,249,255)' /home/me/web/my.png /home/me/web/mynew.png");

?>

i get the error:

convert: unable to open image `/home/me/web/mynew.png': @ error/blob.c/OpenBlob/2498.

Has anyone a idea?

2
  • is the path in the error message the correct path to your file? Commented Sep 5, 2012 at 9:02
  • now the path is corrected, but still the same error... Commented Sep 5, 2012 at 11:32

2 Answers 2

4

you have to use relative paths to your homedir (because of shell_exec) otherwise you have to use absolute paths.

But why dont you use imagemagick for php?

Sign up to request clarification or add additional context in comments.

1 Comment

Path is now corrected, but still the same error. I don't use imagemagick for php because I can't find the convert -transparent command in there...
3

To me that looks like an access-rights issue. Your web server tries to write a file inside your home directory.

Normally your home-directory is protected in such a way that no one except yourself can write files in there. Therefore your web server can not create the new file while you can when using the terminal.

Check the access rights to the folder that shall contain the new image and allow the user that is running the web server to write to that folder.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.