convesion of psd file with ColorSpace cmyk to jpg always have always black background

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?".
Locked
vinoddogra10
Posts: 3
Joined: 2020-01-15T05:27:09-07:00
Authentication code: 1152

convesion of psd file with ColorSpace cmyk to jpg always have always black background

Post by vinoddogra10 »

Hi,
I am converting psd file to jpg

I want to change the transparency with white color , but the output result is always black.

psd file have ColorSpace = CMYK.

Here is my code

Code: Select all

MagickImage image = new MagickImage();
image.Read(imagefullpath, null)

var resizeGeometry = new MagickGeometry(566,800);
image.Resize(resizeGeometry);
MagickImage tempImage = new MagickImage(image);
tempImage.BackgroundColor = new MagickColor(255, 255, 255);
tempImage.Alpha(AlphaOption.Remove);
tempImage.ColorAlpha(tempImage.BackgroundColor);
tempImage.Density = new Density(73,73);
tempImage.Quality =70;
tempImage.Strip();
tempImage.Write(outfile)

tempImage.Dispose();

image.Dispose();
My example file is too large so can't able to upload the file.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convesion of psd file with ColorSpace cmyk to jpg always have always black background

Post by snibgo »

vinoddogra10 wrote:ColorSpace = CMYK

MagickColor(255, 255, 255);
CMYK "255" means full ink, so this is black.
snibgo's IM pages: im.snibgo.com

vinoddogra10
Posts: 3
Joined: 2020-01-15T05:27:09-07:00
Authentication code: 1152

Re: convesion of psd file with ColorSpace cmyk to jpg always have always black background

Post by vinoddogra10 »

thanks the fix is working
Last edited by vinoddogra10 on 2020-01-16T03:50:59-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convesion of psd file with ColorSpace cmyk to jpg always have always black background

Post by fmw42 »

I believe that you have removed the alpha channel before you apply the background color. Change the order of those two lines.

From:

Code: Select all

tempImage.Alpha(AlphaOption.Remove);
tempImage.ColorAlpha(tempImage.BackgroundColor);
To:

Code: Select all

tempImage.ColorAlpha(tempImage.BackgroundColor);
tempImage.Alpha(AlphaOption.Remove);

vinoddogra10
Posts: 3
Joined: 2020-01-15T05:27:09-07:00
Authentication code: 1152

Re: convesion of psd file with ColorSpace cmyk to jpg always have always black background

Post by vinoddogra10 »

The image colors are changed if removed the alpha channel before applying the background color.

Locked