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?".
Using the PHP API, I'm capturing a user's hand written signature and attempting to make it a 32-bit transparent png to be overlayed on a PDF form. The code I have below actually works and displays in the browser fine but there is a problem with the png when it is opened in Photoshop or applied to a PDF document. When I open the png in Photoshop or insert it into a PDF it is solid blue.
Your image has blue writing on a transparent blue backgound. Every single pixel is blue; only the alpha varies.
When I convert it to PDF (IM v6.8.9-0, Ghostscript v9.10), I get the expected blue writing on a transparent background.
I don't have Photoshop so can't test with that. But I can't see why there would be problems.
"identify -verbose" shows the image has gamma=1, which is unsual. Gamma=0.454545 (sRGB) would be more common. That should make no dfference to this image, as all pixels are (0,0,255), so gamma has no effect.
This will fix it -- tested with PS CS (so kind of old). Sets the background under the transparency to black leaving the background blue where there is writing in the alpha channel.
Thanks for your input. I followed the advice but it only gave me a workaround and I just wasn't satisfied with that. I really wanted the authentic, semitransparent anti-aliasing. There was only one problem with my solution and it turned out to be a quirky issue with Imagick itself. So for the benefit of future generations, here is the solution:
$sig = new Imagick();
$sig->readImageBlob($hex); // this is an 8-bit grayscale bmp image, black signature on white background
// I don't know/care if this is all necessary but it ensures I end up with the intended file format
$sig->setImageType(Imagick::IMGTYPE_TRUECOLORMATTE);
$sig->setImageColorspace (imagick::COLORSPACE_RGB);
$sig->setImageDepth(32);
$sig->setImageFormat('PNG32');
$sig->negateImage(true);
// this is the correct way to acheive a colored shape in Imagick
$sig->setImageBackgroundColor('blue');
$sig->setImageAlphaChannel (Imagick::ALPHACHANNEL_SHAPE);
$sig->writeImage('PNG32:'.$fileName); // saving with the PNG32 designation before the file name was the key! Otherwise Imagick was saving as an 8 bit png format regardless of the directions I gave it above. Many Bothans died to bring us this information.
I do not think this is realistic or applicable if you are not using Q32 IM. If you are on Q16 or Q8, the best you can do is depth 16 or 8, respectively. depth in IM is per channel, not per pixel. PNG32: ensures you have 8-bits per channel including the alpha channel
I do not think this is realistic or applicable if you are not using Q32 IM. If you are on Q16 or Q8, the best you can do is depth 16 or 8, respectively. depth in IM is per channel, not per pixel. PNG32: ensures you have 8-bits per channel including the alpha channel