extent turns entire image black

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
sslebedev
Posts: 2
Joined: 2016-10-31T08:01:54-07:00
Authentication code: 1151

extent turns entire image black

Post by sslebedev »

Hello,

I have .PNG images and I want to extend their size by several transparent pixels (transparent border, for example). I'm doing it like this:

Code: Select all

magick mogrify -background none -extent 1152x344 Background.png
It works for most of test images given, but several images like this https://www.dropbox.com/s/731r58oh5ncnb ... d.png?dl=0 becomes all black. I can add transparency to the image by '-transparent white' but it is also lost after subsequent extension. I also tryed other options, option orders etc, but it changed nothing.

What am I doing wrong? Why it bahaves like this? Can it be performed without any losses of quality?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: extent turns entire image black

Post by fmw42 »

This seems to be an oddity of IM 7. Try adding -alpha set after reading the input.

In IM 6.9.6.2, this works fine

Code: Select all

convert Background.png -background none -extent 1152x344 tmp.png
In IM 7, this produces an all transparent image.

Code: Select all

magick Background.png -background none -extent 1152x344 tmp.png
But this works fine in IM 7

Code: Select all

magick Background.png -alpha set -background none -extent 1152x344 tmp.png
So does this:

Code: Select all

magick mogrify -alpha set -background none -extent 1200x400 background.png
sslebedev
Posts: 2
Joined: 2016-10-31T08:01:54-07:00
Authentication code: 1151

Re: extent turns entire image black

Post by sslebedev »

Sure, it works, thank you very much.

P.S. I've been sure I tried this combination... (sad)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: extent turns entire image black

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.
Post Reply