can't get white background for display or convert

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
MikeR

can't get white background for display or convert

Post by MikeR »

I've just installed ImageMagick 6.5.1-0 2009-08-27 Q16 for a fresh install of Ubuntu 9.10 Karmic Koala OS. When I open an encapsulated postscript file there is a gray checkerboard pattern for background. I'm almost certain it should be white background, as other image display software like ghostview and XV show white. The documentation says default background for ImageMagick is white. My previous version of ImageMagick on an older version of Ubuntu worked as expected. I should mention that I'm primarily interested in converting the EPS to GIF using this software.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: can't get white background for display or convert

Post by snibgo »

I don't think IM will ever create a chequer backgound, unless you ask it to. Perhaps your image viewer is showing that for transparency.

Please post your EPS file and exact command you are using.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: can't get white background for display or convert

Post by fmw42 »

If your file has transparency and you use the display or show: options to display in X11, then you will get a checker background (not too sure about display as it has changed behavior on my Mac lately). But show: does have a checker background when use to view your transparent image. Display has options that allow you to specify a background image when you have transparency. see http://www.imagemagick.org/script/display.php

convert image.png show:

display image.png
MikeR

Re: can't get white background for display or convert

Post by MikeR »

snibgo: How do I post the image file? I do not have a dedicated web site for this purpose.

fmw4: Not sure I follow what you're saying.

I'm using the display command, but the checkerboard background also shows when I use the open function in ImageMagick GUI.

I also note that the test png file image.png found here:

http://www.imagemagick.org/Usage/

also shows checkerboard background pattern in ImageMagick, but not with other viewers.

The display command properly renders JPG and GIF images. Seems that these EPS I've created with PGPLOT are the problem.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: can't get white background for display or convert

Post by fmw42 »

the various IM display devices, display, show: and the GUI will put a checkerboard background underneath the transparent parts of the image. Other views may or may not do that.

To post an image, you need to find some free image web site, post your image there and then put a link in your messages here to that image file. There are a number of free sites that will allow you to post an image.
MikeR

Re: can't get white background for display or convert

Post by MikeR »

I've now tested my EPS image file, created with PGPLOT, using:

evince
ghostview
GIMP photo editor

All render the image as expected. But as I mentioned, ImageMagick gives me a checkerboard background.

As a test, I've downloaded another EPS file from here:

http://www.freevectors.com/vector_graphic/97

The three applications above all show the image as salmon color over white background. ImageMagick on my Ubuntu 9.10 OS shows not a checkerboard, but, rather, blue streaks on black.
MikeR

Re: can't get white background for display or convert

Post by MikeR »

EPS file (test.eps) posted to:

http://www.badongo.com/file/21239896
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: can't get white background for display or convert

Post by fmw42 »

MikeR wrote:EPS file (test.eps) posted to:

http://www.badongo.com/file/21239896
I have downloaded this and opened it in IM using

convert test.eps show:

and it shows a checker background because the image is transparent. If I display it in some other tool, such as Mac Preview or GraphicConverter, it shows with a white background. This is just the way various tools deal with indicating where the image is transparent.

When I use the IM GUI or display test.eps, the image shows with no background and one can see through to the windows underneath.

This seems to be a Mac issue as I have raised it before and was told it could not be reproduced on Linux and that Linux would show checkerb oard background where the image is transparent.

Having the checkerboard there does not mean that it is part of the image. Only that the image is transparent and the display device is indicating that by putting a checkerboard underneath the image.
MikeR

Re: can't get white background for display or convert

Post by MikeR »

1) Imagemagick used to display like other viewers. It is unfortunate that is does not do so now.

2) I have tried to make the transparent background white, using -background and transparent-color. No luck

Regarding 1), why the change?

I'd previously been able to do a very simple conversion from EPS to GIF using convert command. No longer. Linux really needs a decent, straightforward conversion tool to do this. I've brought that up on Ubuntu forums.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: can't get white background for display or convert

Post by fmw42 »

there is nothing wrong with the IM display in principle. it is a choice of how to deal with transparency. what do you show behind the transparent parts? IM chose to put a checkerboard background to re-inforce that it is transparent. other systems just put white or black or gray and so you have no idea whether it is transparent or not.

this works for me!

convert test.eps -background white -flatten test.gif

convert test.gif show:

That makes the transparent parts white and remove the transparency all together and show: does not show the checkerboard any longer as the image is not transparent and has a true white background in the image.
MikeR

Re: can't get white background for display or convert

Post by MikeR »

Agreed. I note the -flatten option you mention produces a white background. Moreover, I've just found that I can force my graphics software to underlay a white background on each image. Thanks for the help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: can't get white background for display or convert

Post by fmw42 »

MikeR wrote:Agreed. I note the -flatten option you mention produces a white background. Moreover, I've just found that I can force my graphics software to underlay a white background on each image. Thanks for the help.
-flatten can make any color background, the color is controlled by the -background setting

if you leave off the -background, then I believe it defaults to white.
Post Reply