Colorize an image with transparenz

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
destroyed

Colorize an image with transparenz

Post by destroyed »

Hello,
I'm searching for a way to colourize an image by another colour-layer but the results so far let a bit to be desired.

This is the image which should be recoloured:
Image

This is the colour-layer:
Image

This is the result so far:
Image

Here is my Code:

Code: Select all

private function colorizeVinyl(){
		$colorWand = new Imagick();
		$colorWand->newImage(600,600,$this->color,"png");
		
		$this->vinylimage->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
		$this->vinylimage->setImageMatte(true);
		$this->vinylimage->compositeImage($colorWand,Imagick::COMPOSITE_ADD,0,0);
		
		echo $this->vinylimage;
	}
I've already tried some other composite filters but none shows the desired result. In Photoshop the layermode is called "linear dodge".

I hope somebody can help me with this problem.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Colorize an image with transparenz

Post by fmw42 »

In Imagick look up the equivalent of the command line functions -fill and -colorize. see http://us3.php.net/manual/en/function.i ... eimage.php

convert blackeh.png -fill "#3a633c" -colorize 50% blackeh_colorize50.png
Image


convert blackeh.png -fill "#3a633c" -colorize 75% blackeh_colorize75.png
Image


convert blackeh.png -fill "#3a633c" -colorize 100% blackeh_colorize100.png
Image
destroyed

Re: Colorize an image with transparenz

Post by destroyed »

Thanks for the answer but the result hast not the same luminance as the source.
I have found a way which works perfect but its needs to do a part by command line.
convert "source.png" "color.png" -compose LinearDodge -composite "tmp.png"

Code: Select all

private function colorizeVinyl(){
		$colorWand = new Imagick();
		$colorWand->newImage($this->size,$this->size,$this->color,"png");
		$colorWand->writeImage($this->path_Temp."/tmp.png");
		$colorWand = null;
		exec("convert \"".$this->path_Rohling."\" \"".$this->path_Temp."tmp.png\" -compose LinearDodge -composite \"".$this->path_Temp."tmp.png\"");
		$this->vinylimage = new Imagick($this->path_Temp."tmp.png");
}
Does anyone know how to use the LinearDodge compositing option in imagick? It seems that they is not included at the moment.

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

Re: Colorize an image with transparenz

Post by anthony »

It should be applied in that same way that any composition is done in IMagick.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
destroyed

Re: Colorize an image with transparenz

Post by destroyed »

Yes but there is no constant for that mode.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Colorize an image with transparenz

Post by fmw42 »

Imagick was not created nor supported by ImageMagick. You need to contact the creator of Imagick. I believe memberlist.php?mode=viewprofile&u=8923
Post Reply