Strange black bars

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
himowa
Posts: 2
Joined: 2017-09-09T12:02:13-07:00
Authentication code: 1151

Strange black bars

Post by himowa »

Hello! First time posting here so please let me know if you need more info. I am running Imagemagick 7.0.7 on my Centos server with Imagick PHP 3.4.3. I recently upgraded from an outdated version when doing a server migration and now code that works just fine produces strange black bars.

http://imgur.com/a/PqW50

Here is an example, normally the image would be just a white alligator. The code I have written recolors certain image layers and then composites them together to form one image with various colors.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Strange black bars

Post by fmw42 »

Have you tried doing your command in equivalent command line mode? Does it fail that way? Did 7.0.7 come with CENTOS or did you install it? Is PHP 3.4.3 and Imagick compatible with IM 7? Have you tried using IM 6 and Imagick? What is your minor version of 7.0.7.x? How did you install it? If from source, then did you install all the needed delegates for various image formats? Is there a simple code example that reproduces the issue?
himowa
Posts: 2
Joined: 2017-09-09T12:02:13-07:00
Authentication code: 1151

Re: Strange black bars

Post by himowa »

Hey thanks for replying and sorry for the delay in responding back! I'll do my best to answer your questions but please bare with me, I am a novice at working with IM especially from the command line.

I was able to composite layers in the command line without encountering the bug, but I was unable to figure out how to replicate the recolor process in this way. However, running a similar script in PHP without recoloring produces no bars, so the issue is definitely with the recolor!

7.0.7 was installed by the company that hosts the server. I requested the most up-to-date version.

I really don't know, how can I check this?

IM 6 and Imagick had a different bug that prevented me from retaining the alpha shape of an image while recoloring, prompting me to request an upgrade. Though it seems IM7 also doesn't recolor properly.

ImageMagick 7.0.7-0 Q16 x86_64 2017-09-07

I am unsure how exactly it was installed, as it was installed by the server admins.

Here's the function I use to recolor, which seems to be the section that is causing the bug. The intended purpose is to recolor the image with a flat color hex and retain the shape/alpha of the image.

Code: Select all

protected function recolor($obj, $hex)
{
    $obj->setImageAlphaChannel(Imagick::ALPHACHANNEL_EXTRACT);
    $obj->setImageBackgroundColor('#' . str_replace('#', '', $hex));
    $obj->setImageAlphaChannel(Imagick::ALPHACHANNEL_SHAPE);
    return $obj;
}
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Strange black bars

Post by fmw42 »

Your same code is discussed here: http://php.net/manual/en/imagick.colorizeimage.php. Does setImageBackgroundColor permit hex colors and have you provide that with the correct syntax? Try putting in a specific hex color and see if that works rather than a variable for $hex. Does your version of Imagick support IM 7?
Post Reply