scaleImage and remove image background

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
smartscript
Posts: 1
Joined: 2014-07-11T12:24:57-07:00
Authentication code: 6789

scaleImage and remove image background

Post by smartscript »

Hi

What i'm trying to do is to scale logo uploads and also make the image background transparent but only if the background is white.

I'm scaling the image using PHP code below.

Please can anyone help?

Code: Select all


function MakeThumb($height, $width, $original, $new_file, $mime_type)
	{
		// iMagick
		if(class_exists('Imagick')) 
		{
			$thumb = new Imagick($original);
			$thumb->scaleImage($width, $height, true);
			$thumb->writeImage($new_file);
			$thumb->destroy();
		}
	}
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: scaleImage and remove image background

Post by fmw42 »

In command line you would use -fuzz XX% -transparent white. See if there are Imagick commands to do that. If you make -fuzz with XX=0 or leave it off, then it will only make exactly (pure) white pixels transparent.

see http://us3.php.net/manual/en/imagick.tr ... timage.php
Post Reply