ImageMagic and Drupal

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
marzmurphy

ImageMagic and Drupal

Post by marzmurphy »

Hi there,

Am wondering if anyone can help me.. Im using the imagemagick libary with Drupal,and am not really sure how it all works. I cant find any tutorials on line(anyone know of any?!?) , but I basically want to add a function whereby a solid background is removed from an image, leaving only the foreground object....(wont have any of the background colours in it!!) Is there a command line tool that will already do this? I have a php script from a previous found site but not even sure where to put this script in order for it to work(what folder etc). I know Drupal is outside the use of these forums, but am really really hoping that someone might be able to help me.

Thanks for any info or advice :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: ImageMagic and Drupal

Post by anthony »

Drupal is a Web application and you may be better talk to other users on a drupal forum about this. I myself and probably most other here do not know how Drupal calls ImageMagick. For example: Does it uses it as a API, or make command line calls?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
marzmurphy

Re: ImageMagic and Drupal

Post by marzmurphy »

Hi Anthony,

It uses command line tools but unfortuantly it only recognises some of them(i think), have been trying to alter the colour channels and make a background block colour transparent but it just keeps returing an error of no such files/commands found.

Il keeping trying though(unfortunately not hugely familiar with either applications :( ......not many on the Drupal forum are that familliar with it either so was chancing the arm on the hope someone might know about it here !!!

Thanks anyways :)

PS: I might just try use the imagemagick on its own, can I ask a basic question, if I have a php script to remove the background of an image -

<?php

$filename = "The name of the image from the upload form";

$cmd = " $filename -transparent the_colour ";

exec(" convert $cmd output_filename_and_path ");

?>

<?php
// If the form has been submitted do this
if ( $Submit ) {

// Temporary upload image name
$original_image = $_FILES['filename']['tmp_name'];

// Get the image dimensions
$size=GetImageSize( $original_image );

// Name to save the image as - in this case the same as the original
$new_image = $_FILES['filename']['name'];

// Maximum image width
$max_width = "200";

// Maximum image height
$max_height = "90";

// Resize the image and save
exec("convert -size {$size[0]}x{$size[1]} $original_image -thumbnail $max_widthx$max_height $new_image");

echo "File uploaded<br>";

echo "<img src=\"".$new_image."\">";
}
else { ?>
<p>File to upload:</p>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<input type="file" name="filename" />
<input type="Submit" name="Submit" value="Submit" />
</form>
<?php } ?>


Where exactly would I put this script, or is there a command line tool that would do it automatically instead.....sorry have been gettinga bit confused by the whole process....greatly appriciate any advise or info that may have.

Thanks mary :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: ImageMagic and Drupal

Post by anthony »

If it is saying command not found than presumably you have a PATH problem.
that is it does not know where the "convert" command is.


This will all be the same type of problems PHP users face when they use the commands. See IM Examples, PHP for tips and techniques for solving these problems, and also visit RubbleWeb who documents many examples for PHP.

http://www.imagemagick.org/Usage/api/#php
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply