Page 1 of 1

[RESOLVED] Background color not applied in conversion from EPS to JPEG

Posted: 2015-02-16T07:37:50-07:00
by kriks
Hi all,

given a EPS with a named clip path, I want to convert it into a JPEG with the clip area colored (from background-color).

I use IM 6.9.0-3 and GS 9.15

Here is the EPS : http://kriks.free.fr/IM/ball/ballon_foot.eps
Here is my command-line (I tried various placements of the background parameter):

Code: Select all

convert -verbose -units PixelsPerInch -density 100 'ballon_foot.eps[0]' +repage -auto-orient -resize 500x500 -colorspace 'sRGB' -alpha transparent -clip-path 'det' -alpha opaque -background red -flatten 'JPEG:ballon.jpg'
This will result in a black background around the ball : http://kriks.free.fr/IM/ball/ballon.jpg

Outputing as PNG then piping into convert to get a JPEG with the background-color works (but it would reduce the case to RGB images):

Code: Select all

convert -verbose -units PixelsPerInch -density 100 'ballon_foot.eps[0]' +repage -auto-orient -resize 500x500 -colorspace 'sRGB' -alpha transparent -clip-path 'det' -alpha opaque PNG32:- | convert PNG32:- -background red -flatten 'JPEG:ballonByPng.jpg'
http://kriks.free.fr/IM/ball/ballonByPng.jpg

Am I wrong with my use of Imagemagick or is there a bug somewhere ?

Re: Background color not applied in conversion from EPS to JPEG

Posted: 2015-02-17T07:44:35-07:00
by snibgo
Your first command has "-alpha opaque -background red -flatten". This makes pixels opaque, so "-flatten" will do nothing, so "-background red" does nothing.

This does what I think you want:

Code: Select all

%IM%convert ^
  -verbose -units PixelsPerInch -density 100 ballon_foot.eps[0] ^
  -colorspace sRGB ^
  -alpha transparent -clip -alpha opaque +clip ^
  -background red -flatten ^
  -resize 500x500 ^
  x1.jpg
Windows BAT syntax, so adjust as required.

I convert to sRGB early, but I leave the resize to the end to get a cleaner transition to the background.

"-alpha transparent -clip -alpha opaque +clip" makes the entire image transparent, then turns the clip area opaque. Then "-background red -flatten" turns the tansparent area red.

Re: Background color not applied in conversion from EPS to JPEG

Posted: 2015-02-18T02:15:41-07:00
by kriks
Thank you very much !

The part that was missing was "+clip" to deactivate the clip path for the next operations.
And the resize tip is also great :)

Re: [RESOLVED] Background color not applied in conversion from EPS to JPEG

Posted: 2015-02-18T10:24:44-07:00
by snibgo
Yes, -clip almost always needs +clip, like a bracketing pair.