PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Sep 17, 2019 11:08 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: imagecopymergegray
PostPosted: Tue Sep 22, 2009 1:31 am 
Offline
Forum Newbie

Joined: Tue Sep 22, 2009 1:26 am
Posts: 1
Location: Singapore
Hello everybody,

I am doing some transformation and merging of different images and now would like one of the layers to simply be monochrome. The code I am using is:

$final_face_gray = imagecreatetruecolor(imagesx($final_face), imagesy($final_face));
imagecopymergegray($final_face_gray, $final_face, 0, 0, 0, 0, imagesx($final_face), imagesy($final_face), 0);
imagepng($final_face, 'original.png');
imagepng($final_face_gray, 'gray_face.png');

The original.png shows the right image and the gray_face.png is just a black image in the right size. If I change the last parameter of the imagecopymergegray to 50 then the image is desaturated a bit but obviously this is not completely black&white as I would like it to be.

What am I missing? Do I have to create a separate palette or something? I saw some sites doing pixel by pixel copying but it seemed to me superfluous as from my understanding imagecopymergegray should take care of all of this?!

Thanks,
Jonas


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group